-
Notifications
You must be signed in to change notification settings - Fork 0
/
OthelloTree.java
59 lines (46 loc) · 1.36 KB
/
OthelloTree.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
50
51
52
53
54
55
56
57
58
59
package Participants.JupilleFrank;
import java.util.ArrayList;
/**
* Tree structure used to contain all possibles next plays since the root node.
*
* @author Dany Jupille
* @author Etienne Frank
* @version 1.0
*/
public class OthelloTree {
/** Node's childrens */
private ArrayList<OthelloTree> childrendsOthelloTrees;
/** Used by the alpha-beta pruning */
public int alphabetaPoints;
/** Root node */
private OthelloGrid rootOthelloGrid;
/**
* @param rootOthelloGrid Grid to be wrapped into the root node
* @param playerID Used to get the player's points in this grid
*/
public OthelloTree(OthelloGrid rootOthelloGrid, int playerID) {
this.rootOthelloGrid = rootOthelloGrid;
alphabetaPoints = rootOthelloGrid.getPlayerPoints(playerID);
childrendsOthelloTrees = new ArrayList<OthelloTree>();
}
public OthelloGrid getRoot() {
return rootOthelloGrid;
}
public void setRoot(OthelloGrid rootOthelloGrid) {
this.rootOthelloGrid = rootOthelloGrid;
}
public ArrayList<OthelloTree> getChildrens() {
return childrendsOthelloTrees;
}
public void addChildren(OthelloTree childrenOthelloTree) {
childrendsOthelloTrees.add(childrenOthelloTree);
}
/**
* Check if this node is a leaf.
*
* @return <b>true</b> if it is a leaf, <b>false</b> otherwise
*/
public boolean isTerminal() {
return childrendsOthelloTrees.isEmpty();
}
}