diff --git a/algorithms/a_star.py b/algorithms/a_star.py index 67f0924..ffcf543 100644 --- a/algorithms/a_star.py +++ b/algorithms/a_star.py @@ -92,7 +92,7 @@ def actions(state: State, grid: List[List[str]]) -> List[str]: if direction == RIGHT and col == COLUMNS - 1: remove_forward(possible_actions) - if FORWARD not in possible_actions and not valid_move(next_position(state.position, direction), grid): + if FORWARD in possible_actions and not valid_move(next_position(state.position, direction), grid): remove_forward(possible_actions) return possible_actions diff --git a/common/constants.py b/common/constants.py index 692c32d..a4ab9f0 100644 --- a/common/constants.py +++ b/common/constants.py @@ -4,7 +4,7 @@ GAME_TITLE = 'WMICraft' WINDOW_HEIGHT = 800 WINDOW_WIDTH = 1360 FPS_COUNT = 60 -TURN_INTERVAL = 1000 +TURN_INTERVAL = 300 GRID_CELL_PADDING = 5 GRID_CELL_SIZE = 36 diff --git a/logic/level.py b/logic/level.py index e657bc3..a3f4a06 100644 --- a/logic/level.py +++ b/logic/level.py @@ -128,13 +128,13 @@ class Level: # update knight on map if current_knight.direction.name == UP: - self.map[knight_pos_y - 1][knight_pos_x] = current_knight + self.map[knight_pos_y - 1][knight_pos_x] = current_knight.team_alias() elif current_knight.direction.name == RIGHT: - self.map[knight_pos_y][knight_pos_x + 1] = current_knight + self.map[knight_pos_y][knight_pos_x + 1] = current_knight.team_alias() elif current_knight.direction.name == DOWN: - self.map[knight_pos_y + 1][knight_pos_x] = current_knight + self.map[knight_pos_y + 1][knight_pos_x] = current_knight.team_alias() elif current_knight.direction.name == LEFT: - self.map[knight_pos_y][knight_pos_x - 1] = current_knight + self.map[knight_pos_y][knight_pos_x - 1] = current_knight.team_alias() def update(self): bg_width = (GRID_CELL_PADDING + GRID_CELL_SIZE) * COLUMNS + BORDER_WIDTH diff --git a/models/knight.py b/models/knight.py index f9bac44..2f69f71 100644 --- a/models/knight.py +++ b/models/knight.py @@ -1,6 +1,7 @@ -import pygame.image import random +import pygame.image + from common.constants import GRID_CELL_SIZE, Direction from common.helpers import parse_cord @@ -56,3 +57,6 @@ class Knight(pygame.sprite.Sprite): elif self.direction.name == 'LEFT': self.position = (self.position[0] - 1, self.position[1]) self.rect.x = self.rect.x - GRID_CELL_SIZE - 5 + + def team_alias(self) -> str: + return "k_b" if self.team == "blue" else "k_r"