-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix mutate state in Nego::apply, and some cleanups + tests
- Loading branch information
1 parent
ddb73c4
commit db13116
Showing
27 changed files
with
32,185 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,44 @@ | ||
use nego::{agent, core}; | ||
use nego::{agent, core::game, core::ray::Rays}; | ||
|
||
use minimax::Game; | ||
|
||
#[macro_use] | ||
extern crate log; | ||
|
||
pub fn demo_minimax() { | ||
let mut state = game::State::new(); | ||
let mut s = 0; | ||
|
||
let timeout = std::time::Duration::from_secs(60); | ||
loop { | ||
state.dump(); | ||
let new_state_opt = if s == 0 { | ||
agent::AIPlayer::Random.step(&state, timeout) | ||
} else { | ||
agent::AIPlayer::Iterative.step(&state, timeout) | ||
}; | ||
s = 1 - s; | ||
|
||
if let Some(new_state) = new_state_opt { | ||
state = new_state; | ||
} else { | ||
break; | ||
} | ||
} | ||
println!( | ||
"Winner: {:?} (b={}, w={})", | ||
agent::Nego::get_winner(&state), | ||
state.board.black.points(), | ||
state.board.white.points() | ||
); | ||
state.dump(); | ||
} | ||
|
||
fn main() { | ||
pretty_env_logger::init(); | ||
|
||
info!("initializing ray LUT"); | ||
core::ray::Rays::build_lut(); | ||
Rays::build_lut(); | ||
|
||
agent::demo_minimax(); | ||
demo_minimax(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.