Skip to content

Commit a143b27

Browse files
committed
Merge branch 'master' into private_release
2 parents c9f1f94 + b1ff520 commit a143b27

64 files changed

Lines changed: 471 additions & 173 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

client/src/components/sidebar/game/team-table.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { schema } from 'battlecode-schema'
55
import { TeamRoundStat } from '../../../playback/RoundStat'
66
import { DoubleChevronUpIcon } from '../../../icons/chevron'
77
import { CurrentMap } from '../../../playback/Map'
8-
import { useRound } from '../../../playback/GameRunner'
8+
import { useRound, useTurnNumber } from '../../../playback/GameRunner'
99

1010
interface UnitsIconProps {
1111
teamIdx: 0 | 1
@@ -34,6 +34,8 @@ interface TeamTableProps {
3434

3535
export const TeamTable: React.FC<TeamTableProps> = (props: TeamTableProps) => {
3636
const round = useRound()
37+
// force react to re-render when using turn playback
38+
const _turn = useTurnNumber()
3739
const teamStat = round?.stat?.getTeamStat(round?.match.game.teams[props.teamIdx])
3840
const map = round?.map
3941

@@ -63,6 +65,7 @@ export const ResourceTable: React.FC<ResourceTableProps> = ({ map, teamStat, tea
6365
let ratKingCount = 0
6466
let ratKingPercent = 0
6567
let globalCheese = 0
68+
let rawCheese = 0
6669

6770
if (map && teamStat) {
6871
cheeseAmount = teamStat.cheeseAmount
@@ -72,6 +75,7 @@ export const ResourceTable: React.FC<ResourceTableProps> = ({ map, teamStat, tea
7275
ratKingCount = teamStat.ratKingCount
7376
ratKingPercent = teamStat.ratKingPercent
7477
globalCheese = teamStat.globalCheeseAmount
78+
rawCheese = teamStat.globalRawCheeseAmount
7579
}
7680

7781
const formatPercent = (val: number) => (val * 100).toFixed(1).toString() + '%'
@@ -133,7 +137,11 @@ export const ResourceTable: React.FC<ResourceTableProps> = ({ map, teamStat, tea
133137
</div>
134138
</div>
135139
</div>
136-
<div className="flex items-center w-full mt-2 mb-1 text-xs font-bold justify-around">Global Cheese Amount: {globalCheese}</div>
140+
<div className="flex items-center w-full mt-2 mb-1 text-xs font-bold justify-around">
141+
<div>Global Cheese: {globalCheese}</div>
142+
<div>Raw Cheese: {rawCheese}</div>
143+
</div>
144+
137145
</div>
138146
)
139147
}

client/src/components/sidebar/map-editor/map-editor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ export const MapEditorPage: React.FC<Props> = (props) => {
145145

146146
const applyBrush = (point: { x: number; y: number }) => {
147147
if (!openBrush) return
148+
if (point === null) return
148149

149150
const undoFunc = openBrush.apply(point.x, point.y, openBrush.fields, true)
150151
strokeUndoStack.current.push(undoFunc)

client/src/constants.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,47 @@ export const ENGINE_BUILTIN_MAP_NAMES: string[] = [
2525
// Default
2626
'DefaultSmall',
2727
'DefaultMedium',
28-
'DefaultLarge'
28+
'DefaultLarge',
2929
// Sprint 1
30+
'sittingducks',
31+
'starvation',
32+
'thunderdome',
33+
'popthecork',
34+
'cheesefarm',
35+
'rift',
36+
'ZeroDay',
37+
'pipes',
38+
'Nofreecheese',
39+
'wallsofparadis',
40+
'dirtpassageway',
41+
'trapped',
42+
'arrows',
43+
'Meow',
44+
'dirtfulcat',
45+
'keepout',
3046
// Sprint 2
47+
'5t4rv4t10n_1337',
48+
'cheesebottles',
49+
'hatefullattice',
50+
'knifefight',
51+
'mercifullattice',
52+
'peaceinourtime',
53+
'jail',
54+
'safelycontained',
55+
'minimaze',
56+
'averyfineline',
57+
'averystrangespace',
58+
'canyoudig',
59+
'streetsofnewyork',
60+
'TheHeist',
61+
'closeup',
62+
'corridorofdoomanddespair',
63+
'EscapeTheNight',
64+
'tiny',
65+
'toomuchcheese',
66+
'uneruesansfin',
67+
'whatsthecatdoin',
68+
'whereisthecheese'
3169
// HS
3270
// Quals
3371
]

client/src/playback/RoundStat.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class TeamRoundStat {
2020
ratKingPercent: number = 0
2121
dirtAmount: number = 0
2222
globalCheeseAmount: number = 0
23+
globalRawCheeseAmount: number = 0
2324
babyRatCount: number = 0
2425
ratTrapAmount: number = 0
2526
catTrapAmount: number = 0
@@ -132,7 +133,10 @@ export default class RoundStat {
132133
// Count number of alive robots
133134
if (body.dead) continue
134135

135-
if (body.robotType == schema.RobotType.RAT) teamStat.babyRatCount++
136+
if (body.robotType == schema.RobotType.RAT) {
137+
teamStat.babyRatCount++
138+
teamStat.globalRawCheeseAmount += body.cheese
139+
}
136140
}
137141

138142
const timems = Date.now() - time

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 & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -23,108 +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_CAN_ATTACK = 70
95-
RC_CAN_ATTACK__LOC_INT = 71
96-
RC_ATTACK = 72
97-
RC_ATTACK__LOC_INT = 73
98-
RC_SQUEAK = 74
99-
RC_READ_SQUEAKS = 75
100-
RC_WRITE_SHARED_ARRAY = 76
101-
RC_READ_SHARED_ARRAY = 77
102-
RC_CAN_TRANSFER_CHEESE = 78
103-
RC_TRANSFER_CHEESE = 79
104-
RC_THROW_RAT = 80
105-
RC_CAN_THROW_RAT = 81
106-
RC_DROP_RAT = 82
107-
RC_CAN_DROP_RAT = 83
108-
RC_CAN_CARRY_RAT = 84
109-
RC_CARRY_RAT = 85
110-
RC_DISINTEGRATE = 86
111-
RC_RESIGN = 87
112-
RC_SET_INDICATOR_STRING = 88
113-
RC_SET_INDICATOR_DOT = 89
114-
RC_SET_INDICATOR_LINE = 90
115-
RC_SET_TIMELINE_MARKER = 91
116-
RC_CAN_TURN__DIR = 92
117-
ML_DISTANCE_SQUARED_TO = 93
118-
ML_BOTTOM_LEFT_DISTANCE_SQUARED_TO = 94
119-
ML_IS_WITHIN_DISTANCE_SQUARED = 95
120-
ML_IS_WITHIN_DISTANCE_SQUARED__LOC_INT_DIR_DOUBLE = 96
121-
ML_IS_WITHIN_DISTANCE_SQUARED__LOC_INT_DIR_DOUBLE_BOOLEAN = 97
122-
ML_IS_ADJACENT_TO = 98
123-
ML_DIRECTION_TO = 99
124-
UT_GET_ALL_TYPE_LOCATIONS = 100
125-
LOG = 101
126-
THROW_GAME_ACTION_EXCEPTION = 102
127-
THROW_EXCEPTION = 103
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
128132

129133

130134
class CrossPlayObjectType(Enum):
@@ -317,6 +321,7 @@ def parse(json):
317321
return MapInfo(
318322
parse(json["loc"]),
319323
json["pass"],
324+
parse(json["fly"]),
320325
json["wall"],
321326
json["dirt"],
322327
json["ch"],

0 commit comments

Comments
 (0)