Ejemplo n.º 1
0
 def test_generatePossibleMoves_2blackpiecesOnFirstTurn(self):
     black = Pieces.Black()
     board = {1: black, 2: black}
     possibleBoard1 = {5: black, 2: black}
     possibleBoard2 = {6: black, 2: black}
     possibleBoard3 = {1: black, 6: black}
     possibleBoard4 = {1: black, 7: black}
     self.assertEqual(Checkers.generatePossibleMoves(board, 1), [possibleBoard1, possibleBoard2, possibleBoard3, possibleBoard4])
Ejemplo n.º 2
0
 def test_generatePossibleMoves_rightJumpsFor1BlackPieceAnd1RedPieceOnFirstTurn(self):
     black = Pieces.Black()
     board = {1: black, 6: self.red}
     self.assertEqual(Checkers.generatePossibleMoves(board, 1), [{10: black}])
Ejemplo n.º 3
0
 def test_generatePossibleMoves_rightMovesFor1BlackPieceAnd1RedPieceOnSecondTurn(self):
     black = Pieces.Black()
     board = {1: black, 29: self.red}
     self.assertEqual(Checkers.generatePossibleMoves(board, 2), [{1: black, 25: self.red}])
Ejemplo n.º 4
0
 def test_generatePossibleMoves_rightMovesFor1BlackPieceOnSecondTurn(self):
     black = Pieces.Black()
     board = {1: black}
     self.assertEqual(Checkers.generatePossibleMoves(board, 2), [])
Ejemplo n.º 5
0
 def test_generatePossibleMoves_rightMovesFor1BlackPieceOnFirstTurn(self):
     black = Pieces.Black()
     board = {1: black}
     self.assertEqual(Checkers.generatePossibleMoves(board, 1), [{5: black}, {6: black}])
Ejemplo n.º 6
0
 def test_generatePossibleMoves_twoPossibleJumps(self):
     black = Pieces.Black()
     board = {1: black, 6: self.red, 14: self.red, 15: self.red}
     expectedBoard = [{15: self.red, 17: black}, {14: self.red, 19: black}]
     self.assertEqual(Checkers.generatePossibleMoves(board, 1), expectedBoard)
Ejemplo n.º 7
0
 def test_generatePossibleMoves_rightJumpsFor1BlackPieceAnd1RedPieceOnSecondTurn(self):
     black = Pieces.Black()
     board = {1: black, 6: self.red}
     expectedBoard = [{1: black, 2: Pieces.RedKing()}]
     self.assertEqual(Checkers.generatePossibleMoves(board, 2), expectedBoard)
Ejemplo n.º 8
0
def makeMove(board, weights, whoseTurn):
    moves = Checkers.generatePossibleMoves(board, whoseTurn)
    moveValues = {move: assignValue(move, weights) for move in moves}
    bestMoves = getKeysWithHighestValue(moveValues)
    bestMove = random.choice(bestMoves)
    return bestMove