diff options
Diffstat (limited to 'src/board/io.rs')
-rw-r--r-- | src/board/io.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/board/io.rs b/src/board/io.rs index 15d7744..78651d5 100644 --- a/src/board/io.rs +++ b/src/board/io.rs @@ -49,7 +49,9 @@ impl IO for Board { let mut rank = 7; let mut file = 0i32; - for character in fen.chars() { + let mut chars = fen.chars(); + + for character in chars.by_ref() { let index = rank * 8 + file; let position = 1 << index.clamp(0, 63); @@ -79,20 +81,26 @@ impl IO for Board { rank -= 1; file = -1; // So it becomes 0 }, - ' ' => { break }, // TODO: break for now, parse everything else later - '-' => {}, // TODO - 'w' => {}, // TODO + ' ' => { break }, _ => todo!("Unexpected character!"), } file += 1; } } + let ply = match chars.next() { + Some(char) => match char { + 'w' => 0, + 'b' => 1, + _ => panic!("Expected side to move"), + } + None => panic!("Expected side to move"), + }; let mut board = Self { piece_sets, occupancy: 0, - ply: 0, + ply, attacks: Attacks::new(), castling_rights: [[true; 2]; 2], // TODO: actualy parse from FEN ep_target: None, // TODO: parse from FEN |