예제 #1
0
    def test_victory_false_3(self):

        grid_shape = GRID_SHAPE
        board = np.full(grid_shape, NONE, dtype=np.int8)
        board[0, 3] = PLAYER_1
        game_state = GameState(grid_shape=grid_shape,
                               currentPlayer=PLAYER_1,
                               board=board)
        is_victory = game_state._isVictory(3, PLAYER_1)
        self.assertEqual(is_victory, False)
예제 #2
0
    def test_victory_true_2(self):
        """Victoires en colonne"""

        grid_shape = GRID_SHAPE

        for ligne in range(0, GRID_SHAPE[0] + 1 - NB_TOKENS_VICTORY):
            for column in range(0, GRID_SHAPE[1]):
                #On met toutes les façons d'aligner 4 PLAYER_1 dans la colonne column
                board = np.full(grid_shape, NONE, dtype=np.int8)
                board[ligne:ligne + NB_TOKENS_VICTORY, column] = PLAYER_1
                #On remplit les lignes sous ligne avec PLAYER_2
                board[0:ligne, :] = PLAYER_2
                game_state = GameState(grid_shape=grid_shape,
                                       currentPlayer=PLAYER_1,
                                       board=board)

                is_victory = game_state._isVictory(column, PLAYER_1)
                self.assertEqual(is_victory, True)
예제 #3
0
    def test_victory_true_3(self):
        """Victoires en diagonale 1 (bas gauche, haut droit)"""

        grid_shape = GRID_SHAPE

        for ligne in range(0, GRID_SHAPE[0] + 1 - NB_TOKENS_VICTORY):
            for column in range(0, GRID_SHAPE[1] + 1 - NB_TOKENS_VICTORY):
                #On aligne 4 PLAYER_1 dans la diagonale dont le point de départ (bas,gauche) est (ligne,column)
                board = np.full(grid_shape, NONE, dtype=np.int8)
                for i, j in zip(range(ligne, ligne + NB_TOKENS_VICTORY),
                                range(column, column + NB_TOKENS_VICTORY)):
                    board[i, j] = PLAYER_1
                    board[0:i, j] = PLAYER_2
                    board[i, j + 1:] = PLAYER_2
                #On remplit les lignes sous ligne avec PLAYER_2
                board[0:ligne, :] = PLAYER_2
                game_state = GameState(grid_shape=grid_shape,
                                       currentPlayer=PLAYER_1,
                                       board=board)

                for i in range(column, column + NB_TOKENS_VICTORY):
                    is_victory = game_state._isVictory(i, PLAYER_1)
                    self.assertEqual(is_victory, True)