-
Notifications
You must be signed in to change notification settings - Fork 0
/
ActionNode.java
54 lines (41 loc) · 1.29 KB
/
ActionNode.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
import java.util.List;
import java.util.ArrayList;
public class ActionNode extends SimpleGameNode {
private final List<PlayerAction> actions;
private final List<Double> bets;
public ActionNode(int player) {
super(player, true);
this.actions = new ArrayList<PlayerAction>();
this.bets = new ArrayList<Double>();
}
public void addChild(GameNode n, PlayerAction action, Double bet) {
super.addChild(n);
actions.add(action);
bets.add(bet);
}
public void addChild(GameNode n) {
throw new UnsupportedOperationException("use overloaded addChild()");
}
public void addFoldChild(GameNode n) {
addChild(n, PlayerAction.FOLD, null);
}
public PlayerAction getAction(int i) {
return actions.get(i);
}
public List<Double> getBets() {
return bets;
}
public Double getBet(int i) {
return bets.get(i);
}
public String getChildString(int cindex) {
StringBuilder sb = new StringBuilder();
PlayerAction a = getAction(cindex);
sb.append('[').append(getPlayer()).append(a);
if (a == PlayerAction.BET) {
sb.append('(').append(getBet(cindex)).append(')');
}
sb.append(']');
return sb.toString();
}
}