def next_action(self): cell = self.block_map.find_cell(self.x, self.y) cell.state = CellState.STOPPED depleted_cells = DepletedCellList(self.block_map, self.production_params) if len(depleted_cells) > 0: return Depleted(self.block_map, depleted_cells.pop()).next_action() else: return SurroundingProduction(self.block_map).next_action()
def _recover_state(self, last_action, is_last_action_success, last_operation_value, production_params): if last_action.type == ActionType.STOP: if is_last_action_success: return Stopped(self.block_map, production_params, last_action.x, last_action.y) else: DepletedCellList.add(self.block_map.find_cell(last_action.x, last_action.y)) else: depleted_cells = DepletedCellList(self.block_map, production_params) if len(depleted_cells) > 0: return Depleted(self.block_map, depleted_cells.pop()) if self.should_stop_waste: depleted_cells = DepletedCellList(self.block_map, production_params) if len(depleted_cells) > 0: return Depleted(self.block_map, depleted_cells.pop()) else: return DoNothing(self.block_map) if last_action.type == ActionType.BUY: if is_last_action_success: return Owned(self.block_map, last_action.x, last_action.y) else: return Occupied(self.block_map, last_action.x, last_action.y) elif last_action.type == ActionType.EXPLORE: if is_last_action_success: return Explored(self.block_map, last_action.x, last_action.y, float(last_operation_value)) elif last_action.type == ActionType.DRILL: if is_last_action_success: if self._need_to_stimulate(float(last_operation_value)): return Stimulated(self.block_map, last_action.x, last_action.y) else: return Production(self.block_map, last_action.x, last_action.y) elif last_action.type == ActionType.STIMULATE: if is_last_action_success: return Production(self.block_map, last_action.x, last_action.y) return SurroundingProduction(self.block_map)