Skip to content
This repository was archived by the owner on Apr 17, 2019. It is now read-only.

Conversation

JulienMattiussi
Copy link
Collaborator

@JulienMattiussi JulienMattiussi commented Jul 20, 2018

https://trello.com/c/ty1OGS7T

Full algorithm is done
I have not won against computer since this. (draws sometimes)

@JulienMattiussi JulienMattiussi changed the title [WIP] Minimax algorithm return a valid solution [RFR] Minimax algorithm return a valid solution Jul 21, 2018
return piecesListNonWinning.([]int)
}
return loosingBoxList.([]grid.Point)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You should have a rule in vscode to add automatically an empty line at the end of each file.

node.Childs = append(node.Childs, AppendChildNodes(childNode, depth-1, quit))
} else {
for i := 0; i < len(boxList); i++ {
if len(piecesList) > 1 && len(boxList) > 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should split the code into small functions because it's not so readable. And in addition you could test small part of code.

// PlayTurn return the next move for given grid
func PlayTurn(currentState state.State) state.State {
newState, done := ai.StartMiniMax(currentState, 0)
newState, done := ai.StartMiniMax(currentState, 30)
Copy link
Contributor

Choose a reason for hiding this comment

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

You could have a constant

return bestState
}

func CalculateNodeValue(node StateNode) int {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this function but I don't find a prettier version ^^

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, the same ...

childNode.Value = LoosingLeafValue
}
return append(currentNode.Childs, childNode)
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need else

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants