I've implemented my chess board using my chess pieces position to update my board. The problem with this implementation is that the board doesn't store the chess pieces, it interfaces it. This means after each turn I would have to wipe the board and add the pieces back in.
from spot import Spot
import piece
class board:
board = [[0 for i in range(8)] for j in range(8)]
def __init__(self):
self.resetBoard()
def spot_getBoard(self, x, y):
if(x < 0 or x > 7 or y < 0 or x > 7):
raise Exception('Index out of bounds')
else:
return self.board
def resetBoard(self):
self.board[0][1] = Spot(0, 1, piece)
self.board[0][4] = Spot(0, 4, piece)
self.board[0][6] = Spot(0, 6, piece)
self.board[1][0] = Spot(1, 0, piece)
self.board[1][1] = Spot(1, 1, piece)
self.board[1][2] = Spot(1, 2, piece)
self.board[1][3] = Spot(1, 3, piece)
self.board[1][4] = Spot(1, 4, piece)
self.board[1][5] = Spot(1, 5, piece)
self.board[1][6] = Spot(1, 6, piece)
self.board[1][7] = Spot(1, 7, piece)
self.board[6][0] = Spot(6, 0, piece)
self.board[6][1] = Spot(6, 1, piece)
self.board[6][2] = Spot(6, 2, piece)
self.board[6][3] = Spot(6, 3, piece)
self.board[6][4] = Spot(6, 4, piece)
self.board[6][5] = Spot(6, 5, piece)
self.board[6][6] = Spot(6, 6, piece)
self.board[6][7] = Spot(6, 7, piece)
self.board[7][1] = Spot(7, 1, piece)
self.board[7][4] = Spot(7, 4, piece)
self.board[7][6] = Spot(7, 6, piece)
What I have tried:
So far I've tried adding in a game loop that updates the board after each turn.