-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTeamTitForTatRecovery.java
56 lines (43 loc) · 1.93 KB
/
TeamTitForTatRecovery.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
public class TeamTitForTatRecovery extends Player {
boolean weHaveWonAGame; // Until we win a game in a series, we play as a Realist. Then we play as Cooperative.
public byte[] bestMoveBytesRealist, scoreWhiteBytesRealist, scoreBlackBytesRealist;
public byte[] bestMoveBytesCooperative, scoreWhiteBytesCooperative, scoreBlackBytesCooperative;
public int BETRAYAL_DELTA = 1;
public int COOPERATION_DELTA = 1;
public TeamTitForTatRecovery(int maxNumMoves) {
TeamRational teamRationalRealist = TeamRational.createRealist(maxNumMoves);
TeamRational teamRationalCooperative = TeamRational.createCooperative(maxNumMoves);
bestMoveBytesRealist = teamRationalRealist.bestMoveBytes;
scoreWhiteBytesRealist = teamRationalRealist.scoreWhiteBytes;
scoreBlackBytesRealist = teamRationalRealist.scoreBlackBytes;
bestMoveBytesCooperative = teamRationalCooperative.bestMoveBytes;
scoreWhiteBytesCooperative = teamRationalCooperative.scoreWhiteBytes;
scoreBlackBytesCooperative = teamRationalCooperative.scoreBlackBytes;
}
public void prepareForSeries() {
weHaveWonAGame=false;
}
public void prepareForMatch() {
}
public void receiveMatchOutcome(int matchOutcome) {
int myMatchPayoff = outcomeToPayoff(matchOutcome); //Convert to a more reasonable format...
if( myMatchPayoff == 3) {
weHaveWonAGame=true;
}
}
public MoveDescription chooseMove() {
BoardPosition boardPosition = toBoardPosition();
if (!weHaveWonAGame) {
TeamRational.Node nodeRealist = new TeamRational.Node(
bestMoveBytesRealist[boardPosition.toInt()],
scoreWhiteBytesRealist[boardPosition.toInt()],
scoreBlackBytesRealist[boardPosition.toInt()]);
return nodeRealist.bestMove;
}
TeamRational.Node nodeCooperative = new TeamRational.Node(
bestMoveBytesCooperative[boardPosition.toInt()],
scoreWhiteBytesCooperative[boardPosition.toInt()],
scoreBlackBytesCooperative[boardPosition.toInt()]);
return nodeCooperative.bestMove;
}
}