This commit is contained in:
nora 2022-10-31 14:37:52 +01:00
commit 2fa7531824
No known key found for this signature in database
8 changed files with 352 additions and 0 deletions

19
src/lib.rs Normal file
View 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));
}
}