@@ -9,6 +9,8 @@ public class Soldier implements GenericRobotContoller {
9
9
boolean SRP_built = false ;
10
10
int cant_find_tower_for = 0 ;
11
11
boolean [][] SRP_pattern ;
12
+ boolean [][] MoneyPattern ;
13
+ boolean [][] PaintPattern ;
12
14
RobotController rc ;
13
15
Pathing pathing_engine ;
14
16
boolean buildPaintTowerNext = false ;
@@ -19,6 +21,8 @@ public Soldier(RobotController handler) throws GameActionException {
19
21
rc = handler ;
20
22
pathing_engine = new Pathing (handler );
21
23
SRP_pattern = rc .getResourcePattern ();
24
+ MoneyPattern = rc .getTowerPattern (UnitType .LEVEL_ONE_MONEY_TOWER );
25
+ PaintPattern = rc .getTowerPattern (UnitType .LEVEL_ONE_PAINT_TOWER );
22
26
}
23
27
24
28
public void run () throws GameActionException {
@@ -61,7 +65,7 @@ public void run() throws GameActionException {
61
65
private boolean buildRuins () throws GameActionException {
62
66
isBuildingRuin = false ;
63
67
// Sense information about all visible nearby tiles.
64
- MapInfo [] nearbyTiles = rc .senseNearbyMapInfos ();
68
+ MapInfo [] nearbyTiles = rc .senseNearbyMapInfos (- 1 );
65
69
// Search for a nearby ruin to complete.
66
70
MapInfo curRuin = null ;
67
71
int curDist = 100000000 ;
@@ -76,41 +80,43 @@ private boolean buildRuins() throws GameActionException {
76
80
}
77
81
}
78
82
79
-
80
83
if (curRuin != null ) {
81
84
MapLocation targetLoc = curRuin .getMapLocation ();
82
85
Direction dir = currentLocation .directionTo (targetLoc );
83
86
if (rc .canMove (dir ))
84
87
rc .move (dir );
85
88
// Mark the pattern we need to draw to build a tower here if we haven't already.
86
89
// Decide tower type based on logic
87
- UnitType towerToBuild ;
90
+ UnitType towerToBuild = UnitType .LEVEL_ONE_MONEY_TOWER ;
91
+ boolean [][] PatternToUse = MoneyPattern ;
88
92
89
93
// If chips exceed 3000, always build paint towers
90
- if (rc .getChips () > 3000 ) {
94
+ if (rc .getChips () > rc . getMapWidth ()* rc . getMapHeight ()* 2.3 ) {
91
95
towerToBuild = UnitType .LEVEL_ONE_PAINT_TOWER ;
92
- } else {
93
- // Alternate between paint and money towers
94
- if (buildPaintTowerNext ) {
95
- towerToBuild = UnitType .LEVEL_ONE_PAINT_TOWER ;
96
- } else {
97
- towerToBuild = UnitType .LEVEL_ONE_MONEY_TOWER ;
98
- }
99
- buildPaintTowerNext = !buildPaintTowerNext ; // Toggle for the next tower
100
- }
96
+ PatternToUse = PaintPattern ;
97
+ }
101
98
102
- MapLocation shouldBeMarked = curRuin .getMapLocation ().subtract (dir );
103
- if (rc .senseMapInfo (shouldBeMarked ).getMark () == PaintType .EMPTY && rc .canMarkTowerPattern (towerToBuild , targetLoc )) {
104
- rc .markTowerPattern (towerToBuild , targetLoc );
105
- System .out .println ("Trying to build a tower at " + targetLoc );
106
- }
107
- // Fill in any spots in the pattern with the appropriate paint.
108
- for (MapInfo patternTile : rc .senseNearbyMapInfos (targetLoc , 8 )) {
109
- if (patternTile .getMark () != patternTile .getPaint ()) {
110
- if (patternTile .getMark () != PaintType .EMPTY ) {
111
- boolean useSecondaryColor = patternTile .getMark () == PaintType .ALLY_SECONDARY ;
112
- if (rc .canAttack (patternTile .getMapLocation ()))
113
- rc .attack (patternTile .getMapLocation (), useSecondaryColor );
99
+ for (MapInfo mapInfo : nearbyTiles ) {
100
+ MapLocation tileLocation = mapInfo .getMapLocation ();
101
+ if (tileLocation == targetLoc ) {
102
+ continue ;
103
+ }
104
+ if (!rc .canAttack (tileLocation )) {
105
+ continue ;
106
+ }
107
+ MapLocation relative_loc = tileLocation .translate (-targetLoc .x , -targetLoc .y );
108
+ boolean x_in = -2 <= relative_loc .x && relative_loc .x <= 2 ;
109
+ boolean y_in = -2 <= relative_loc .y && relative_loc .y <= 2 ;
110
+ if (x_in && y_in ) {
111
+ rc .setIndicatorDot (tileLocation , 12 , 111 , 250 );
112
+ boolean color = PatternToUse [relative_loc .x + 2 ][-(relative_loc .y - 2 )];
113
+ PaintType correct_paint = PaintType .ALLY_PRIMARY ;
114
+ if (color ) {
115
+ correct_paint = PaintType .ALLY_SECONDARY ;
116
+ }
117
+ if (mapInfo .getPaint () != correct_paint ) {
118
+ rc .attack (mapInfo .getMapLocation (), color );
119
+ break ;
114
120
}
115
121
}
116
122
}
0 commit comments