feat: a_star without tile costs
This commit is contained in:
parent
7131d1f905
commit
04f17e3293
@ -92,7 +92,7 @@ def actions(state: State, grid: List[List[str]]) -> List[str]:
|
|||||||
if direction == RIGHT and col == COLUMNS - 1:
|
if direction == RIGHT and col == COLUMNS - 1:
|
||||||
remove_forward(possible_actions)
|
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)
|
remove_forward(possible_actions)
|
||||||
|
|
||||||
return possible_actions
|
return possible_actions
|
||||||
|
@ -4,7 +4,7 @@ GAME_TITLE = 'WMICraft'
|
|||||||
WINDOW_HEIGHT = 800
|
WINDOW_HEIGHT = 800
|
||||||
WINDOW_WIDTH = 1360
|
WINDOW_WIDTH = 1360
|
||||||
FPS_COUNT = 60
|
FPS_COUNT = 60
|
||||||
TURN_INTERVAL = 1000
|
TURN_INTERVAL = 300
|
||||||
|
|
||||||
GRID_CELL_PADDING = 5
|
GRID_CELL_PADDING = 5
|
||||||
GRID_CELL_SIZE = 36
|
GRID_CELL_SIZE = 36
|
||||||
|
@ -128,13 +128,13 @@ class Level:
|
|||||||
|
|
||||||
# update knight on map
|
# update knight on map
|
||||||
if current_knight.direction.name == UP:
|
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:
|
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:
|
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:
|
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):
|
def update(self):
|
||||||
bg_width = (GRID_CELL_PADDING + GRID_CELL_SIZE) * COLUMNS + BORDER_WIDTH
|
bg_width = (GRID_CELL_PADDING + GRID_CELL_SIZE) * COLUMNS + BORDER_WIDTH
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import pygame.image
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
import pygame.image
|
||||||
|
|
||||||
from common.constants import GRID_CELL_SIZE, Direction
|
from common.constants import GRID_CELL_SIZE, Direction
|
||||||
from common.helpers import parse_cord
|
from common.helpers import parse_cord
|
||||||
|
|
||||||
@ -56,3 +57,6 @@ class Knight(pygame.sprite.Sprite):
|
|||||||
elif self.direction.name == 'LEFT':
|
elif self.direction.name == 'LEFT':
|
||||||
self.position = (self.position[0] - 1, self.position[1])
|
self.position = (self.position[0] - 1, self.position[1])
|
||||||
self.rect.x = self.rect.x - GRID_CELL_SIZE - 5
|
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"
|
||||||
|
Loading…
Reference in New Issue
Block a user