On Jan 14, 2009, at 9:36 AM, Daniel Waeber wrote:

I have a question about the the part were the stats are updated.
(l.15-25). having an array of amaf-values in every node seems very memory
intensive and I don't get how you would access these values.

You are right, it is memory intensive. I believe this is one of the reasons that most implementations wait a certain number of playouts before creating the next level of nodes.

Accessing the AMAF values depends on your implementation. The following is a code-snippet from my MCTS reference implementation that updates the AMAF values in the tree:

                        if (_useAMAF)
                        {
                                IntStack playoutMoves = 
_searchAdministration.getMoveStack();
                                byte color = 
_monteCarloAdministration.getColorToMove();
                                int start = 
_monteCarloAdministration.getMoveStack().getSize();
                                int end = playoutMoves.getSize();
                                double weight = 1.0;
double weightDelta = 1.0 / (end - start + 1); // Michael Williams' idea to use decreasing weights
                                GoArray.clear(_weightMap);
                                GoArray.clear(_colorMap);
                                for (int i=start; i<end; i++)
                                {
                                        int moveXY = playoutMoves.get(i);
                                        if (_colorMap[moveXY]==0)
                                        {
                                                _colorMap[moveXY] = color;
                                                _weightMap[moveXY] = weight;
                                        }
                                        weight -= weightDelta;
                                        color = opposite(color);
                                }
                                
                                while (playoutNode!=null)
                                {
                                        color = 
opposite(playoutNode.getContent().getMove().getColor());
boolean playerWins = (blackWins && color==BLACK) || (!blackWins && color==WHITE); double score = playerWins ? MonteCarloTreeSearchResult.MAX_SCORE : MonteCarloTreeSearchResult.MIN_SCORE;
                                        for (int i=0; 
i<playoutNode.getChildCount(); i++)
                                        {
TreeNode<MonteCarloTreeSearchResult<MoveType>> nextNode = playoutNode.getChildAt(i); MonteCarloTreeSearchResult<MoveType> result = nextNode.getContent();
                                                GoMove move = (GoMove) 
result.getMove();
                                                int xy = move.getXY();
                                                if (_colorMap[xy]==color)
result.increaseVirtualPlayouts(_weightMap[xy]*score,_weightMap[xy]);
                                        }
                                        playoutNode = playoutNode.getParent();
                                }
                        }


playoutNode is the move-node from which the playout was done. The amaf values are stored in its children by the increaseVirtualPlayout() method. Note that it goes up the tree by assigning the parent to playoutNode until it gets to the root.

For more context it would be better to lookup the whole source at 
http://plug-and-go.dev.java.net
If you think some more comments in the code could clarify things better I'm open to suggestions.

Good luck.

    Mark

_______________________________________________
computer-go mailing list
computer-go@computer-go.org
http://www.computer-go.org/mailman/listinfo/computer-go/

Reply via email to