Refactoring evaluate_test

[?]
Dec 28, 2020, 4:45 PM
2DRAL6A256OELKDGOGBXQ2VLLIEKKKZ4VEV3O26QP7JJN32SB3IQC

Dependencies

  • [2] HSJSKGY7 Refactoring evaluate functions
  • [3] G5KXCVIL tictactoe: initial import
  • [4] UWVAMBIJ Fix couple of tests, add more
  • [5] TYELLGSA Rename checkDiag to checkDiagLR and add checkDiagRL. Add more tests

Change contents

  • replacement in snippets/tictactoe/evaluate_test.go at line 1
    [3.2067][3.2068:2086]()
    package tictactoe
    [3.2067]
    [3.2086]
    package tictactoe_test
  • edit in snippets/tictactoe/evaluate_test.go at line 5
    [3.2107]
    [3.2107]
    "tictactoe"
  • replacement in snippets/tictactoe/evaluate_test.go at line 13
    [3.2232][2.71:91]()
    board Board
    [3.2232]
    [3.2255]
    board tictactoe.Board
  • replacement in snippets/tictactoe/evaluate_test.go at line 16
    [3.2277][3.2277:2460](),[3.2460][3.0:383]()
    {"Nothing", [][]rune{{Pl1, Pl1, Pl2}, {Empty, Empty, Empty}, {Empty, Empty, Empty}}, 0},
    {"Pl1 row", [][]rune{{Pl1, Pl1, Pl1}, {Empty, Empty, Empty}, {Empty, Empty, Empty}}, 10},
    {"Pl2 col", [][]rune{{Pl2, Empty, Empty}, {Pl2, Empty, Empty}, {Pl2, Empty, Empty}}, -10},
    {"Pl1 last col", [][]rune{{Empty, Empty, Pl1}, {Empty, Empty, Pl1}, {Empty, Empty, Pl1}}, 10},
    {"Pl2 diag lr", [][]rune{{Pl2, Empty, Empty}, {Empty, Pl2, Empty}, {Empty, Empty, Pl2}}, -10},
    {"Pl1 diag rl", [][]rune{{Empty, Empty, Pl1}, {Empty, Pl1, Empty}, {Pl1, Empty, Empty}}, 10},
    [3.2277]
    [3.2638]
    {"Nothing", tictactoe.Board{{tictactoe.Pl1, tictactoe.Pl1, tictactoe.Pl2}, {tictactoe.Empty, tictactoe.Empty, tictactoe.Empty}, {tictactoe.Empty, tictactoe.Empty, tictactoe.Empty}}, 0},
    {"tictactoe.Pl1 row", tictactoe.Board{{tictactoe.Pl1, tictactoe.Pl1, tictactoe.Pl1}, {tictactoe.Empty, tictactoe.Empty, tictactoe.Empty}, {tictactoe.Empty, tictactoe.Empty, tictactoe.Empty}}, 10},
    {"tictactoe.Pl2 col", tictactoe.Board{{tictactoe.Pl2, tictactoe.Empty, tictactoe.Empty}, {tictactoe.Pl2, tictactoe.Empty, tictactoe.Empty}, {tictactoe.Pl2, tictactoe.Empty, tictactoe.Empty}}, -10},
    {"tictactoe.Pl1 last col", tictactoe.Board{{tictactoe.Empty, tictactoe.Empty, tictactoe.Pl1}, {tictactoe.Empty, tictactoe.Empty, tictactoe.Pl1}, {tictactoe.Empty, tictactoe.Empty, tictactoe.Pl1}}, 10},
    {"tictactoe.Pl2 diag lr", tictactoe.Board{{tictactoe.Pl2, tictactoe.Empty, tictactoe.Empty}, {tictactoe.Empty, tictactoe.Pl2, tictactoe.Empty}, {tictactoe.Empty, tictactoe.Empty, tictactoe.Pl2}}, -10},
    {"tictactoe.Pl1 diag rl", tictactoe.Board{{tictactoe.Empty, tictactoe.Empty, tictactoe.Pl1}, {tictactoe.Empty, tictactoe.Pl1, tictactoe.Empty}, {tictactoe.Pl1, tictactoe.Empty, tictactoe.Empty}}, 10},
  • replacement in snippets/tictactoe/evaluate_test.go at line 25
    [3.2729][2.92:145]()
    assert.Equal(t, tc.expected, tc.board.evaluate())
    [3.2729]
    [3.2781]
    assert.Equal(t, tc.expected, tc.board.Evaluate())
  • replacement in snippets/tictactoe/evaluate.go at line 3
    [3.2826][2.146:178]()
    func (b Board) evaluate() int {
    [3.2826]
    [2.178]
    // Evaluate evaluates the Board for the minimax algorithm.
    func (b Board) Evaluate() int {