blob: cec32568e7e3ed919395e7f7b0dc16c037a15c60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
extern crate zombot;
extern crate time;
use time::{PreciseTime, Duration};
use zombot::*;
const STATE_PATH: &str = "tests/state0.json";
// there are assertions in the game engine, run when it's in debug mode
#[test]
fn it_does_a_normal_turn_successfully() {
let start_time = PreciseTime::now();
let state = match input::json::read_bitwise_state_from_file(STATE_PATH) {
Ok(ok) => ok,
Err(error) => panic!("Error while parsing JSON file: {}", error)
};
let max_time = Duration::milliseconds(200);
strategy::monte_carlo::choose_move(&state, start_time, max_time);
assert!(start_time.to(PreciseTime::now()) < max_time + Duration::milliseconds(50))
}
#[test]
fn it_does_a_normal_tree_serach_turn_successfully() {
let start_time = PreciseTime::now();
let state = match input::json::read_bitwise_state_from_file(STATE_PATH) {
Ok(ok) => ok,
Err(error) => panic!("Error while parsing JSON file: {}", error)
};
let max_time = Duration::milliseconds(200);
strategy::monte_carlo_tree::choose_move(&state, start_time, max_time);
assert!(start_time.to(PreciseTime::now()) < max_time + Duration::milliseconds(50))
}
|