aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-01-31 11:14:30 +0300
committereug-vs <eugene@eug-vs.xyz>2023-01-31 11:14:30 +0300
commitef1f7eb8959b788e7b3fec4a01c86eb8cf1e7b04 (patch)
tree444b7bdb46c1244dc26d7ededf006700d9618e83
parent69913f7b0b046ec4c64269b78da4f81c4c386b6d (diff)
downloadchessnost-ef1f7eb8959b788e7b3fec4a01c86eb8cf1e7b04.tar.gz
feat: parse fen from commandline
-rw-r--r--src/main.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 88e878d..53a72ea 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -39,10 +39,9 @@ fn computer_move(board: &mut Board, time_left: &mut Duration) {
board.print();
}
-
fn main() {
let args: Vec<String> = env::args().collect();
- assert!(args.len() >= 3, "Provide all arguments [COLOR] [TIME_MINUTES] [INCREMENT_SECONDS]");
+ assert!(args.len() >= 4, "Provide all arguments [COLOR] [TIME_MINUTES] [INCREMENT_SECONDS]");
let color = match args[1].as_str() {
"w" => Color::White,
@@ -50,7 +49,7 @@ fn main() {
_ => panic!("Please provide a color [w|b]")
};
- let mut time_left = Duration::from_secs(match args[2].parse() {
+ let mut time_left = Duration::from_secs(60 * match args[2].parse() {
Ok(x) => x,
Err(..) => 15
});
@@ -61,8 +60,11 @@ fn main() {
});
let manual_decrement = Duration::from_secs(7); // Time to sync moves with the game
- // let fen = String::from("8/8/8/1r6/3NK3/5Q2/5p2/5k2 w - - 0 1");
- let mut board = Board::new();
+ let mut board = if args.len() == 5 {
+ Board::from_FEN(args[4].to_string())
+ } else {
+ Board::new()
+ };
board.print();
loop {