Skip to content

Commit b156bc9

Browse files
committed
add randomness
1 parent e2c53bd commit b156bc9

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

engine/src/main/battlecode/world/InternalRobot.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public class InternalRobot implements Comparable<InternalRobot> {
5656
// the number of messages this robot/tower has sent this turn
5757
private int sentMessagesCount;
5858

59+
public static Random rand = new Random(1092);
60+
5961
private int chirality;
6062
private int sleepTimeRemaining;
6163

@@ -1179,11 +1181,15 @@ else if (this.type == UnitType.CAT) {
11791181
if (this.catTurnsStuck >= 4){
11801182
// cat has been unable to move or dig or attack for 4+ turns
11811183
// start turning and then trying to dig or attack again
1184+
Direction[] directions = Direction.values();
1185+
Direction random = directions[rand.nextInt(directions.length)];
1186+
11821187
if (this.controller.canTurn()) {
1183-
try {
1184-
if (this.chirality == 0) this.controller.turn(this.dir.rotateRight());
1185-
else this.controller.turn(this.dir.rotateLeft());
1186-
} catch (GameActionException e) {}
1188+
try{
1189+
this.controller.turn(random);
1190+
}
1191+
catch (GameActionException e){}
1192+
11871193
}
11881194
}
11891195
else{

0 commit comments

Comments
 (0)