I'm fairly new to Python and so I'm not extremely familiar with the syntax and the way things work exactly. It's possible I'm misunderstanding, but from what I can tell from my code this line:
largeBoard = [[Board() for i in range(3)] for j in range(3)]
is creating 9 references to the same Board object, rather than 9 different Board objects. How do I create 9 different Board objects instead?
When I run:
largeBoard = [[Board() for i in range(3)] for j in range(3)]
x_or_o = 'x'
largeBoard[1][0].board[0][0] = 'g' # each Board has a board inside that is a list
for i in range(3):
for j in range(3):
for k in range(3):
for l in range(3):
print largeBoard[i][j].board[k][l]
I get multiple 'g' that is what made me think that they are all references to the same object.
Boardobjects. Try printing theidof each object inlargeBoard.Boardclass... perhaps it is built around a singleton-like pattern that simply returns (a reference to) the same object every time you call it's constructor...boardinstead of settingself.boardin the__init__method.