-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.java
49 lines (36 loc) · 849 Bytes
/
Game.java
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
import java.util.*;
import java.io.*;
public class Game
{
private List<State> states;
private State current;
private boolean isFirst;
public Game() {
this.states = new ArrayList<State>();
this.current = new State();
this.isFirst = false;
}
public void setIsFirst(boolean isFirst) {
this.isFirst = isFirst;
}
public boolean pushOpponentMove(int row) {
return this.current.pushMove(row, false);
}
public boolean pushMyMove(int row) {
return this.current.pushMove(row, true);
}
public State aiMove() {
if(current.isGameEnding()) {
return current;
}
State state = Intelligence.move(current, Intelligence.DEPTH);
this.pushOpponentMove(state.getMainMove());
return state;
}
public State getCurrentState() {
return this.current;
}
public String toString() {
return this.current.toString();
}
}