15,939,960 members
See more:
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.
Python
```from spot import Spot
import piece

class board:
board = [[0 for i in range(8)] for j in range(8)]  #you cant have loop declerations outside of classes

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):
# Initializw Black Pieces
# self.board[0][0] = Spot(0,0,piece)  # black rooks
self.board[0][1] = Spot(0, 1, piece)  # black knight
# self.board[0][2] = Spot(0,2,piece)  # black bishops
# self.board[0][3] = Spot(0,3,piece)  # black queens
self.board[0][4] = Spot(0, 4, piece)  # black king
# self.board[0][5] = Spot(0,5,piece)  # black bishops
self.board[0][6] = Spot(0, 6, piece)  # black knight
# self.board[0][7] = Spot(0,7,piece)  # black rooks
self.board[1][0] = Spot(1, 0, piece)  # black pawn
self.board[1][1] = Spot(1, 1, piece)  # black pawn
self.board[1][2] = Spot(1, 2, piece)  # black pawn
self.board[1][3] = Spot(1, 3, piece)  # black pawn
self.board[1][4] = Spot(1, 4, piece)  # black pawn
self.board[1][5] = Spot(1, 5, piece)  # black pawn
self.board[1][6] = Spot(1, 6, piece)  # black pawn
self.board[1][7] = Spot(1, 7, piece)  # black pawn

# Initializw White Pieces
self.board[6][0] = Spot(6, 0, piece)  # white pawn
self.board[6][1] = Spot(6, 1, piece)  # white pawn
self.board[6][2] = Spot(6, 2, piece)  # white pawn
self.board[6][3] = Spot(6, 3, piece)  # white pawn
self.board[6][4] = Spot(6, 4, piece)  # white pawn
self.board[6][5] = Spot(6, 5, piece)  # white pawn
self.board[6][6] = Spot(6, 6, piece)  # white pawn
self.board[6][7] = Spot(6, 7, piece)  # white pawn
# self.board[7][0] = Spot(7,0,piece)  # white rooks
self.board[7][1] = Spot(7, 1, piece)  # white knight
# self.board[7][2] = Spot(7,2,piece)  # white bishops
# self.board[7][3] = Spot(7,3,piece)  # white queens
self.board[7][4] = Spot(7, 4, piece)  # white king
# self.board[7][5] = Spot(7,5,piece)  # white bishops
self.board[7][6] = Spot(7, 6, piece)  # white knight
# self.board[7][7] = Spot(7,7,piece)  # white rooks```

What I have tried:

So far I've tried adding in a game loop that updates the board after each turn.
Posted
Updated 22-Jul-20 22:30pm
v2
[no name] 23-Jul-20 0:44am
Maybe you're not persisting "board" between calls.
I'm confused as to what you mean by persisting board between calls?
Richard MacCutchan 23-Jul-20 4:33am
You have not shown any of the code that causes the issue. I also noticed in the following line:
`if(x < 0 or x > 7 or y < 0 or x > 7):`

the last expression should be for `y` not `x`.