-
Notifications
You must be signed in to change notification settings - Fork 0
/
MapMatrix.py
42 lines (32 loc) · 1.26 KB
/
MapMatrix.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from Config import CROSS, CIRCLE, EMPTY, DIMENSION
class MapMatrix:
def __init__(self, size, nparray=None):
self.matrix = [[EMPTY for _ in range(size)] for _ in range(size)]
if nparray is not None:
for i in range(size):
for j in range(size):
if nparray[i][j] == 0:
self.matrix[i][j] = EMPTY
else:
self.matrix[i][j] = nparray[i][j]
self.marks = 0
def markOn(self, coordinates, turn):
if turn == 'ai':
self.matrix[coordinates.x][coordinates.y] = CIRCLE
elif turn == 'player':
self.matrix[coordinates.x][coordinates.y] = CROSS
self.marks += 1
def markCrossOn(self, coordinates):
self.matrix[coordinates.x][coordinates.y] = CROSS
self.marks += 1
def markCircleOn(self, coordinates):
self.matrix[coordinates.x][coordinates.y] = CIRCLE
self.marks += 1
def markAsEmpty(self, coordinates):
if self.matrix[coordinates.x][coordinates.y] != EMPTY:
self.marks -= 1
self.matrix[coordinates.x][coordinates.y] = EMPTY
def checkIfMapFull(self):
if self.marks == DIMENSION**2:
return True
return False