Skip to content

Commit 5703f52

Browse files
author
Ian Gonzalez Hermosillo
committed
Merge branch 'engine-day-2'
2 parents 1376c48 + fad2265 commit 5703f52

File tree

6 files changed

+66
-14
lines changed

6 files changed

+66
-14
lines changed

engine/src/main/battlecode/common/GameConstants.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ public class GameConstants {
120120
public static final int EXTRA_RESOURCES_FROM_PATTERN = 3;
121121

122122
/** The extra damage all ally towers get for each level 1 defense tower */
123-
public static final int EXTRA_DAMAGE_FROM_DEFENSE_TOWER = 10;
123+
public static final int EXTRA_DAMAGE_FROM_DEFENSE_TOWER = 5;
124124

125125
/** The increase in extra damage for ally towers for upgrading a defense tower */
126-
public static final int EXTRA_TOWER_DAMAGE_LEVEL_INCREASE = 5;
126+
public static final int EXTRA_TOWER_DAMAGE_LEVEL_INCREASE = 2;
127127

128128
/** The percent of the defense tower damage buff that is applied to AoE attacks */
129-
public static final int DEFENSE_ATTACK_BUFF_AOE_EFFECTIVENESS = 50;
129+
public static final int DEFENSE_ATTACK_BUFF_AOE_EFFECTIVENESS = 0;
130130

131131
/** Maximum amount of turns a robot can go at 0 paint without dying */
132132
public static final int MAX_TURNS_WITHOUT_PAINT = 10;

engine/src/main/battlecode/common/PaintType.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ public boolean isAlly() {
1111
return this == ALLY_PRIMARY || this == ALLY_SECONDARY;
1212
}
1313

14+
public boolean isEnemy(){
15+
return this == ENEMY_PRIMARY || this == ENEMY_SECONDARY;
16+
}
17+
1418
public boolean isSecondary() {
1519
return this == ALLY_SECONDARY || this == ENEMY_SECONDARY;
1620
}

engine/src/main/battlecode/common/RobotController.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,16 @@ public interface RobotController {
685685
// ***** ATTACK / HEAL ********
686686
// ****************************
687687

688+
/**
689+
* Tests whether this robot can paint the given location.
690+
*
691+
* @param loc target location to paint
692+
* @return true if rc.attack(loc) will paint the given location
693+
*
694+
* @battlecode.doc.costlymethod
695+
*/
696+
boolean canPaint(MapLocation loc);
697+
688698
/**
689699
* Tests whether this robot can attack the given location. Types of
690700
* attacks for specific units determine whether or not towers, other
@@ -866,6 +876,7 @@ public interface RobotController {
866876
* @param red the red component of the dot's color
867877
* @param green the green component of the dot's color
868878
* @param blue the blue component of the dot's color
879+
* @throws GameActionException if the location is off the map
869880
*
870881
* @battlecode.doc.costlymethod
871882
*/
@@ -879,6 +890,7 @@ public interface RobotController {
879890
* @param red the red component of the line's color
880891
* @param green the green component of the line's color
881892
* @param blue the blue component of the line's color
893+
* @throws GameActionException if any location is off the map
882894
*
883895
* @battlecode.doc.costlymethod
884896
*/

engine/src/main/battlecode/common/UnitType.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
package battlecode.common;
22

33
public enum UnitType {
4-
SOLDIER(200, 250, 5, 250, -1, 200, 10, 9, 20, -1, 0, 0),
5-
SPLASHER(300, 400, 50, 150, -1, 300, 50, 8, -1, 50, 0, 0),
4+
SOLDIER(200, 250, 5, 250, -1, 200, 10, 9, 50, -1, 0, 0),
5+
SPLASHER(300, 400, 50, 150, -1, 300, 50, 4, -1, 100, 0, 0),
66
MOPPER(100, 300, 0, 50, -1, 100, 30, 2, -1, -1, 0, 0),
77

8-
LEVEL_ONE_PAINT_TOWER(0, 100, 0, 1000, 1, 1000, 10, 9, 20, 10, 5, 0),
9-
LEVEL_TWO_PAINT_TOWER(0, 250, 0, 1500, 2, 1000, 10, 9, 20, 10, 10, 0),
10-
LEVEL_THREE_PAINT_TOWER(0, 500, 0, 2000, 3, 1000, 10, 9, 20, 10, 15, 0),
8+
LEVEL_ONE_PAINT_TOWER(0, 1000, 0, 1000, 1, 1000, 10, 9, 20, 10, 5, 0),
9+
LEVEL_TWO_PAINT_TOWER(0, 2500, 0, 1500, 2, 1000, 10, 9, 20, 10, 10, 0),
10+
LEVEL_THREE_PAINT_TOWER(0, 5000, 0, 2000, 3, 1000, 10, 9, 20, 10, 15, 0),
1111

12-
LEVEL_ONE_MONEY_TOWER(0, 100, 0, 1000, 1, 1000, 10, 9, 20, 10, 0, 10),
13-
LEVEL_TWO_MONEY_TOWER(0, 250, 0, 1500, 2, 1000, 10, 9, 20, 10, 0, 15),
14-
LEVEL_THREE_MONEY_TOWER(0, 500, 0, 2000, 3, 1000, 10, 9, 20, 10, 0, 20),
12+
LEVEL_ONE_MONEY_TOWER(0, 1000, 0, 1000, 1, 1000, 10, 9, 20, 10, 0, 20),
13+
LEVEL_TWO_MONEY_TOWER(0, 2500, 0, 1500, 2, 1000, 10, 9, 20, 10, 0, 30),
14+
LEVEL_THREE_MONEY_TOWER(0, 5000, 0, 2000, 3, 1000, 10, 9, 20, 10, 0, 40),
1515

16-
LEVEL_ONE_DEFENSE_TOWER(0, 100, 0, 2500, 1, 1000, 10, 20, 60, 30, 0, 0),
17-
LEVEL_TWO_DEFENSE_TOWER(0, 250, 0, 3000, 2, 1000, 10, 20, 65, 35, 0, 0),
18-
LEVEL_THREE_DEFENSE_TOWER(0, 500, 0, 3500, 3, 1000, 10, 20, 70, 40, 0, 0);
16+
LEVEL_ONE_DEFENSE_TOWER(0, 1000, 0, 2000, 1, 1000, 10, 16, 40, 20, 0, 0),
17+
LEVEL_TWO_DEFENSE_TOWER(0, 2500, 0, 2500, 2, 1000, 10, 16, 50, 25, 0, 0),
18+
LEVEL_THREE_DEFENSE_TOWER(0, 5000, 0, 3000, 3, 1000, 10, 16, 60, 30, 0, 0);
1919

2020

2121
// the paint cost to build the unit
@@ -78,6 +78,18 @@ public UnitType getNextLevel(){
7878
}
7979
}
8080

81+
public UnitType getBaseType(){
82+
switch (this){
83+
case LEVEL_TWO_DEFENSE_TOWER: return LEVEL_ONE_DEFENSE_TOWER;
84+
case LEVEL_THREE_DEFENSE_TOWER: return LEVEL_ONE_DEFENSE_TOWER;
85+
case LEVEL_TWO_PAINT_TOWER: return LEVEL_ONE_PAINT_TOWER;
86+
case LEVEL_THREE_PAINT_TOWER: return LEVEL_ONE_PAINT_TOWER;
87+
case LEVEL_TWO_MONEY_TOWER: return LEVEL_ONE_MONEY_TOWER;
88+
case LEVEL_THREE_MONEY_TOWER: return LEVEL_ONE_MONEY_TOWER;
89+
default: return this;
90+
}
91+
}
92+
8193
UnitType(int paintCost, int moneyCost, int attackCost, int health, int level, int paintCapacity, int actionCooldown, int actionRadiusSquared, int attackStrength, int aoeAttackStrength, int paintPerTurn, int moneyPerTurn) {
8294
this.paintCost = paintCost;
8395
this.moneyCost = moneyCost;

engine/src/main/battlecode/instrumenter/bytecode/resources/MethodCosts.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ battlecode/common/RobotController/getResourcePattern 2 tru
2626
battlecode/common/RobotController/getTowerPattern 2 true
2727
battlecode/common/RobotController/adjacentLocation 1 true
2828
battlecode/common/RobotController/attack 0 true
29+
battlecode/common/RobotController/canPaint 10 true
2930
battlecode/common/RobotController/canAttack 10 true
3031
battlecode/common/RobotController/canMopSwing 10 true
3132
battlecode/common/RobotController/mopSwing 0 true
@@ -112,11 +113,13 @@ battlecode/common/Message/getBytes 3 fal
112113
battlecode/common/Message/toString 5 false
113114
battlecode/common/Message/copy 5 false
114115
battlecode/common/PaintType/isAlly 2 false
116+
battlecode/common/PaintType/isEnemy 2 false
115117
battlecode/common/PaintType/isSecondary 2 false
116118
battlecode/common/UnitType/isRobotType 3 false
117119
battlecode/common/UnitType/isTowerType 3 false
118120
battlecode/common/UnitType/canUpgradeType 3 false
119121
battlecode/common/UnitType/getNextLevel 3 false
122+
battlecode/common/UnitType/getBaseType 3 false
120123
java/lang/Math/IEEEremainder 1 false
121124
java/lang/Math/abs 1 false
122125
java/lang/Math/acos 1 false

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,27 @@ public void completeResourcePattern(MapLocation loc) throws GameActionException
837837
// ****** ATTACK / HEAL ********
838838
// *****************************
839839

840+
@Override
841+
public boolean canPaint(MapLocation loc){
842+
assertNotNull(loc);
843+
if (!onTheMap(loc))
844+
return false;
845+
// towers and moppers cannot paint tiles
846+
if (getType().isTowerType() || getType() == UnitType.MOPPER){
847+
return false;
848+
}
849+
if (getType() == UnitType.SOLDIER){
850+
if (loc.distanceSquaredTo(this.robot.getLocation()) > UnitType.SOLDIER.actionRadiusSquared)
851+
return false;
852+
return this.gameWorld.isPaintable(loc) && this.gameWorld.teamFromPaint(this.gameWorld.getPaint(loc)) != getTeam().opponent();
853+
}
854+
else{
855+
if (loc.distanceSquaredTo(this.robot.getLocation()) > UnitType.SPLASHER.actionRadiusSquared)
856+
return false;
857+
return this.gameWorld.isPaintable(loc);
858+
}
859+
}
860+
840861
private void assertCanAttackSoldier(MapLocation loc) throws GameActionException {
841862
assertIsActionReady();
842863
assertCanActLocation(loc, UnitType.SOLDIER.actionRadiusSquared);

0 commit comments

Comments
 (0)