Skip to content

Commit

Permalink
Revert "more progress on kwg representative" for main_auto
Browse files Browse the repository at this point in the history
This reverts commit d43d6c2.
  • Loading branch information
andy-k committed Dec 3, 2023
1 parent 6c3076a commit b4067e5
Showing 1 changed file with 5 additions and 51 deletions.
56 changes: 5 additions & 51 deletions src/main_auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@ fn main() -> error::Returns<()> {
} else {
kwg::Kwg::from_bytes_alloc(&std::fs::read("lexbin/CSW21.kwg")?)
};
let kwg_representative = if jumbled {
kwg::Kwg::from_bytes_alloc(kwg::EMPTY_KWG_BYTES)
} else {
// cargo run --release --bin buildlex -- english-kwg-score lexsrc/CSW21.txt lexbin/CSW21-s.kwg
// (filename convention tbd)
kwg::Kwg::from_bytes_alloc(&std::fs::read("lexbin/CSW21-s.kwg")?)
};
let _ = kwg_representative;
//let kwg_representative = None;
/*
let _klv = klv::Klv::from_bytes_alloc(&std::fs::read("lexbin/english.klv2")?);
*/
Expand Down Expand Up @@ -96,8 +87,6 @@ fn main() -> error::Returns<()> {
let mut game_state = game_state::GameState::new(game_config);
let mut rng = rand_chacha::ChaCha20Rng::from_entropy();
let mut timers = game_timers::GameTimers::new(game_config.num_players());
let mut td1 = std::time::Duration::ZERO;
let mut td2 = std::time::Duration::ZERO;
loop {
game_state.reset_and_draw_tiles(game_config, &mut rng);
let mut final_scores = vec![0; game_state.players.len()];
Expand Down Expand Up @@ -151,10 +140,10 @@ fn main() -> error::Returns<()> {
game_config,
kwg: &kwg,
klv: &klv,
kwg_representative: Some(&kwg_representative),
kwg_representative: None,
};

if false {
if true {
move_generator.gen_moves_unfiltered(&movegen::GenMovesParams {
board_snapshot,
rack: &game_state.current_player().rack,
Expand All @@ -170,8 +159,8 @@ fn main() -> error::Returns<()> {

// stress-test scoring algorithm
if match &board_snapshot.game_config.game_rules() {
game_config::GameRules::Classic => false,
game_config::GameRules::Jumbled => false,
game_config::GameRules::Classic => true,
game_config::GameRules::Jumbled => true,
} {
let leave_scale = if let move_filter::GenMoves::Tilt { tilt, .. } = filtered_movegen
{
Expand Down Expand Up @@ -253,51 +242,16 @@ fn main() -> error::Returns<()> {
assert_eq!(issues, 0);
}

let t1 = std::time::Instant::now();
move_picker.pick_a_move(
filtered_movegen,
&mut move_generator,
board_snapshot,
&game_state,
&game_state.current_player().rack,
);
let d1 = t1.elapsed();
let first_play;
let first_eq;
{
let plays = &mut move_generator.plays;
let play = &plays[0].play; // assume at least there's always Pass
println!("Playing: {}", play.fmt(board_snapshot));
first_play = play.clone();
first_eq = plays[0].equity;
}

let bs = &movegen::BoardSnapshot {
kwg_representative: None,
..*board_snapshot
};
let t2 = std::time::Instant::now();
move_picker.pick_a_move(
filtered_movegen,
&mut move_generator,
bs,
&game_state,
&game_state.current_player().rack,
);
let d2 = t2.elapsed();
let plays = &mut move_generator.plays;
let play = &plays[0].play; // assume at least there's always Pass
println!("Playing: {}", play.fmt(bs));

td1 += d1;
td2 += d2;
if false {
println!("repr {:?} {:?} orig {:?}", d1, d1.cmp(&d2), d2);
}
println!("repr {:?} {:?} orig {:?}", td1, td1.cmp(&td2), td2);
if first_play != *play && first_eq != plays[0].equity {
panic!();
}
println!("Playing: {}", play.fmt(board_snapshot));

game_state.play(game_config, &mut rng, play)?;

Expand Down

0 comments on commit b4067e5

Please sign in to comment.