Korzystanie z minimaksowania w poszukiwaniu gier karcianych z niedoskonałymi informacjami

Chcę użyć wyszukiwania minimax (z przycinaniem alfa-beta) lub raczej wyszukiwania negamax, aby program komputerowy zagrał w grę karcianą.

Gra karciana składa się z 4 graczy. Aby móc korzystać z minimax itp., Upraszczam grę do „ja” przeciwko „innym”. Po każdym „ruchu” możesz obiektywnie odczytać ocenę bieżącego stanu z samej gry. Kiedy wszyscy czterej gracze umieścili kartę, najwyższa wygrywa wszystkie - a wartości kart się liczą.

Ponieważ nie wiesz, jak dokładnie rozkłada się karty między pozostałymi 3 graczami, pomyślałem, że musisz symulować wszystkie możliwe dystrybucje („światy”) kartami, które nie są twoje. Masz 12 kart, pozostałych 3 graczy ma łącznie 36 kart.

Więc moim podejściem jest ten algorytm, gdzieplayer to liczba od 1 do 3 symbolizująca trzech graczy komputerowych, których program może potrzebować, aby znaleźć ruchy. I-player oznacza przeciwników, a mianowicie wszystkich pozostałych trzech graczy razem.

private Card computerPickCard(GameState state, ArrayList<Card> cards) {
    int bestScore = Integer.MIN_VALUE;
    Card bestMove = null;
    int nCards = cards.size();
    for (int i = 0; i < nCards; i++) {
        if (state.moveIsLegal(cards.get(i))) { // if you are allowed to place this card
            int score;
            GameState futureState = state.testMove(cards.get(i)); // a move is the placing of a card (which returns a new game state)
            score = negamaxSearch(-state.getPlayersTurn(), futureState, 1, Integer.MIN_VALUE, Integer.MAX_VALUE);
            if (score > bestScore) {
                bestScore = score;
                bestMove = cards.get(i);
            }
        }
    }
    // now bestMove is the card to place
}

private int negamaxSearch(int player, GameState state, int depthLeft, int alpha, int beta) {
    ArrayList<Card> cards;
    if (player >= 1 && player <= 3) {
        cards = state.getCards(player);
    }
    else {
        if (player == -1) {
            cards = state.getCards(0);
            cards.addAll(state.getCards(2));
            cards.addAll(state.getCards(3));
        }
        else if (player == -2) {
            cards = state.getCards(0);
            cards.addAll(state.getCards(1));
            cards.addAll(state.getCards(3));
        }
        else {
            cards = state.getCards(0);
            cards.addAll(state.getCards(1));
            cards.addAll(state.getCards(2));
        }
    }
    if (depthLeft <= 0 || state.isEnd()) { // end of recursion as the game is finished or max depth is reached
        if (player >= 1 && player <= 3) {
            return state.getCurrentPoints(player); // player's points as a positive value (for self)
        }
        else {
            return -state.getCurrentPoints(-player); // player's points as a negative value (for others)
        }
    }
    else {
        int score;
        int nCards = cards.size();
        if (player > 0) { // make one move (it's player's turn)
            for (int i = 0; i < nCards; i++) {
                GameState futureState = state.testMove(cards.get(i));
                if (futureState != null) { // wenn Zug gültig ist
                    score = negamaxSuche(-player, futureState, depthLeft-1, -beta, -alpha);
                    if (score >= beta) {
                        return score;
                    }
                    if (score > alpha) {
                        alpha = score; // alpha acts like max
                    }
                }
            }
            return alpha;
        }
        else { // make three moves (it's the others' turn)
            for (int i = 0; i < nCards; i++) {
                GameState futureState = state.testMove(cards.get(i));
                if (futureState != null) { // if move is valid
                    for (int k = 0; k < nCards; k++) {
                        if (k != i) {
                            GameState futureStateLevel2 = futureState.testMove(cards.get(k));
                            if (futureStateLevel2 != null) { // if move is valid
                                for (int m = 0; m < nCards; m++) {
                                    if (m != i && m != k) {
                                        GameState futureStateLevel3 = futureStateLevel2.testMove(cards.get(m));
                                        if (futureStateLevel3 != null) { // if move is valid
                                            score = negamaxSuche(-player, futureStateLevel3, depthLeft-1, -beta, -alpha);
                                            if (score >= beta) {
                                                return score;
                                            }
                                            if (score > alpha) {
                                                alpha = score; // alpha acts like max
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return alpha;
        }
    }
}

Wydaje się, że działa dobrze, ale dla głębokości 1 (depthLeft=1) program musi już obliczyć średnio 50 000 ruchów (umieszczonych kart). To oczywiście za dużo!

Moje pytania to:

Czy implementacja jest w ogóle poprawna? Czy możesz symulować taką grę? Szczególnie w odniesieniu do niedoskonałych informacji?Jak można poprawić algorytm pod względem szybkości i obciążenia pracą?Czy mogę na przykład zmniejszyć zestaw możliwych ruchów do losowego zestawu 50%, aby poprawić szybkość, zachowując dobre wyniki?znalazłemAlgorytm UCT być dobrym rozwiązaniem (być może). Czy znasz ten algorytm? Czy możesz pomóc mi go wdrożyć?

questionAnswers(2)

yourAnswerToTheQuestion