action costs

This commit is contained in:
Wiktor Szynaka 2023-05-13 21:00:13 +02:00
parent 76eb4771a2
commit b25a36e872

12
bfs.py
View File

@ -90,11 +90,15 @@ def is_state_success(state: AgentState, grid: Dict[Tuple[int, int], GridCellType
except:
return False
def get_cost_for_cell_type(cell_type: GridCellType) -> int:
if cell_type == GridCellType.SPEED_BUMP:
return 10
else:
def get_cost_for_action(action: AgentActionType, cell_type: GridCellType) -> int:
if action == AgentActionType.TURN_LEFT or action == AgentActionType.TURN_RIGHT:
return 1
if cell_type == GridCellType.SPEED_BUMP:
if action == AgentActionType.MOVE_FORWARD:
return 10
if action == AgentActionType.MOVE_FORWARD:
return 3
def is_state_valid(state: AgentState, grid: Dict[Tuple[int, int], GridCellType]) -> bool:
try: