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

Add minimax algorithm #870

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nichujie
Copy link

@nichujie nichujie commented Mar 6, 2022

Closes #566

spelgubbe and others added 6 commits March 3, 2022 19:35
Heuristic and game state definition still missing. No tests yet.
Old GameNode is called TicTacToeGameNode as it is used to represent tic tac toe game states.
The idea is that any game implementing the GameNode interface should be able to use the
Minimax algorithm.
Changes findBestMove and minimax to be correct regardless of player associated
with a game state. Adds to the GameNode interface a required method getMove,
which should return the move which caused the game state defined by the GameNode.

Adds a test which exemplifies the previous issue and a few tests checking
the functionality of minimax when used on a Tic Tac Toe game.
if (Array.isArray(board) && board.length === 3) {
for (let i = 0; i < 3; i += 1) {
const row = board[i];
if (Array.isArray(row) && row.length === 3) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverse condition and add continue statement to decrease indentation level.

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

Successfully merging this pull request may close these issues.

Add MiniMax
3 participants