aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 {