Skip to content

Commit 9b05f3b

Browse files
authored
Merge pull request #91 from battlecode/master
engine v1.2.2 changes
2 parents 06a138a + bb97539 commit 9b05f3b

15 files changed

Lines changed: 666 additions & 149 deletions

File tree

engine/src/crossplay_python/battlecode26/classes.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,6 @@ def __repr__(self) -> str:
216216
_trap_to_index = {trap: index for index, trap in enumerate(_trap_order)}
217217

218218

219-
class MapInfo:
220-
def __init__(self, location: MapLocation, is_passable: bool, is_wall: bool, is_dirt: bool,
221-
cheese_amount: int, trap: TrapType, has_cheese_mine: bool):
222-
self.location = location
223-
self.is_passable = is_passable
224-
self.is_wall = is_wall
225-
self.is_dirt = is_dirt
226-
self.cheese_amount = cheese_amount
227-
self.trap = trap
228-
self.has_cheese_mine = has_cheese_mine
229-
230-
231219
class RobotInfo:
232220
def __init__(self, id: int, team: Team, unit_type: UnitType, health: int,
233221
location: MapLocation, direction: Direction,
@@ -243,6 +231,19 @@ def __init__(self, id: int, team: Team, unit_type: UnitType, health: int,
243231
self.carrying_robot = carrying_robot
244232

245233

234+
class MapInfo:
235+
def __init__(self, location: MapLocation, is_passable: bool, flying_robot: RobotInfo, is_wall: bool,
236+
is_dirt: bool, cheese_amount: int, trap: TrapType, has_cheese_mine: bool):
237+
self.location = location
238+
self.is_passable = is_passable
239+
self.flying_robot = flying_robot
240+
self.is_wall = is_wall
241+
self.is_dirt = is_dirt
242+
self.cheese_amount = cheese_amount
243+
self.trap = trap
244+
self.has_cheese_mine = has_cheese_mine
245+
246+
246247
class Message:
247248
def __init__(self, message_bytes: int, sender_id: int, round: int, source_loc: MapLocation):
248249
self.bytes = message_bytes

engine/src/crossplay_python/battlecode26/crossplay.py

Lines changed: 107 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -23,109 +23,112 @@ def __init__(self, message):
2323
class CrossPlayMethod(Enum):
2424
INVALID = 0
2525
END_TURN = 1
26-
RC_GET_ROUND_NUM = 2
27-
RC_GET_MAP_WIDTH = 3
28-
RC_GET_MAP_HEIGHT = 4
29-
RC_IS_COOPERATION = 5
30-
RC_GET_ID = 6
31-
RC_GET_TEAM = 7
32-
RC_GET_LOCATION = 8
33-
RC_GET_ALL_PART_LOCATIONS = 9
34-
RC_GET_DIRECTION = 10
35-
RC_GET_HEALTH = 11
36-
RC_GET_RAW_CHEESE = 12
37-
RC_GET_GLOBAL_CHEESE = 13
38-
RC_GET_ALL_CHEESE = 14
39-
RC_GET_DIRT = 15
40-
RC_GET_TYPE = 16
41-
RC_GET_CARRYING = 17
42-
RC_IS_BEING_THROWN = 18
43-
RC_IS_BEING_CARRIED = 19
44-
RC_ON_THE_MAP = 20
45-
RC_CAN_SENSE_LOCATION = 21
46-
RC_IS_LOCATION_OCCUPIED = 22
47-
RC_CAN_SENSE_ROBOT_AT_LOCATION = 23
48-
RC_SENSE_ROBOT_AT_LOCATION = 24
49-
RC_CAN_SENSE_ROBOT = 25
50-
RC_SENSE_ROBOT = 26
51-
RC_SENSE_NEARBY_ROBOTS = 27
52-
RC_SENSE_NEARBY_ROBOTS__INT = 28
53-
RC_SENSE_NEARBY_ROBOTS__INT_TEAM = 29
54-
RC_SENSE_NEARBY_ROBOTS__LOC_INT_TEAM = 30
55-
RC_SENSE_PASSABILITY = 31
56-
RC_SENSE_MAP_INFO = 32
57-
RC_SENSE_NEARBY_MAP_INFOS = 33
58-
RC_SENSE_NEARBY_MAP_INFOS__INT = 34
59-
RC_SENSE_NEARBY_MAP_INFOS__LOC = 35
60-
RC_SENSE_NEARBY_MAP_INFOS__LOC_INT = 36
61-
RC_ADJACENT_LOCATION = 37
62-
RC_GET_ALL_LOCATIONS_WITHIN_RADIUS_SQUARED = 38
63-
RC_IS_ACTION_READY = 39
64-
RC_GET_ACTION_COOLDOWN_TURNS = 40
65-
RC_IS_MOVEMENT_READY = 41
66-
RC_IS_TURNING_READY = 42
67-
RC_GET_MOVEMENT_COOLDOWN_TURNS = 43
68-
RC_GET_TURNING_COOLDOWN_TURNS = 44
69-
RC_CAN_MOVE_FORWARD = 45
70-
RC_CAN_MOVE = 46
71-
RC_MOVE_FORWARD = 47
72-
RC_MOVE = 48
73-
RC_CAN_TURN = 49
74-
RC_TURN = 50
75-
RC_GET_CURRENT_RAT_COST = 51
76-
RC_CAN_BUILD_RAT = 52
77-
RC_BUILD_RAT = 53
78-
RC_CAN_BECOME_RAT_KING = 54
79-
RC_BECOME_RAT_KING = 55
80-
RC_CAN_PLACE_DIRT = 56
81-
RC_PLACE_DIRT = 57
82-
RC_CAN_REMOVE_DIRT = 58
83-
RC_REMOVE_DIRT = 59
84-
RC_CAN_PLACE_RAT_TRAP = 60
85-
RC_PLACE_RAT_TRAP = 61
86-
RC_CAN_REMOVE_RAT_TRAP = 62
87-
RC_REMOVE_RAT_TRAP = 63
88-
RC_CAN_PLACE_CAT_TRAP = 64
89-
RC_PLACE_CAT_TRAP = 65
90-
RC_CAN_REMOVE_CAT_TRAP = 66
91-
RC_REMOVE_CAT_TRAP = 67
92-
RC_CAN_PICK_UP_CHEESE = 68
93-
RC_PICK_UP_CHEESE = 69
94-
RC_PICK_UP_CHEESE__LOC_INT = 70
95-
RC_CAN_ATTACK = 71
96-
RC_CAN_ATTACK__LOC_INT = 72
97-
RC_ATTACK = 73
98-
RC_ATTACK__LOC_INT = 74
99-
RC_SQUEAK = 75
100-
RC_READ_SQUEAKS = 76
101-
RC_WRITE_SHARED_ARRAY = 77
102-
RC_READ_SHARED_ARRAY = 78
103-
RC_CAN_TRANSFER_CHEESE = 79
104-
RC_TRANSFER_CHEESE = 80
105-
RC_THROW_RAT = 81
106-
RC_CAN_THROW_RAT = 82
107-
RC_DROP_RAT = 83
108-
RC_CAN_DROP_RAT = 84
109-
RC_CAN_CARRY_RAT = 85
110-
RC_CARRY_RAT = 86
111-
RC_DISINTEGRATE = 87
112-
RC_RESIGN = 88
113-
RC_SET_INDICATOR_STRING = 89
114-
RC_SET_INDICATOR_DOT = 90
115-
RC_SET_INDICATOR_LINE = 91
116-
RC_SET_TIMELINE_MARKER = 92
117-
RC_CAN_TURN__DIR = 93
118-
ML_DISTANCE_SQUARED_TO = 94
119-
ML_BOTTOM_LEFT_DISTANCE_SQUARED_TO = 95
120-
ML_IS_WITHIN_DISTANCE_SQUARED = 96
121-
ML_IS_WITHIN_DISTANCE_SQUARED__LOC_INT_DIR_DOUBLE = 97
122-
ML_IS_WITHIN_DISTANCE_SQUARED__LOC_INT_DIR_DOUBLE_BOOLEAN = 98
123-
ML_IS_ADJACENT_TO = 99
124-
ML_DIRECTION_TO = 100
125-
UT_GET_ALL_TYPE_LOCATIONS = 101
126-
LOG = 102
127-
THROW_GAME_ACTION_EXCEPTION = 103
128-
THROW_EXCEPTION = 104
26+
ML_DISTANCE_SQUARED_TO = 2
27+
ML_BOTTOM_LEFT_DISTANCE_SQUARED_TO = 3
28+
ML_IS_WITHIN_DISTANCE_SQUARED = 4
29+
ML_IS_WITHIN_DISTANCE_SQUARED__LOC_INT_DIR_DOUBLE = 5
30+
ML_IS_WITHIN_DISTANCE_SQUARED__LOC_INT_DIR_DOUBLE_BOOLEAN = 6
31+
ML_IS_ADJACENT_TO = 7
32+
ML_DIRECTION_TO = 8
33+
UT_GET_ALL_TYPE_LOCATIONS = 9
34+
LOG = 10
35+
THROW_GAME_ACTION_EXCEPTION = 11
36+
THROW_EXCEPTION = 12
37+
RC_GET_ROUND_NUM = 13
38+
RC_GET_MAP_WIDTH = 14
39+
RC_GET_MAP_HEIGHT = 15
40+
RC_IS_COOPERATION = 16
41+
RC_GET_ID = 17
42+
RC_GET_TEAM = 18
43+
RC_GET_LOCATION = 19
44+
RC_GET_ALL_PART_LOCATIONS = 20
45+
RC_GET_DIRECTION = 21
46+
RC_GET_HEALTH = 22
47+
RC_GET_RAW_CHEESE = 23
48+
RC_GET_GLOBAL_CHEESE = 24
49+
RC_GET_ALL_CHEESE = 25
50+
RC_GET_DIRT = 26
51+
RC_GET_TYPE = 27
52+
RC_GET_CARRYING = 28
53+
RC_IS_BEING_THROWN = 29
54+
RC_IS_BEING_CARRIED = 30
55+
RC_ON_THE_MAP = 31
56+
RC_CAN_SENSE_LOCATION = 32
57+
RC_IS_LOCATION_OCCUPIED = 33
58+
RC_CAN_SENSE_ROBOT_AT_LOCATION = 34
59+
RC_SENSE_ROBOT_AT_LOCATION = 35
60+
RC_CAN_SENSE_ROBOT = 36
61+
RC_SENSE_ROBOT = 37
62+
RC_SENSE_NEARBY_ROBOTS = 38
63+
RC_SENSE_NEARBY_ROBOTS__INT = 39
64+
RC_SENSE_NEARBY_ROBOTS__INT_TEAM = 40
65+
RC_SENSE_NEARBY_ROBOTS__LOC_INT_TEAM = 41
66+
RC_SENSE_PASSABILITY = 42
67+
RC_SENSE_MAP_INFO = 43
68+
RC_SENSE_NEARBY_MAP_INFOS = 44
69+
RC_SENSE_NEARBY_MAP_INFOS__INT = 45
70+
RC_SENSE_NEARBY_MAP_INFOS__LOC = 46
71+
RC_SENSE_NEARBY_MAP_INFOS__LOC_INT = 47
72+
RC_ADJACENT_LOCATION = 48
73+
RC_GET_ALL_LOCATIONS_WITHIN_RADIUS_SQUARED = 49
74+
RC_IS_ACTION_READY = 50
75+
RC_GET_ACTION_COOLDOWN_TURNS = 51
76+
RC_IS_MOVEMENT_READY = 52
77+
RC_IS_TURNING_READY = 53
78+
RC_GET_MOVEMENT_COOLDOWN_TURNS = 54
79+
RC_GET_TURNING_COOLDOWN_TURNS = 55
80+
RC_CAN_MOVE_FORWARD = 56
81+
RC_CAN_MOVE = 57
82+
RC_MOVE_FORWARD = 58
83+
RC_MOVE = 59
84+
RC_CAN_TURN = 60
85+
RC_TURN = 61
86+
RC_GET_CURRENT_RAT_COST = 62
87+
RC_CAN_BUILD_RAT = 63
88+
RC_BUILD_RAT = 64
89+
RC_CAN_BECOME_RAT_KING = 65
90+
RC_BECOME_RAT_KING = 66
91+
RC_CAN_PLACE_DIRT = 67
92+
RC_PLACE_DIRT = 68
93+
RC_CAN_REMOVE_DIRT = 69
94+
RC_REMOVE_DIRT = 70
95+
RC_CAN_PLACE_RAT_TRAP = 71
96+
RC_PLACE_RAT_TRAP = 72
97+
RC_CAN_REMOVE_RAT_TRAP = 73
98+
RC_REMOVE_RAT_TRAP = 74
99+
RC_CAN_PLACE_CAT_TRAP = 75
100+
RC_PLACE_CAT_TRAP = 76
101+
RC_CAN_REMOVE_CAT_TRAP = 77
102+
RC_REMOVE_CAT_TRAP = 78
103+
RC_CAN_PICK_UP_CHEESE = 79
104+
RC_PICK_UP_CHEESE = 80
105+
RC_PICK_UP_CHEESE__LOC_INT = 81
106+
RC_CAN_ATTACK = 82
107+
RC_CAN_ATTACK__LOC_INT = 83
108+
RC_ATTACK = 84
109+
RC_ATTACK__LOC_INT = 85
110+
RC_SQUEAK = 86
111+
RC_READ_SQUEAKS = 87
112+
RC_WRITE_SHARED_ARRAY = 88
113+
RC_READ_SHARED_ARRAY = 89
114+
RC_CAN_TRANSFER_CHEESE = 90
115+
RC_TRANSFER_CHEESE = 91
116+
RC_THROW_RAT = 92
117+
RC_CAN_THROW_RAT = 93
118+
RC_DROP_RAT = 94
119+
RC_CAN_DROP_RAT = 95
120+
RC_CAN_CARRY_RAT = 96
121+
RC_CARRY_RAT = 97
122+
RC_DISINTEGRATE = 98
123+
RC_RESIGN = 99
124+
RC_SET_INDICATOR_STRING = 100
125+
RC_SET_INDICATOR_DOT = 101
126+
RC_SET_INDICATOR_LINE = 102
127+
RC_SET_TIMELINE_MARKER = 103
128+
RC_CAN_TURN__DIR = 104
129+
RC_GET_BACKSTABBING_TEAM = 105
130+
RC_GET_NUMBER_RAT_TRAPS = 106
131+
RC_GET_NUMBER_CAT_TRAPS = 107
129132

130133

131134
class CrossPlayObjectType(Enum):
@@ -318,6 +321,7 @@ def parse(json):
318321
return MapInfo(
319322
parse(json["loc"]),
320323
json["pass"],
324+
parse(json["fly"]),
321325
json["wall"],
322326
json["dirt"],
323327
json["ch"],

engine/src/crossplay_python/battlecode26/wrappers.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ def get_all_locations_within_radius_squared(center: MapLocation, radius_squared:
149149
@staticmethod
150150
def get_all_part_locations() -> list[MapLocation]:
151151
return _wait(_m.RC_GET_ALL_PART_LOCATIONS)
152-
152+
153+
@staticmethod
154+
def get_backstabbing_team() -> Team:
155+
return _wait(_m.RC_GET_BACKSTABBING_TEAM)
156+
153157
@staticmethod
154158
def get_carrying() -> RobotInfo:
155159
return _wait(_m.RC_GET_CARRYING)
@@ -185,7 +189,15 @@ def get_location() -> MapLocation:
185189
@staticmethod
186190
def get_movement_cooldown_turns() -> int:
187191
return _wait(_m.RC_GET_MOVEMENT_COOLDOWN_TURNS)
188-
192+
193+
@staticmethod
194+
def get_number_rat_traps() -> int:
195+
return _wait(_m.RC_GET_NUMBER_RAT_TRAPS)
196+
197+
@staticmethod
198+
def get_number_cat_traps() -> int:
199+
return _wait(_m.RC_GET_NUMBER_CAT_TRAPS)
200+
189201
@staticmethod
190202
def get_raw_cheese() -> int:
191203
return _wait(_m.RC_GET_RAW_CHEESE)

engine/src/crossplay_python/python_docs.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Battlecode 2026 Python Documentation
2-
v1.2.1
2+
v1.2.2
33

44
## Getting Started
55

@@ -159,6 +159,9 @@ class RobotController:
159159
def get_all_part_locations() -> list[MapLocation]:
160160
pass
161161

162+
def get_backstabbing_team() -> Team:
163+
pass
164+
162165
def get_carrying() -> RobotInfo:
163166
pass
164167

@@ -186,6 +189,12 @@ class RobotController:
186189
def get_movement_cooldown_turns() -> int:
187190
pass
188191

192+
def get_number_rat_traps() -> int:
193+
pass
194+
195+
def get_number_cat_traps() -> int:
196+
pass
197+
189198
def get_raw_cheese() -> int:
190199
pass
191200

@@ -488,6 +497,7 @@ class MapInfo:
488497
Fields:
489498
- location: MapLocation
490499
- is_passable: bool
500+
- flying_robot: RobotInfo
491501
- is_wall: bool
492502
- is_dirt: bool
493503
- cheese_amount: int

engine/src/crossplay_python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
],
2727
python_requires='>=3.12, <3.13',
2828
zip_safe=False,
29-
version='1.2.1',
29+
version='1.2.2',
3030
)

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public class MapInfo {
66

77
private boolean isPassable;
88

9+
private RobotInfo flyingRobot;
10+
911
private boolean isWall;
1012

1113
private boolean isDirt;
@@ -17,7 +19,7 @@ public class MapInfo {
1719

1820
private boolean hasCheeseMine;
1921

20-
public MapInfo(MapLocation loc, boolean isPassable, boolean isWall, boolean isDirt, int cheeseAmount, TrapType trap, boolean hasCheeseMine) {
22+
public MapInfo(MapLocation loc, boolean isPassable, RobotInfo flyingRobot, boolean isWall, boolean isDirt, int cheeseAmount, TrapType trap, boolean hasCheeseMine) {
2123
if (loc == null) {
2224
throw new IllegalArgumentException("MapLocation in MapInfo constructor cannot be null");
2325
} else if (trap == null) {
@@ -26,6 +28,7 @@ public MapInfo(MapLocation loc, boolean isPassable, boolean isWall, boolean isDi
2628

2729
this.loc = loc;
2830
this.isPassable = isPassable;
31+
this.flyingRobot = flyingRobot;
2932
this.isWall = isWall;
3033
this.isDirt = isDirt;
3134
this.cheeseAmount = cheeseAmount;
@@ -44,6 +47,17 @@ public boolean isPassable() {
4447
return isPassable;
4548
}
4649

50+
/**
51+
* Returns info of a flying robot at this location
52+
*
53+
* @return RobotInfo for the flying robot at this location (or null if no flying robot is present)
54+
*
55+
* @battlecode.doc.costlymethod
56+
*/
57+
public RobotInfo flyingRobot() {
58+
return flyingRobot;
59+
}
60+
4761
/**
4862
* Returns if this square is a wall.
4963
*

0 commit comments

Comments
 (0)