-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameBOTS.java
More file actions
38 lines (33 loc) · 1.05 KB
/
Copy pathGameBOTS.java
File metadata and controls
38 lines (33 loc) · 1.05 KB
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
package game_theory_bimatrix;
public class GameBOTS implements Game {
static final int LW = 0, WL = 1;
static String[] ACTIONS = {"Lethal Weapon", "Wondrous Love"};
/**
* @param myAction action played by hero
* @param otherAction action played by villain
* @param player what is player number for player that played myAction * @return utility for the player of interest
*/
public int utility(int myAction, int otherAction, int player) {
if (myAction != otherAction)
return 0;
if (player == 1) {
if (myAction == 0)
return 2;
else return 1;
} else {
if (myAction == 1)
return 2;
else return 1; }
}
/**
* Provide a description of an action
*
* @param actionIndex the integer representing the action * @return the description of the action
*/
public String actionAsString(int actionIndex) {
return ACTIONS[actionIndex];
}
public String getType() {
return "BOTS";
}
}