-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_grid.py
25 lines (22 loc) · 1.06 KB
/
my_grid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from my_chessblock import ChessBlock
import numpy as np
class Grid:
def __init__(self, my_x : float, my_y: float):
self.core_grid = np.empty((my_x, my_y), dtype=ChessBlock) #Numpy Array that represents the chessblock
self.grid_width = my_x #Width of the chessboard
self.grid_height = my_y #Height of the chessboard
dump_list = [] #Empty list used as a temporary grid
for i in range(my_x):
column = [] #Columns of the temporary grid
for j in range(my_y):
StandardBlock = ChessBlock(i, j) #Creates a chessblock
column.append(StandardBlock) #Adds the block to the column
dump_list.append(column) #Adds the column to grid
self.core_grid = np.array(dump_list, copy=True) #Creates proper chessgrid
#del column, dump_list
def PrintGrid(self): #Prints the chessboard
print("Grid: ")
for i in range(self.grid_width):
for j in range(self.grid_height):
print(self.core_grid[i][j], "\t", end=" ")
print("")