Compare commits

..

No commits in common. "e545f09bb43bc4227aa7b85e4797aedceee5679b" and "d8452daddf6e04c49366eb8da31f3cb328a9bd5f" have entirely different histories.

2 changed files with 9 additions and 9 deletions

View File

@ -217,16 +217,11 @@ impl Node {
board: &mut simulation::Board,
deadline: &Instant,
) -> Result<Option<SnakeToken>, DeadlineError> {
let stop_condition =
|board: &simulation::Board| board.alive_snakes() <= 1 || Instant::now() >= *deadline;
let winner = if stop_condition(board) {
if Instant::now() >= *deadline {
return Err(DeadlineError);
}
board.snakes().next()
} else if self.statistic.played == 0 {
let winner = if self.statistic.played == 0 {
// We didn't simulate a game for this node yet. Do that
board.simulate_until(&mut thread_rng(), stop_condition);
board.simulate_until(&mut thread_rng(), |board| {
board.alive_snakes() <= 1 || Instant::now() >= *deadline
});
if Instant::now() >= *deadline {
return Err(DeadlineError);
}
@ -257,6 +252,9 @@ impl Node {
})
.collect();
if Instant::now() >= *deadline {
return Err(DeadlineError);
}
board.simulate_actions(&actions, &mut thread_rng());
let winner = self
.childs

View File

@ -262,6 +262,7 @@ fn run_local_docker(port: u16) -> Result<Child, DynError> {
"--env",
format!("ROCKET_PORT={}", port).as_str(),
"--network=host",
"-i",
"--rm",
"local_snake",
])
@ -292,6 +293,7 @@ fn run_production(port: u16) -> Result<Child, DynError> {
"--env",
format!("ROCKET_PORT={}", port).as_str(),
"--network=host",
"-i",
"--rm",
"docker.mkaenner.de/snake:latest",
])