-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid.py
30 lines (21 loc) · 897 Bytes
/
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
26
27
28
29
30
from state_handler import StateHandler
class Grid:
def __init__(self, neighborMap = {}, cells = set([])):
self.__neighborMap = neighborMap
self.__cells = cells
self.__stateHandler = StateHandler()
def addCell(self, x_y):
newState = self.__stateHandler.addCell(x_y, self.__neighborMap, self.__cells)
self.__neighborMap, self.__cells = newState
def removeCell(self, x_y):
newState = self.__stateHandler.removeCell(x_y, self.__neighborMap, self.__cells)
self.__neighborMap, self.__cells = newState
def nextState(self):
newState = self.__stateHandler.nextState(self)
self.__neighborMap, self.__cells = newState
def getNeighborMap(self):
return self.__neighborMap
def getCells(self):
return self.__cells
def isCellLive(self, x_y):
return x_y in self.__cells