improve player management
This commit is contained in:
16
src/game.rs
16
src/game.rs
@@ -1,4 +1,4 @@
|
||||
use crate::{agent::Agent, repr::Board};
|
||||
use crate::{agent::Agent, board::Board};
|
||||
use std::time::Duration;
|
||||
|
||||
pub struct Game {
|
||||
@@ -43,17 +43,17 @@ impl Game {
|
||||
|
||||
// TODO! make this loop good
|
||||
pub fn game_loop(&mut self) {
|
||||
let mut i = 0;
|
||||
loop {
|
||||
self.step(i);
|
||||
|
||||
// alternate which player plays
|
||||
i += 1;
|
||||
i %= self.players.len();
|
||||
|
||||
println!("{}", self);
|
||||
|
||||
std::thread::sleep(Duration::from_millis(500));
|
||||
self.step(0);
|
||||
println!("{}", self);
|
||||
|
||||
std::thread::sleep(Duration::from_millis(500));
|
||||
|
||||
self.step(1);
|
||||
println!("{}", self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user