Skip to content

Commit

Permalink
changes to state
Browse files Browse the repository at this point in the history
  • Loading branch information
john.wohl@uconn.edu committed Dec 4, 2019
1 parent 3a1fd22 commit 5a38693
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions state.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
WHITE = "W"
BLACK = "B"

class State:
def __init__(self):
self.nrows = 18
Expand All @@ -10,14 +13,21 @@ def setup(self):
self.board.append([])
for col in range(self.ncols):
if((row + col) % 2 == 0):
self.board[row].append("B")
self.board[row].append(BLACK)
else:
self.board[row].append("W")
self.board[row].append(WHITE)

def removePiece(self, row, col):
self.board[row][col] = None

def placePiece(self, row, col, color):
if(not self.board[row][col]):
self.board[row][col] = color
else:
print("Error: attempted to place piece on occupied spot")

def __str__(self):
string = ""
for row in range(self.nrows):
string += str(self.board[row]) + "\n"
return string


0 comments on commit 5a38693

Please sign in to comment.