Refactoring minimax tests

[?]
Dec 28, 2020, 7:14 PM
R6MPEEL26MQ424DRMCNE7RT7OABPD3RTKVQNCUXZ4AIWTEM6CJ6QC

Dependencies

Change contents

  • replacement in snippets/tictactoe/minimax_test.go at line 1
    [2.388][2.389:407]()
    package tictactoe
    [2.388]
    [2.407]
    package tictactoe_test
  • edit in snippets/tictactoe/minimax_test.go at line 6
    [2.436]
    [2.436]
    "tictactoe"
  • replacement in snippets/tictactoe/minimax_test.go at line 25
    [2.922][2.922:999]()
    assert.Equal(t, tc.expected, minimax(0, 0, true, tc.scores, int(height)))
    [2.922]
    [2.999]
    assert.Equal(t, tc.expected, tictactoe.Minimax(0, 0, true, tc.scores, int(height)))
  • replacement in snippets/tictactoe/minimax.go at line 3
    [2.1043][2.1043:1410]()
    // 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 Tree
    func minimax(depth, nodeIndex int, isMax bool, scores []int, height int) int {
    [2.1043]
    [2.1410]
    // 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 Tree
    func Minimax(depth, nodeIndex int, isMax bool, scores []int, height int) int {
  • replacement in snippets/tictactoe/minimax.go at line 15
    [2.1515][2.1515:1644]()
    left := minimax(depth+1, nodeIndex*2, false, scores, height)
    right := minimax(depth+1, nodeIndex*2+1, false, scores, height)
    [2.1515]
    [2.1644]
    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
    [2.1670][2.1670:1833]()
    } 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
    [2.1836]
    [2.1836]
    left := Minimax(depth+1, nodeIndex*2, true, scores, height)
    right := Minimax(depth+1, nodeIndex*2+1, true, scores, height)
    return min(left, right)