def testNonWins(self): for non_win in self.non_wins: for playerId in range(2): b = GameBoard() for move in non_win: # move player b.makeMove(move, playerId) # move opponent for cell in b.getEmptyCells(): if cell not in non_win: b.makeMove(cell, range(2)[playerId-1]) break self.assertEqual(False, b.checkForWin(playerId)) # test opponent non-wins for non_win in self.non_wins: for playerId in range(2): b = GameBoard() for move in non_win: # move player for cell in b.getEmptyCells(): if cell not in non_win: b.makeMove(cell, playerId) break # move opponent b.makeMove(move, range(2)[playerId-1]) self.assertEqual(False, b.checkForWin(range(2)[playerId-1]))
def testDefaultWins(self): for win in self.wins: for playerId in range(2): b = GameBoard() for move in win: # move player b.makeMove(move, playerId) # move opponent for cell in b.getEmptyCells(): if cell not in win: b.makeMove(cell, range(2)[playerId-1]) break self.assertEqual(True, b.checkForWin(playerId)) # test opponent wins for win in self.wins: for playerId in range(2): b = GameBoard() for move in win: # move player for cell in b.getEmptyCells(): if cell not in win: b.makeMove(cell, playerId) break # move opponenet b.makeMove(move, range(2)[playerId-1]) self.assertEqual(True, b.checkForWin(range(2)[playerId-1]))