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
58
use crate::constants::*;
use crate::square::*;
use crate::state::*;
pub struct LinearGame {
pub states: Vec<State>,
pub state_ptr: usize,
}
impl LinearGame {
pub fn new() -> LinearGame {
LinearGame {
states: vec![State::new(); MAX_STATES],
state_ptr: 0,
}
}
pub fn current(&mut self) -> &mut State {
&mut self.states[self.state_ptr]
}
pub fn pretty_print_string(&mut self) -> String {
self.current().pretty_print_string()
}
pub fn print(&mut self) {
println!("{}", self.pretty_print_string())
}
pub fn init(&mut self, variant: Variant) {
self.state_ptr = 0;
self.current().init(variant);
}
pub fn push(&mut self, mv: Move) {
self.current().make_move(mv);
}
pub fn push_by_index(&mut self, index: usize) -> bool {
if index < self.current().move_buff.len() {
let mv = self.current().move_buff[index].mv;
self.push(mv);
return true;
}
false
}
}