Inteligentny_Wozek/grid.py

36 lines
983 B
Python
Raw Normal View History

2023-05-06 18:06:30 +02:00
from enum import Enum
2023-05-08 11:27:16 +02:00
from plansza import x1,x2,x3,x4,y1,y2,y3,y4,a,b
2023-05-06 18:06:30 +02:00
from typing import Tuple, Dict
class GridCellType(Enum):
FREE = 0
RACK = 1
PLACE = 2
2023-05-29 00:13:02 +02:00
# class RackCellType(Enum):
# OGROD = 0
# NARZEDZIA = 1
# KUCHNIA = 2
# MOTORYZACJA = 3
2023-05-06 18:06:30 +02:00
class SearchGrid:
grid: Dict[Tuple[int, int], GridCellType] = {}
2023-05-29 00:13:02 +02:00
# rack_grid : Dict[Tuple[int, int], GridCellType] = {}
2023-05-06 18:06:30 +02:00
def __init__(self) -> None:
self._init_grid()
def _init_grid(self) -> None:
for i in range (0,14):
for j in range(0,14):
self.grid[(i, j)] = GridCellType.FREE
2023-05-29 00:13:02 +02:00
for c, d in [(x1, y1), (x1, y1+1), (x1+1, y1), (x1+1, y1+1), (x2, y2), (x2+1, y2), (x2, y2+1), (x2+1, y2+1),
2023-05-08 11:27:16 +02:00
(x3, y3), (x3+1, y3), (x3, y3+1), (x3+1, y3+1), (x4, y4), (x4+1, y4), (x4, y4+1), (x4+1, y4+1),]:
2023-05-29 00:13:02 +02:00
self.grid[(c,d)] = GridCellType.RACK
2023-05-30 21:00:08 +02:00
for e, f in [(a,b)]:
2023-05-29 00:13:02 +02:00
self.grid[(e,f)] = GridCellType.PLACE