mirror of
https://github.com/Noratrieb/minmax.git
synced 2026-01-14 23:35:04 +01:00
player
This commit is contained in:
commit
2fa7531824
8 changed files with 352 additions and 0 deletions
19
src/lib.rs
Normal file
19
src/lib.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
mod board;
|
||||
mod game;
|
||||
|
||||
use board::Player;
|
||||
|
||||
pub use board::Board;
|
||||
|
||||
pub trait GamePlayer {
|
||||
fn next_move(&mut self, board: &mut Board, this_player: Player);
|
||||
}
|
||||
|
||||
pub struct GreedyPlayer;
|
||||
|
||||
impl GamePlayer for GreedyPlayer {
|
||||
fn next_move(&mut self, board: &mut Board, this_player: Player) {
|
||||
let first_free = board.iter().position(|p| p.is_none()).unwrap();
|
||||
board.set(first_free, Some(this_player));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue