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
use crate::constants::*;
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);
}
}