Skip to content

Commit 9c6e415

Browse files
chore: simplify tuning result print code
1 parent eda43f0 commit 9c6e415

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/bin/hce-tuner/main.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use std::process::exit;
22

3-
use chess::{definitions::NumberOf, pieces::PIECE_NAMES};
3+
use chess::{
4+
definitions::NumberOf,
5+
pieces::{ALL_PIECES, PIECE_NAMES},
6+
};
47
use clap::Parser;
58
use indicatif::ParallelProgressIterator;
69
use parameters::Parameters;
@@ -52,11 +55,12 @@ fn print_params(params: &Parameters) {
5255
println!("Tuned parameters:");
5356
println!("=================");
5457
println!("pub const PSQTS : [[PhasedScore; NumberOf::SQUARES]; NumberOf::PIECE_TYPES] = [");
55-
for i in (0..params.len()).step_by(NumberOf::SQUARES) {
56-
println!(" // {}", PIECE_NAMES[i / (NumberOf::SQUARES)]);
58+
for piece in ALL_PIECES {
59+
println!(" // {}", PIECE_NAMES[piece as usize]);
5760
println!(" [");
58-
59-
let table = &params.as_slice()[i..i + NumberOf::SQUARES];
61+
let start_idx = piece as usize * NumberOf::SQUARES;
62+
let end_index = start_idx + NumberOf::SQUARES;
63+
let table = &params.as_slice()[start_idx..end_index];
6064
print_table(8, table);
6165
println!(" ],");
6266
}

0 commit comments

Comments
 (0)