diff --git a/src/game_ui.py b/src/game_ui.py index 1d2214f..6eb8d7e 100644 --- a/src/game_ui.py +++ b/src/game_ui.py @@ -2,7 +2,7 @@ import pygame as pg from agent import Agent from environment import Environment -from const import WIDTH, HEIGHT, IMAGES, SAPPER_IDLE +from const import WIDTH, HEIGHT, IMAGES, SAPPER_IDLE, ROCK_INDEXES, SAPPER_KABOOM class GameUi: @@ -17,10 +17,10 @@ class GameUi: shift = -1 if self.agent.direction in (0, 3) else 1 if coord == 'x': - if self.env.field[self.agent.y][self.agent.x+shift].number in (2, 3): + if self.env.field[self.agent.y][self.agent.x+shift].number in ROCK_INDEXES: return elif coord == 'y': - if self.env.field[self.agent.y+shift][self.agent.x].number in (2, 3): + if self.env.field[self.agent.y+shift][self.agent.x].number in ROCK_INDEXES: return for x in range(8): @@ -46,3 +46,10 @@ class GameUi: self.agent.direction = (self.agent.direction + direction) % 4 self.agent.img = SAPPER_IDLE[self.agent.direction] self.update() + + def kaboom(self): + self.agent.img = SAPPER_KABOOM[self.agent.direction] + self.update() + pg.time.delay(500) + self.agent.img = SAPPER_IDLE[self.agent.direction] + self.update() diff --git a/src/search_algoritms/helpers.py b/src/search_algoritms/helpers.py index c8eb4ac..acb3dbe 100644 --- a/src/search_algoritms/helpers.py +++ b/src/search_algoritms/helpers.py @@ -3,6 +3,7 @@ from typing import List, Tuple import pygame as pg from src.tile import Tile +from const import ROCK_INDEXES from search_algoritms.node import Node @@ -30,9 +31,9 @@ def successor(field: List[List[Tile]], x: int, y: int, direction: int): neighbours.append((x, y, (direction - 1) % 4, pg.K_a)) neighbours.append((x, y, (direction + 1) % 4, pg.K_d)) - if coord == 'x' and 0 <= x + shift <= 9 and field[y][x + shift].number not in (2, 3): + if coord == 'x' and 0 <= x + shift <= 9 and field[y][x + shift].number not in ROCK_INDEXES: neighbours.append((x + shift, y, direction, pg.K_w)) - elif coord == 'y' and 0 <= y + shift <= 9 and field[y + shift][x].number not in (2, 3): + elif coord == 'y' and 0 <= y + shift <= 9 and field[y + shift][x].number not in ROCK_INDEXES: neighbours.append((x, y + shift, direction, pg.K_w)) return neighbours