aboutsummaryrefslogtreecommitdiff
path: root/src/board/io.rs
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-08-22 02:59:20 +0300
committereug-vs <eugene@eug-vs.xyz>2023-08-22 05:56:11 +0300
commita3bef6f93a960ad51d7601ed8e53c6a83a532f71 (patch)
treefffffe84df9c1e4903ccf0fd48db099758078a60 /src/board/io.rs
parentbc599d145a8d3a5e69128bc9e702ac7a32d73a4c (diff)
downloadchessnost-a3bef6f93a960ad51d7601ed8e53c6a83a532f71.tar.gz
feat: improve UCI position fen moves case
Diffstat (limited to 'src/board/io.rs')
-rw-r--r--src/board/io.rs18
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