All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
historyState.cc
Go to the documentation of this file.
1 /* historyState.cc
2  */
4 
6  : dirty(false)
7 {
8  assert(current.isConsistent());
9  assert(initial_state.isConsistent());
10 }
11 
13  : initial_state(initial), current(initial), dirty(false)
14 {
15  assert(current.isConsistent());
16  assert(initial_state.isConsistent());
17 }
18 
20 {
21 }
22 
24 {
25  initial_state = current = NumEffectState(initial);
26  moves.clear();
27  dirty = false;
28 }
29 
31 {
32  if (dirty)
33  update();
34  moves.push_back(move);
35  current.makeMove(move);
36 }
37 
39 {
40  dirty = true;
41  moves.pop_back();
42 }
43 
45 {
46  makeMove(Move::PASS(state().turn()));
47 }
48 
50 {
51  assert(! moves.empty() && moves.back().isPass());
52  if (! dirty) {
53  moves.pop_back();
54  current.changeTurn();
55  return;
56  }
57  unmakeMove();
58 }
59 
61 {
62  current = initial_state;
63  for (size_t i=0; i<moves.size(); ++i)
64  current.makeMove(moves[i]);
65  dirty = false;
66 }
67 
68 // ;;; Local Variables:
69 // ;;; mode:c++
70 // ;;; c-basic-offset:2
71 // ;;; End: