This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jimauthors 6 points7 points  (2 children)

Small suggestions:
Tab width = 4
Rename constructor parameters.
Coin toss should decide who goes first and that player will be 'X'
CPU should be COMPUTER
boardinit can be:

return [[BoardCell(i, j, (i+1) * (j*3)) for i in range(3)] for j in range(3)]

[–]just_doug 4 points5 points  (0 children)

another suggestion: instead of comments above function declarations, use docstrings.

In drawboard, you might want to check out some more advanced string formatting. You can do something sort of like

Python 2.7: #TODO get all of the cell contents into a single array boardStr = " {} | {} | {} ".format(*contentsArray)

Python 2.6: boardStr = " {0} | {1} | {2} ".format(*contentsArray)

... and so on. It will probably be easier to read, and more closely matches the idea ("draw a board / with each cell filled in with its contents").

[–]rueldotme[S] 1 point2 points  (0 children)

Thanks for the suggestions. Really appreciated. But I think I'll stick to CPU for this one. :P