Использование минимаксного поиска для карточных игр с несовершенной информацией

Я хочу использовать минимаксный поиск (с отсечкой альфа-бета) или, скорее, поиск negamax, чтобы компьютерная программа играла в карточную игру.

Карточная игра на самом деле состоит из 4 игроков. Таким образом, чтобы иметь возможность использовать минимакс и т. Д., Я упрощаю игру до «меня». против "других". После каждого "перемещения" вы можете объективно считывать оценку текущего состояния из самой игры. Когда все 4 игрока поместили карту, самый высокий выигрывает их всех - и карты & apos; значения рассчитываются.

Поскольку вы не знаете, как точно распределены карты между тремя другими игроками, я подумал, что вы должны смоделировать все возможные распределения ("миры") с картами, которые не принадлежат вам. У вас есть 12 карт, у остальных 3 игроков всего 36 карт.

Так что мой подход заключается в этом алгоритме, гдеplayer это число от 1 до 3, обозначающее трех компьютерных игроков, для которых программе может понадобиться найти ходы. А также-player выступает за противников, а именно всех трех других игроков вместе.

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;
        }
    }
}

Вроде нормально работает, но на глубину 1 (depthLeft=1), программе уже нужно рассчитать в среднем 50 000 ходов (размещенных карт). Это слишком много, конечно!

Итак, мои вопросы:

Is the implementation correct at all? Can you simulate a game like this? Regarding the imperfect information, especially? How can you improve the algorithm in speed and work load? Can I, for example, reduce the set of possible moves to a random set of 50% to improve speed, while keeping good results? I found UCT algorithm to be a good solution (maybe). Do you know this algorithm? Can you help me implementing it?

Ответы на вопрос(2)

Ваш ответ на вопрос