Refactoring minimax tests
[?]
Dec 28, 2020, 7:14 PM
R6MPEEL26MQ424DRMCNE7RT7OABPD3RTKVQNCUXZ4AIWTEM6CJ6QCDependencies
- [2]
G5KXCVILtictactoe: initial import
Change contents
- replacement in snippets/tictactoe/minimax_test.go at line 1
package tictactoepackage tictactoe_test - edit in snippets/tictactoe/minimax_test.go at line 6
"tictactoe" - replacement in snippets/tictactoe/minimax_test.go at line 25
assert.Equal(t, tc.expected, minimax(0, 0, true, tc.scores, int(height)))assert.Equal(t, tc.expected, tictactoe.Minimax(0, 0, true, tc.scores, int(height))) - replacement in snippets/tictactoe/minimax.go at line 3
// minimax is for retrieving the optimal value for maximizer// depth is the current depth in the game tree// nodeIndex is the current index of node in scores// scores stores the Game Tree// isMax is true if the current move is a maximizer// height is the max height of the Game Treefunc minimax(depth, nodeIndex int, isMax bool, scores []int, height int) int {// Minimax is for retrieving the optimal value for maximizer.// depth is the current depth in the game tree// nodeIndex is the current index of node in scores// isMax is true if the current move is a maximizer// scores stores the Game Tree// height is the max height of the Game Treefunc Minimax(depth, nodeIndex int, isMax bool, scores []int, height int) int { - replacement in snippets/tictactoe/minimax.go at line 15
left := minimax(depth+1, nodeIndex*2, false, scores, height)right := minimax(depth+1, nodeIndex*2+1, false, scores, height)left := Minimax(depth+1, nodeIndex*2, false, scores, height)right := Minimax(depth+1, nodeIndex*2+1, false, scores, height) - edit in snippets/tictactoe/minimax.go at line 18
} else {left := minimax(depth+1, nodeIndex*2, true, scores, height)right := minimax(depth+1, nodeIndex*2+1, true, scores, height)return min(left, right) - edit in snippets/tictactoe/minimax.go at line 19
left := Minimax(depth+1, nodeIndex*2, true, scores, height)right := Minimax(depth+1, nodeIndex*2+1, true, scores, height)return min(left, right)