Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions engine/src/crossplay_python/battlecode26/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,6 @@ def __repr__(self) -> str:
_trap_to_index = {trap: index for index, trap in enumerate(_trap_order)}


class MapInfo:
def __init__(self, location: MapLocation, is_passable: bool, is_wall: bool, is_dirt: bool,
cheese_amount: int, trap: TrapType, has_cheese_mine: bool):
self.location = location
self.is_passable = is_passable
self.is_wall = is_wall
self.is_dirt = is_dirt
self.cheese_amount = cheese_amount
self.trap = trap
self.has_cheese_mine = has_cheese_mine


class RobotInfo:
def __init__(self, id: int, team: Team, unit_type: UnitType, health: int,
location: MapLocation, direction: Direction,
Expand All @@ -243,6 +231,19 @@ def __init__(self, id: int, team: Team, unit_type: UnitType, health: int,
self.carrying_robot = carrying_robot


class MapInfo:
def __init__(self, location: MapLocation, is_passable: bool, flying_robot: RobotInfo, is_wall: bool,
is_dirt: bool, cheese_amount: int, trap: TrapType, has_cheese_mine: bool):
self.location = location
self.is_passable = is_passable
self.flying_robot = flying_robot
self.is_wall = is_wall
self.is_dirt = is_dirt
self.cheese_amount = cheese_amount
self.trap = trap
self.has_cheese_mine = has_cheese_mine


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


class CrossPlayObjectType(Enum):
Expand Down Expand Up @@ -318,6 +321,7 @@ def parse(json):
return MapInfo(
parse(json["loc"]),
json["pass"],
parse(json["fly"]),
json["wall"],
json["dirt"],
json["ch"],
Expand Down
16 changes: 14 additions & 2 deletions engine/src/crossplay_python/battlecode26/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ def get_all_locations_within_radius_squared(center: MapLocation, radius_squared:
@staticmethod
def get_all_part_locations() -> list[MapLocation]:
return _wait(_m.RC_GET_ALL_PART_LOCATIONS)


@staticmethod
def get_backstabbing_team() -> Team:
return _wait(_m.RC_GET_BACKSTABBING_TEAM)

@staticmethod
def get_carrying() -> RobotInfo:
return _wait(_m.RC_GET_CARRYING)
Expand Down Expand Up @@ -185,7 +189,15 @@ def get_location() -> MapLocation:
@staticmethod
def get_movement_cooldown_turns() -> int:
return _wait(_m.RC_GET_MOVEMENT_COOLDOWN_TURNS)


@staticmethod
def get_number_rat_traps() -> int:
return _wait(_m.RC_GET_NUMBER_RAT_TRAPS)

@staticmethod
def get_number_cat_traps() -> int:
return _wait(_m.RC_GET_NUMBER_CAT_TRAPS)

@staticmethod
def get_raw_cheese() -> int:
return _wait(_m.RC_GET_RAW_CHEESE)
Expand Down
12 changes: 11 additions & 1 deletion engine/src/crossplay_python/python_docs.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Battlecode 2026 Python Documentation
v1.2.1
v1.2.2

## Getting Started

Expand Down Expand Up @@ -159,6 +159,9 @@ class RobotController:
def get_all_part_locations() -> list[MapLocation]:
pass

def get_backstabbing_team() -> Team:
pass

def get_carrying() -> RobotInfo:
pass

Expand Down Expand Up @@ -186,6 +189,12 @@ class RobotController:
def get_movement_cooldown_turns() -> int:
pass

def get_number_rat_traps() -> int:
pass

def get_number_cat_traps() -> int:
pass

def get_raw_cheese() -> int:
pass

Expand Down Expand Up @@ -488,6 +497,7 @@ class MapInfo:
Fields:
- location: MapLocation
- is_passable: bool
- flying_robot: RobotInfo
- is_wall: bool
- is_dirt: bool
- cheese_amount: int
Expand Down
2 changes: 1 addition & 1 deletion engine/src/crossplay_python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
],
python_requires='>=3.12, <3.13',
zip_safe=False,
version='1.2.1',
version='1.2.2',
)
16 changes: 15 additions & 1 deletion engine/src/main/battlecode/common/MapInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public class MapInfo {

private boolean isPassable;

private RobotInfo flyingRobot;

private boolean isWall;

private boolean isDirt;
Expand All @@ -17,7 +19,7 @@ public class MapInfo {

private boolean hasCheeseMine;

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

this.loc = loc;
this.isPassable = isPassable;
this.flyingRobot = flyingRobot;
this.isWall = isWall;
this.isDirt = isDirt;
this.cheeseAmount = cheeseAmount;
Expand All @@ -44,6 +47,17 @@ public boolean isPassable() {
return isPassable;
}

/**
* Returns info of a flying robot at this location
*
* @return RobotInfo for the flying robot at this location (or null if no flying robot is present)
*
* @battlecode.doc.costlymethod
*/
public RobotInfo flyingRobot() {
return flyingRobot;
}

/**
* Returns if this square is a wall.
*
Expand Down
Loading