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

[tic tac toe], before implementing minimax #33

Open
sreeharshaparuchur1 opened this issue Jan 9, 2021 · 1 comment
Open

[tic tac toe], before implementing minimax #33

sreeharshaparuchur1 opened this issue Jan 9, 2021 · 1 comment

Comments

@sreeharshaparuchur1
Copy link

When the user clicks on tiles "3,4,5" (they should win), the AI player plays too (this is wrt the code at the end of section 5) and chooses tile number "2". On tracing the path of the programme, we see that in the script, the 'turn' function is called which is meant to "checkWin" which will return "True" (as the human player has won). But, according to the way java execution works, simply returning from that function doesn't stop the execution of the next line of code in the parent function. Thus, even though we win, the only condition being checked before the AI player playing is if the game has been drawn, not won. This can be rectified easily by changing line 31 from

if (!checkTie()) turn(bestSpot(), aiPlayer);

to

if (!checkTie() && !checkWin(origBoard, huPlayer)) turn(bestSpot(), aiPlayer);
@ANURAG-PATHAK
Copy link

please assign me this issue

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

2 participants