summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: ee0ba591f3c0f7fcb175455bb1c7ef858b994c60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
extern crate worthebot_battleships;

use worthebot_battleships as bot;
use std::env;
use std::path::PathBuf;

fn main() { 
    let working_dir = env::args()
        .nth(2)
        .map(|x| PathBuf::from(x))
        .ok_or(String::from("Requires game state folder to be passed as the second parameter"));

    let result = working_dir.and_then(|working_dir| bot::write_move(working_dir));

    match result {
        Ok(()) => println!("Bot terminated successfully"),
        Err(e) => println!("Error in bot execution: {}", e)
    }
}