Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect tie project - tic-tac-toe sample answer.py #1

Open
aulemasa opened this issue Sep 24, 2020 · 0 comments
Open

incorrect tie project - tic-tac-toe sample answer.py #1

aulemasa opened this issue Sep 24, 2020 · 0 comments

Comments

@aulemasa
Copy link

aulemasa commented Sep 24, 2020

I think there is a bug in the VictoryFor function which results in the moment when the computer places its sign in the [0,2] [1,1] [2,0] fields, it is a tie instead of the computer winning.
tie

I think this is because those two if's give the same result
if board[rc][rc] != sgn: # check 1st diagonal cross1 = False if board[2 - rc][2 - rc] != sgn: # check 2nd diagonal cross2 = False

In my opinion, the function is better to look like this
` for rc in range(3):

    if board[rc][0] == sign and board[rc][1] == sign and board[rc][2] == sign:  # check row rc
        return winner
    if board[0][rc] == sign and board[1][rc] == sign and board[2][rc] == sign:  # check column rc
        return winner

if board[0][0] == sign and board[1][1] == sign and board[2][2] == sign:
    return winner

if board[0][2] == sign and board[1][1] == sign and board[2][0] == sign:
    return winner`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant