dengl11 / ChineseChessAI

AI Agent for Chinese Chess - CS 221 Project
https://dengl11.github.io/ChineseChessAI/
71 stars 33 forks source link

get_ordered_moves #1

Closed HongyiZ closed 6 years ago

HongyiZ commented 6 years ago

How does get_ordered_moves() in ABPruning achieve sorting by utility value? get_ordered_moves(agent: Agent) { return agent.get_moves_arr(); }


    get_moves_arr() {
        var moves = [];
        for (var movePieceName in this.legalMoves) { //legalMoves: {name: []}
            var toPosList = this.legalMoves[movePieceName];
            for (var i in toPosList) {
                var move = toPosList[i];
                moves.push([movePieceName, move]);
            }
        }
        return moves;
    }```
dengl11 commented 6 years ago

get_ordered_moves is an inherited method of Agent, and for ABPruning agent, there is no reordering of the moves, so it just uses the unordered moves. Because the point of ABPruning is alpha-beta pruning, not about reordering of moves.

The actually reordering of moves happens in MoveReorderPruner , which is the child class of ABPruning. By comparing ABPruning and MoveReorderPruner, we can see the effect of reordering of moves, which is improvement of MoveReorderPruner upon ABPruning.