Skip to content

Commit 3e96b6d

Browse files
author
Ian Gonzalez Hermosillo
committed
fix initial paint amounts, restore examplefuncsplayer
1 parent 444b931 commit 3e96b6d

File tree

3 files changed

+11
-44
lines changed

3 files changed

+11
-44
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ public class GameConstants {
7676
/** Paint capacity for mopper robots */
7777
public static final int PAINT_CAPACITY_MOPPER = 100;
7878

79-
/** The amount of a paint a paint tower starts with. */
80-
public static final int INITIAL_PAINT_TOWER_PAINT = 500;
81-
8279
/** The amount of money each team starts with. */
8380
public static final int INITIAL_TEAM_MONEY = 1000;
8481

@@ -104,6 +101,12 @@ public class GameConstants {
104101
/** The number of defense towers a player starts with */
105102
public static final int NUMBER_INITIAL_DEFENSE_TOWERS = 0;
106103

104+
/** The amount of a paint a paint tower starts with. */
105+
public static final int INITIAL_PAINT_TOWER_PAINT = 500;
106+
107+
/** The percentage of a robot's paint capacity that is full when first built. */
108+
public static final int INITIAL_ROBOT_PAINT_PERCENTAGE = 50;
109+
107110
/** The width and height of the patterns that robots can draw */
108111
public static final int PATTERN_SIZE = 5;
109112

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,10 @@ public int spawnRobot(int ID, UnitType type, MapLocation location, Team team){
941941
if (type.isTowerType()){
942942
this.teamInfo.addTowers(1, team);
943943
}
944-
robot.addPaint(type.paintCost); //TODO: initial paint amounts
944+
if (type == UnitType.LEVEL_ONE_PAINT_TOWER)
945+
robot.addPaint(GameConstants.INITIAL_PAINT_TOWER_PAINT);
946+
else if (type.isRobotType())
947+
robot.addPaint((int) Math.round(type.paintCapacity * GameConstants.INITIAL_ROBOT_PAINT_PERCENTAGE / 100.0));
945948
return ID;
946949
}
947950

example-bots/src/main/examplefuncsplayer/RobotPlayer.java

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
* is created!
2222
*/
2323
public class RobotPlayer {
24-
private record ImportantGameObservations(int numNearbyAllyRobots, int numNearbyEnemyRobots) {}
25-
2624
/**
2725
* We will use this variable to count the number of turns this robot has been alive.
2826
* You can use static variables like this to save any information you want. Keep in mind that even though
@@ -61,7 +59,7 @@ private record ImportantGameObservations(int numNearbyAllyRobots, int numNearbyE
6159
public static void run(RobotController rc) throws GameActionException {
6260
// Hello world! Standard output is very useful for debugging.
6361
// Everything you say here will be directly viewable in your terminal when you run a match!
64-
//System.out.println("I'm alive");
62+
System.out.println("I'm alive");
6563

6664
// You can also use indicators to save debug notes in replays.
6765
rc.setIndicatorString("Hello world!");
@@ -79,43 +77,6 @@ public static void run(RobotController rc) throws GameActionException {
7977
// different types. Here, we separate the control depending on the UnitType, so we can
8078
// use different strategies on different robots. If you wish, you are free to rewrite
8179
// this into a different control structure!
82-
83-
// Check that various Java features haven't broken
84-
UnitType enumValue = UnitType.SOLDIER;
85-
boolean canAttack = enumValue.isTowerType();
86-
Map<UnitType, Integer> enumMap = new EnumMap<>(UnitType.class);
87-
enumMap.put(UnitType.SOLDIER, 42);
88-
Map<Integer, Integer> hashMap = new HashMap<>();
89-
hashMap.put(123, 456);
90-
PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
91-
priorityQueue.add(4);
92-
priorityQueue.add(7);
93-
priorityQueue.add(2);
94-
int[] intArr = new int[]{3, 3, 5, 8, 5, 3, 4, 6, 8, 5, 7, 4, 3, 7, 6, 4, 3};
95-
Arrays.sort(intArr);
96-
Integer[] objArr = new Integer[]{3, 3, 5, 8, 5, 3, 4, 6, 8, 5, 7, 4, 3, 7, 6, 4, 3};
97-
Arrays.sort(objArr);
98-
Integer[] data = new Integer[]{1, 2, 3, 4, 5};
99-
List<Integer> dataList = Arrays.asList(data);
100-
Stream<Integer> dataStream = dataList.stream();
101-
Stream<Integer> evenDataStream = dataStream.filter(x -> x % 2 == 0);
102-
//Object[] evenData = evenDataStream.toArray();
103-
// This seems to fail, because jdk.internal.misc.SharedSecrets hardcodes class names as strings
104-
// See https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/jdk/internal/access/SharedSecrets.java#L101
105-
// TODO: these strings probably need to be sanitized on a case-by-case basis
106-
List<Integer> listData = evenDataStream.toList();
107-
System.out.println("DATA " + listData);
108-
// Let's use some features from Java 9+
109-
// var was introduced with Java 10, and record types with Java 16
110-
var numNearbyAllies = rc.senseNearbyRobots(-1, rc.getTeam()).length;
111-
var numNearbyEnemies = rc.senseNearbyRobots(-1, rc.getTeam().opponent()).length;
112-
var observations = new ImportantGameObservations(numNearbyAllies, numNearbyEnemies);
113-
if (observations.numNearbyAllyRobots() > observations.numNearbyEnemyRobots()) {
114-
System.out.println("I have a good feeling about this!");
115-
} else {
116-
System.out.println("I have a baaaaad feeling about this!");
117-
}
118-
11980
switch (rc.getType()){
12081
case SOLDIER: runSoldier(rc); break;
12182
case MOPPER: runMopper(rc); break;

0 commit comments

Comments
 (0)