-
Notifications
You must be signed in to change notification settings - Fork 4
/
board.py
51 lines (42 loc) · 1.34 KB
/
board.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
42
43
44
45
46
47
48
49
50
51
''' The Board Class :
The board class creates a 18x18 board for gameplay,
with boundaries, walls and empty spaces. It also
comprises of a getprint function to take a print
of the board.'''
class Board:
'''The main board class'''
board = [[] for i in range(0, 42)]
# Types of Rows
boundaryWalls = ["X" for i in range(0, 84)]
normalRow = []
normalRowWithBricks = []
for i in range(0, 84):
if i < 4 or i >= 80:
normalRow.append('X')
else:
normalRow.append(' ')
for i in range(0, 84):
if i >= 80:
normalRowWithBricks.append('X')
elif i % 8 < 4:
if i < 80:
normalRowWithBricks.append('X')
else:
if i < 80:
normalRowWithBricks.append(' ')
for i in range(0, 42):
if i < 2 or i >= 40:
board[i] = boundaryWalls[:]
elif (i - 2) % 4 < 2:
board[i] = normalRow[:]
else:
board[i] = normalRowWithBricks[:]
# The Basic Function to get a print of the board.
def getprint(self):
'''Method to get a print of board'''
temp = ['' for i in range(0, 84)]
for j in range(0, 42):
for i in range(0, 84):
temp[j] = temp[j] + self.board[j][i]
for i in range(0, 42):
print(temp[i])