@@ -69,7 +69,8 @@ public class InternalRobot implements Comparable<InternalRobot> {
6969
7070 private int currentWaypoint ;
7171 private CatStateType catState ;
72- private MapLocation [] catWaypoints ;
72+ private MapLocation [] rawCatWaypoints ;
73+ private MapLocation [] adjustedCatWaypoints ;
7374 private MapLocation catTargetLoc ;
7475 private int catTurns ;
7576 private RobotInfo catTarget ;
@@ -126,14 +127,36 @@ public InternalRobot(GameWorld gw, int id, Team team, UnitType type, MapLocation
126127
127128 // set waypoints
128129 int [] waypointIndexLocations = gw .getGameMap ().getCatWaypointsByID (this .ID );
129- catWaypoints = new MapLocation [waypointIndexLocations .length ];
130- for (int i = 0 ; i < waypointIndexLocations .length ; i ++)
131- catWaypoints [i ] = this .gameWorld .indexToLocation (waypointIndexLocations [i ]);
130+ rawCatWaypoints = new MapLocation [waypointIndexLocations .length ];
131+ adjustedCatWaypoints = new MapLocation [waypointIndexLocations .length ];
132+ for (int i = 0 ; i < waypointIndexLocations .length ; i ++){
133+ rawCatWaypoints [i ] = this .gameWorld .indexToLocation (waypointIndexLocations [i ]);
134+ if (this .chirality == 0 ){
135+ adjustedCatWaypoints [i ] = rawCatWaypoints [i ];
136+ }
137+ else {
138+ MapSymmetry symmetry = this .gameWorld .getGameMap ().getSymmetry ();
139+ switch (symmetry ) {
140+ case VERTICAL :
141+ adjustedCatWaypoints [i ] = rawCatWaypoints [i ].add (Direction .EAST .opposite ());
142+ break ;
143+ case HORIZONTAL :
144+ adjustedCatWaypoints [i ] = rawCatWaypoints [i ].add (Direction .NORTH .opposite ());
145+ break ;
146+ case ROTATIONAL :
147+ adjustedCatWaypoints [i ] = rawCatWaypoints [i ].add (Direction .NORTHEAST .opposite ());
148+ break ;
149+ default :
150+ throw new RuntimeException ("Invalid symmetry" );
151+ }
152+ }
153+ }
132154
133- this .catTargetLoc = this .catWaypoints [0 ];
155+ this .catTargetLoc = this .adjustedCatWaypoints [0 ];
134156
135157 } else {
136- this .catWaypoints = new MapLocation [0 ];
158+ this .rawCatWaypoints = new MapLocation [0 ];
159+ this .adjustedCatWaypoints = new MapLocation [0 ];
137160 this .catTargetLoc = null ;
138161 }
139162
@@ -1114,21 +1137,10 @@ public void processEndOfTurn() {
11141137 switch (this .catState ) {
11151138 case EXPLORE :
11161139
1117- MapLocation waypoint = catWaypoints [currentWaypoint ];
1118-
1119- if (this .location .equals (waypoint )) {
1120- currentWaypoint = (currentWaypoint + 1 ) % catWaypoints .length ;
1121- }
1122-
1123- this .dir = this .location .directionTo (catWaypoints [currentWaypoint ]);
1124-
11251140 // try seeing nearby rats
11261141 Message squeak = getFrontMessage ();
11271142 RobotInfo [] nearbyRobots = this .controller .senseNearbyRobots ();
11281143
1129- // this.gameWorld.getAllRobotsWithinConeRadiusSquared(this.location,
1130- // this.dir, getVisionConeAngle(), getVisionRadiusSquared(), team);
1131-
11321144 boolean ratVisible = false ;
11331145 RobotInfo rat = null ;
11341146
@@ -1148,21 +1160,26 @@ public void processEndOfTurn() {
11481160 this .catTargetLoc = squeak .getSource ();
11491161 this .catState = CatStateType .CHASE ;
11501162 } else {
1151- this .catTargetLoc = waypoint ;
1163+ MapLocation waypoint = adjustedCatWaypoints [currentWaypoint ];
1164+
1165+ if (this .location .equals (waypoint )) {
1166+ currentWaypoint = (currentWaypoint + 1 ) % adjustedCatWaypoints .length ;
1167+ }
1168+ this .catTargetLoc = adjustedCatWaypoints [currentWaypoint ];
11521169 }
11531170
1154- Direction toWaypoint = this .location .directionTo (this .catTargetLoc );
1155- this .dir = this .location .directionTo (this .catTargetLoc );
1171+ this .dir = this .gameWorld .getBfsDir (this .location , this .catTargetLoc );
11561172
1157- if (this .controller .canMove (toWaypoint )) {
1173+ if (this .controller .canMove (this .dir )) {
1174+ System .out .println ("TRYING TO MOVE" );
11581175 try {
1159- this .controller .move (toWaypoint );
1176+ this .controller .move (this . dir );
11601177 } catch (GameActionException e ) {
11611178 }
11621179
11631180 } else {
11641181 for (MapLocation partLoc : this .getAllPartLocations ()) {
1165- MapLocation nextLoc = partLoc .add (toWaypoint );
1182+ MapLocation nextLoc = partLoc .add (this . dir );
11661183
11671184 if (this .controller .canRemoveDirt (nextLoc )) {
11681185 System .out .println ("stuck more here cuz of dirt " + this .gameWorld .currentRound );
@@ -1192,8 +1209,7 @@ public void processEndOfTurn() {
11921209 case CHASE :
11931210 System .out .println ("CAT " + this .ID + "Entering Chase" );
11941211
1195- Direction toTarget = this .location .directionTo (this .catTargetLoc );
1196- this .dir = toTarget ;
1212+ this .dir = this .gameWorld .getBfsDir (this .location , this .catTargetLoc );
11971213
11981214 if (this .location .equals (this .catTargetLoc )) {
11991215 this .catState = CatStateType .SEARCH ;
@@ -1290,7 +1306,7 @@ public void processEndOfTurn() {
12901306
12911307 }
12921308
1293- this .dir = this .location . directionTo ( this .catTargetLoc );
1309+ this .dir = this .gameWorld . getBfsDir ( this . location , this .catTargetLoc );
12941310
12951311 // pounce towards target if possible
12961312 pounceTraj = canPounce (this .catTargetLoc );
0 commit comments