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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#![feature(test)]
use std::fmt;
extern crate test;
extern crate rand;
extern crate rayon;
extern crate clap;
extern crate cpuprofiler;
pub mod game;
pub mod strategies;
pub mod runner;
#[allow(dead_code)]
pub fn display<T: fmt::Display>(x: &T) {
println!("{}", x);
}
#[allow(dead_code)]
pub fn debug<T: fmt::Debug>(x: &T) {
println!("{:?}", x);
}
#[cfg(test)]
mod tests {
use super::*;
use super::strategies::*;
use super::strategies::negamax::*;
use super::game::*;
use super::game::connectfour::*;
use test::Bencher;
#[test]
fn it_works() {
assert_eq!(4, 2 + 2);
}
#[bench]
fn bench_negamax(b: &mut Bencher) {
b.iter(|| {
let mut strategy = Negamax::create(NegamaxParams {
max_depth: 3,
trials: 5,
});
strategy.decide(&ConnectFour::new(&Color::R));
});
}
}