Skip to content

Commit

Permalink
Parse int args
Browse files Browse the repository at this point in the history
  • Loading branch information
primenumber committed May 15, 2024
1 parent 15846c7 commit c40456d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,16 @@ fn generate_depth_n(board: Board, depth: usize, prev_passed: bool, record: &mut

pub fn parallel_self_play(matches: &ArgMatches) {
let output_path = matches.get_one::<String>("OUTPUT").unwrap();
let random_depth = *matches.get_one::<usize>("DEPTH").unwrap();
let take_count = *matches.get_one::<usize>("COUNT").unwrap();
let random_depth = matches
.get_one::<String>("DEPTH")
.unwrap()
.parse::<usize>()
.unwrap();
let take_count = matches
.get_one::<String>("COUNT")
.unwrap()
.parse::<usize>()
.unwrap();

let out_f = File::create(output_path).unwrap();
let mut writer = BufWriter::new(out_f);
Expand Down
24 changes: 20 additions & 4 deletions src/train.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ pub fn clean_record(matches: &ArgMatches) {
pub fn gen_dataset(matches: &ArgMatches) {
let input_path = matches.get_one::<String>("INPUT").unwrap();
let output_path = matches.get_one::<String>("OUTPUT").unwrap();
let max_output = *matches.get_one::<usize>("MAX_OUT").unwrap();
let max_output = matches
.get_one::<String>("MAX_OUT")
.unwrap()
.parse::<usize>()
.unwrap();

eprintln!("Parse input...");
let mut boards_with_results = Vec::new();
Expand Down Expand Up @@ -232,9 +236,21 @@ const PATTERNS_LARGE: [u64; 10] = [
pub fn train(matches: &ArgMatches) -> Option<()> {
let input_path = matches.get_one::<String>("INPUT").unwrap();
let output_path = matches.get_one::<String>("OUTPUT").unwrap();
let range_min = *matches.get_one::<i8>("from").unwrap();
let range_max = *matches.get_one::<i8>("to").unwrap();
let width = matches.get_one::<i8>("width").unwrap();
let range_min = matches
.get_one::<String>("from")
.unwrap()
.parse::<i8>()
.unwrap();
let range_max = matches
.get_one::<String>("to")
.unwrap()
.parse::<i8>()
.unwrap();
let width = matches
.get_one::<String>("width")
.unwrap()
.parse::<i8>()
.unwrap();

let in_f = File::open(input_path).ok()?;
let mut reader = BufReader::new(in_f);
Expand Down

0 comments on commit c40456d

Please sign in to comment.