forked from ccase/Cowboys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTieGuy.java
30 lines (24 loc) · 1.05 KB
/
TieGuy.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
public class TieGuy extends Shooter {
public String play(String mine, String other){
if(mine.equals("")){ return "R"; } //Always reload the first move
char myLastMove = mine.charAt(mine.length() - 1);
char hisLastMove = other.charAt(mine.length() - 1);
int myRCount = mine.length() - mine.replace("R", "").length();
int hisRCount = other.length() - other.replace("R", "").length();
int mySCount = mine.length() - mine.replace("S", "").length();
int hisSCount = other.length() - other.replace("S", "").length();
int myBullets = myRCount - mySCount;
int hisBullets = hisRCount - hisSCount;
if (myBullets < 0) {myBullets = 0;}
if (hisBullets < 0) {hisBullets = 0;}
int rounds = mine.length();
if (rounds > 3) {
if (mine.substring(mine.length()-3).equals("BBB") &&
other.substring(other.length()-3).equals("BBB")) {return "R";}
}
if (myBullets > 5) {return "S";}
else if (hisBullets == 0) {return "R";}
else if (hisBullets < 5 && myBullets > 0) {return "B";}
else {return "R";}
}
}