Fix switch toggling

master
Louis Pearson 2022-08-04 22:32:20 -06:00
parent e8ebe43de6
commit 638440f619
1 changed files with 15 additions and 15 deletions

View File

@ -14,11 +14,11 @@ pub fn is_plug(tile: u8) bool {
} }
pub fn is_conduit(tile: u8) bool { pub fn is_conduit(tile: u8) bool {
return tile >= 97 and tile <= 112; return tile >= 97 and tile <= 113;
} }
pub fn is_switch(tile: u8) bool { pub fn is_switch(tile: u8) bool {
return tile >= 25 and tile <= 32; return tile >= 24 and tile <= 31;
} }
pub fn is_logic(tile: u8) bool { pub fn is_logic(tile: u8) bool {
@ -28,17 +28,17 @@ pub fn is_logic(tile: u8) bool {
pub fn toggle_switch(tile: u8) u8 { pub fn toggle_switch(tile: u8) u8 {
return switch (tile) { return switch (tile) {
// Tee west // Tee west
25 => 26, 24 => 25,
26 => 25, 25 => 24,
// Tee east // Tee east
27 => 28, 26 => 27,
28 => 27, 27 => 26,
// Vertical // Vertical
29 => 30, 28 => 29,
30 => 29, 29 => 28,
// Horizontal // Horizontal
31 => 32, 30 => 31,
32 => 21, 31 => 30,
// Not a switch, pass tile through // Not a switch, pass tile through
else => tile, else => tile,
}; };
@ -75,14 +75,14 @@ const Current = [4]bool;
fn get_inputs(tile: u8) Current { fn get_inputs(tile: u8) Current {
return switch (tile) { return switch (tile) {
// Conduit recieves from every side // Conduit recieves from every side
17...20, 16...20,
43...47, 43...47,
97...113, 97...113,
=> .{ true, true, true, true }, => .{ true, true, true, true },
// Switch_On // Switch_On
25, 25,
27, 27,
30, 29,
=> .{ true, false, true, false }, => .{ true, false, true, false },
// Switch_Off // Switch_Off
26, 26,
@ -101,7 +101,7 @@ fn get_inputs(tile: u8) Current {
fn get_outputs(tile: u8) Current { fn get_outputs(tile: u8) Current {
return switch (tile) { return switch (tile) {
// Conduit goes out every side // Conduit goes out every side
17...21, 16...20,
43...47, 43...47,
97...113, 97...113,
=> .{ true, true, true, true }, => .{ true, true, true, true },
@ -135,8 +135,8 @@ const Plugs = [4]bool;
fn get_plugs(tile: u8) Plugs { fn get_plugs(tile: u8) Plugs {
return switch (tile) { return switch (tile) {
17 => .{ false, false, true, false }, 17 => .{ false, false, true, false },
18 => .{ false, false, false, true }, 18 => .{ false, true, false, false },
19 => .{ false, true, false, false }, 19 => .{ false, false, false, true },
20 => .{ true, false, false, false }, 20 => .{ true, false, false, false },
else => .{ false, false, false, false }, else => .{ false, false, false, false },
}; };