[Tutor] programming tic tac toe

Ark cloudneozero at gmail.com
Thu Aug 21 02:30:32 CEST 2008


Hi.
I programmed a simple tic tac toe game in python.  I already finished it,
but I'm not pleased with the way I used to identify a line.
I used a list (with lists inside) to represent the board.  And to identify a
winning line I used many if's, like this one:
def line(board):
    if board[0][0] == board[1][1] == board[2][2]:
        return True
    ...
    ...
    return False
It's only an examble, but I did it that way.
I did not like using all those if's, and I would like to hear suggestions to
find a line in the board, maybe a more  intelligent approach.
I would like a solution using lists because it would be useful for example
in C too, but I have been thinking about another way to represent a board.

Ark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080820/60470fc1/attachment-0001.htm>


More information about the Tutor mailing list