feat: a_star without tile costs

This commit is contained in:
korzepadawid 2022-04-12 20:21:29 +02:00
parent 7131d1f905
commit 04f17e3293
4 changed files with 11 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"