added coords to background
@ -7,8 +7,8 @@ import project_constants as const
|
|||||||
def calculate_screen_position(row, column):
|
def calculate_screen_position(row, column):
|
||||||
|
|
||||||
coords = (
|
coords = (
|
||||||
const.V_SCREEN_PADDING + const.V_TILE_SIZE * column,
|
const.V_NUMBER_PADDING + const.V_SCREEN_PADDING + const.V_TILE_SIZE * column,
|
||||||
const.V_SCREEN_PADDING + const.V_TILE_SIZE * row,
|
const.V_NUMBER_PADDING + const.V_SCREEN_PADDING + const.V_TILE_SIZE * row,
|
||||||
)
|
)
|
||||||
|
|
||||||
return coords
|
return coords
|
||||||
|
6
main.py
@ -25,8 +25,10 @@ def main():
|
|||||||
# create an instance of Minefield, pass necessary data
|
# create an instance of Minefield, pass necessary data
|
||||||
minefield = mf.Minefield(const.MAP_RANDOM_10x10)
|
minefield = mf.Minefield(const.MAP_RANDOM_10x10)
|
||||||
|
|
||||||
# get sequence of actions found by BFS algorythm
|
# get sequence of actions found by BFS algorithm
|
||||||
action_sequence = bfs.graphsearch(initial_state=bfs.State(row=minefield.agent.position[0],
|
action_sequence = bfs.graphsearch(
|
||||||
|
initial_state=bfs.State(
|
||||||
|
row=minefield.agent.position[0],
|
||||||
column=minefield.agent.position[1],
|
column=minefield.agent.position[1],
|
||||||
direction=const.Direction.UP),
|
direction=const.Direction.UP),
|
||||||
minefield=minefield)
|
minefield=minefield)
|
||||||
|
@ -59,8 +59,8 @@ class Minefield:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def calculate_screen_position(row, column):
|
def calculate_screen_position(row, column):
|
||||||
coords = (
|
coords = (
|
||||||
const.V_SCREEN_PADDING + const.V_TILE_SIZE * column,
|
const.V_NUMBER_PADDING + const.V_SCREEN_PADDING + const.V_TILE_SIZE * column,
|
||||||
const.V_SCREEN_PADDING + const.V_TILE_SIZE * row,
|
const.V_NUMBER_PADDING + const.V_SCREEN_PADDING + const.V_TILE_SIZE * row,
|
||||||
)
|
)
|
||||||
|
|
||||||
return coords
|
return coords
|
||||||
|
@ -14,21 +14,23 @@ from enum import Enum
|
|||||||
# ================= #
|
# ================= #
|
||||||
|
|
||||||
V_NAME_OF_WINDOW = "MineFusion TM"
|
V_NAME_OF_WINDOW = "MineFusion TM"
|
||||||
ASSETS_DIR = os.path.join("resources", "assets")
|
DIR_ASSETS = os.path.join("resources", "assets")
|
||||||
V_FPS = 60
|
V_FPS = 60
|
||||||
|
|
||||||
ACTION_INTERVAL = 1 # interval between two actions in seconds
|
ACTION_INTERVAL = 1 # interval between two actions in seconds
|
||||||
|
|
||||||
V_TILE_SIZE = 60
|
V_TILE_SIZE = 60
|
||||||
V_GRID_VER_TILES = V_GRID_HOR_TILES = 10 # vertical (number of rows), horizontal (number of columns)
|
V_GRID_VER_TILES = 10 # vertical (number of rows)
|
||||||
|
V_GRID_HOR_TILES = 10 # horizontal (number of columns)
|
||||||
V_SCREEN_PADDING = 10
|
V_SCREEN_PADDING = 10
|
||||||
V_WINDOW_HEIGHT = V_TILE_SIZE * V_GRID_VER_TILES
|
V_NUMBER_PADDING = 50
|
||||||
V_WINDOW_WIDTH = V_TILE_SIZE * V_GRID_HOR_TILES
|
V_TILE_AREA_HEIGHT = V_TILE_SIZE * V_GRID_VER_TILES
|
||||||
|
V_TILE_AREA_WIDTH = V_TILE_SIZE * V_GRID_HOR_TILES
|
||||||
|
|
||||||
SCREEN = pygame.display.set_mode(
|
SCREEN = pygame.display.set_mode(
|
||||||
(
|
(
|
||||||
V_TILE_SIZE * V_GRID_HOR_TILES + 2 * V_SCREEN_PADDING, # screen width
|
V_TILE_AREA_WIDTH + 2 * V_SCREEN_PADDING + V_NUMBER_PADDING, # screen width
|
||||||
V_TILE_SIZE * V_GRID_HOR_TILES + 2 * V_SCREEN_PADDING # screen height
|
V_TILE_AREA_HEIGHT + 2 * V_SCREEN_PADDING + V_NUMBER_PADDING # screen height
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -113,71 +115,71 @@ MAP_RANDOM_10x10 = os.path.join("resources", "minefields", "secondmap.json")
|
|||||||
# ============== #
|
# ============== #
|
||||||
|
|
||||||
ASSET_BACKGROUND = pygame.transform.scale(
|
ASSET_BACKGROUND = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "new_grid.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "numbered_grid.png")),
|
||||||
(V_WINDOW_WIDTH, V_WINDOW_WIDTH)
|
(650, 650)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_SAPPER = pygame.transform.scale(
|
ASSET_SAPPER = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "robot_sapper.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "robot_sapper.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_WALL = pygame.transform.scale(
|
ASSET_WALL = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "brick_wall.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "brick_wall.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_MINE_A = pygame.transform.scale(
|
ASSET_MINE_A = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "mine_a.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "simple assets/mine_a.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_MINE_B = pygame.transform.scale(
|
ASSET_MINE_B = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "mine_b.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "simple assets/mine_b.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_MINE_F = pygame.transform.scale(
|
ASSET_MINE_F = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "mine_f.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "simple assets/mine_f.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_MINE_K = pygame.transform.scale(
|
ASSET_MINE_K = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "mine_k.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "simple assets/mine_k.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_ORANGE = pygame.transform.scale(
|
ASSET_TILE_ORANGE = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_orange.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "tile_orange.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_RED = pygame.transform.scale(
|
ASSET_TILE_RED = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_red.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "tile_red.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_BLUE = pygame.transform.scale(
|
ASSET_TILE_BLUE = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_blue.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "tile_blue.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_PURPLE = pygame.transform.scale(
|
ASSET_TILE_PURPLE = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_purple.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "tile_purple.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_GREEN = pygame.transform.scale(
|
ASSET_TILE_GREEN = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_green.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "tile_green.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_YELLOW = pygame.transform.scale(
|
ASSET_TILE_YELLOW = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_yellow.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "tile_yellow.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_WHITE = pygame.transform.scale(
|
ASSET_TILE_WHITE = pygame.transform.scale(
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_white.png")),
|
pygame.image.load(os.path.join(DIR_ASSETS, "tile_white.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
Before Width: | Height: | Size: 406 B |
BIN
resources/assets/numbered_grid.png
Normal file
After Width: | Height: | Size: 903 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 109 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 116 B |
Before Width: | Height: | Size: 153 B After Width: | Height: | Size: 153 B |
@ -6,7 +6,7 @@ from project_constants import Direction, Action
|
|||||||
from minefield import Minefield
|
from minefield import Minefield
|
||||||
|
|
||||||
# temporary goal for testing
|
# temporary goal for testing
|
||||||
GOAL = (13, 9)
|
GOAL = (9, 9)
|
||||||
|
|
||||||
|
|
||||||
class State:
|
class State:
|
||||||
|