speed up loading and saving to redis that the move request are getting a answer when switching workers, strip data that neats to get recomuted every turn
Build and Push Docker Container / build-and-push (push) Successful in 4m49s
Build and Push Docker Container / build-and-push (push) Successful in 4m49s
This commit is contained in:
@@ -79,6 +79,11 @@ class ApexBattleSnake(TemplateSnake):
|
||||
# RL bootstrap dataset recorder
|
||||
self.rl_bootstrap = RLBootstrapDataset()
|
||||
|
||||
def __getstate__(self):
|
||||
state = super().__getstate__()
|
||||
state['_game_phase'] = 0.0 # A3: per-turn scalar, recomputed in choose_move
|
||||
return state
|
||||
|
||||
# ── Env helpers ──────────────────────────────────────────────────────────────
|
||||
|
||||
def _get_timeout_buffer_ms(self) -> int:
|
||||
|
||||
@@ -202,3 +202,12 @@ class TemplateSnake:
|
||||
def set_target_food(self, target_food:dict):
|
||||
self.target_food = target_food
|
||||
return True
|
||||
|
||||
def __getstate__(self):
|
||||
state = self.__dict__.copy()
|
||||
state['history'] = [] # strip history — grows per turn, not needed for moves
|
||||
state.pop('game_board', None) # re-set at top of every choose_move; circular ref
|
||||
state.pop('calculations', None) # re-initialised at top of every choose_move
|
||||
state.pop('eat_the_snake_overwrite', None) # re-initialised at top of every choose_move
|
||||
state.pop('kill_the_snake', None) # per-call transient
|
||||
return state
|
||||
|
||||
@@ -100,6 +100,17 @@ class UltimateBattleSnake(TemplateSnake):
|
||||
# RL bootstrap dataset recorder
|
||||
self.rl_bootstrap = RLBootstrapDataset()
|
||||
|
||||
def __getstate__(self):
|
||||
state = super().__getstate__()
|
||||
# strip per-turn precomputed state — all re-assigned at the top of choose_move
|
||||
state['_enemy_dmaps'] = []
|
||||
state['_enemy_heads'] = []
|
||||
state['_base_blocked'] = set()
|
||||
state['_is_snail'] = False
|
||||
state['_bfs_cache'] = {}
|
||||
state['_bfs_cache_turn'] = -1
|
||||
return state
|
||||
|
||||
# ── Env helpers ──────────────────────────────────────────────────────────────
|
||||
|
||||
def _get_timeout_buffer_ms(self) -> int:
|
||||
|
||||
Reference in New Issue
Block a user