Skip to content

Commit 5acbedb

Browse files
committed
Bomberland polish: drop redundant per-call deepcopies and dead bombs_returned stat
- Remove copy.deepcopy in call_agent args and _agent_worker; the agent runs in a separate process (isolation from the process boundary), and make_state already snapshots agents/units, so the extra copies were pure overhead. - Remove the bombs_returned stat, which was tracked but never scored or reported (bomb inventory refund on explosion is unchanged).
1 parent ba03805 commit 5acbedb

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

codeclash/arenas/bomberland/runtime/run_bomberland.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def load_agent(name, path):
4242
def _agent_worker(path, state, result_queue):
4343
try:
4444
callback = load_agent("runtime", path)
45-
result = callback(copy.deepcopy(state))
45+
result = callback(state)
4646
result_queue.put({"actions": result if isinstance(result, dict) else {}})
4747
except BaseException as exc:
4848
if isinstance(exc, (KeyboardInterrupt, SystemExit)):
@@ -55,7 +55,7 @@ def call_agent(agent_path, state, timeout):
5555
start_method = "fork" if "fork" in multiprocessing.get_all_start_methods() else "spawn"
5656
context = multiprocessing.get_context(start_method)
5757
result_queue = context.Queue(maxsize=1)
58-
process = context.Process(target=_agent_worker, args=(agent_path, copy.deepcopy(state), result_queue))
58+
process = context.Process(target=_agent_worker, args=(agent_path, state, result_queue))
5959
process.start()
6060
process.join(timeout)
6161
if process.is_alive():
@@ -240,7 +240,6 @@ def explode_bomb(index, bombs, metal, wood, units, stats, blasts):
240240
bomb = bombs[index]
241241
cells = blast_cells(bomb["pos"], bomb["radius"], metal, wood)
242242
owner = bomb["owner"]
243-
stats[owner]["bombs_returned"] += 1
244243
unit_id = bomb.get("unit_id")
245244
if unit_id in units:
246245
units[unit_id]["inventory"]["bombs"] += 1
@@ -398,7 +397,6 @@ def run_game(players, callbacks, seed, ticks, width, height, unit_count, agent_t
398397
"wood_destroyed": 0,
399398
"invalid_actions": 0,
400399
"agent_errors": 0,
401-
"bombs_returned": 0,
402400
}
403401
for player in players
404402
}

0 commit comments

Comments
 (0)