src/core/reinforcement/policy/executablepolicy/MCTSPolicy.java
public int act(Matrix policyValueMatrix, HashSet<Integer> availableActions, boolean alwaysGreedy) {
            updateActionProbabilities(policyValueMatrix, availableActions);
            maxAction = null;
            double maxValue = Double.NEGATIVE_INFINITY;
            if (alwaysGreedy) {
                for (Integer actionID : availableActions) {
                    Action action = actions.get(actionID);
                    double currentValue = action.getPolicyValue();
                    if (maxValue == Double.NEGATIVE_INFINITY || maxValue < currentValue) {
                        maxValue = currentValue;
                        maxAction = action;
                    }
                }
            }
            else {
                incrementVisitCount();
                HashMap<Integer, Double> dirichletDistribution = getDirichletDistribution(alpha, availableActions);
                for (Integer actionID : availableActions) {
                    Action action = actions.get(actionID);
                    double currentValue = action.getPUCT(dirichletDistribution.get(action.actionID), epsilon);
                    if (maxValue == Double.NEGATIVE_INFINITY || maxValue < currentValue) {
                        maxValue = currentValue;
                        maxAction = action;
                    }
                }
            }
            return (maxAction != null) ? maxAction.getActionID() : -1;
        }
/**
         * Takes action based on heuristic value. Adds noise to UCB value from Dirichlet distribution.
         *
         * @param policyValueMatrix current policy value matrix.
         * @param availableActions available actions in current state
         * @param alwaysGreedy if true greedy action is always taken.
         * @return action taken.
         */
Takes action based on heuristic value. Adds noise to UCB value from Dirichlet distribution.

@param policyValueMatrix current policy value matrix.
@param availableActions available actions in current state
@param alwaysGreedy if true greedy action is always taken.
@return action taken.
Takes action based on heuristic value . Adds noise to UCB value from Dirichlet distribution . @param policyValueMatrix current policy value matrix . @param availableActions available actions in current state @param alwaysGreedy if true greedy action is always taken . @return action taken .
public int act(Matrix policyValueMatrix, HashSet<Integer> availableActions, boolean alwaysGreedy) {
            updateActionProbabilities(policyValueMatrix, availableActions);
            maxAction = null;
            double maxValue = Double.NEGATIVE_INFINITY;
            if (alwaysGreedy) {
                for (Integer actionID : availableActions) {
                    Action action = actions.get(actionID);
                    double currentValue = action.getPolicyValue();
                    if (maxValue == Double.NEGATIVE_INFINITY || maxValue < currentValue) {
                        maxValue = currentValue;
                        maxAction = action;
                    }
                }
            }
            else {
                incrementVisitCount();
                HashMap<Integer, Double> dirichletDistribution = getDirichletDistribution(alpha, availableActions);
                for (Integer actionID : availableActions) {
                    Action action = actions.get(actionID);
                    double currentValue = action.getPUCT(dirichletDistribution.get(action.actionID), epsilon);
                    if (maxValue == Double.NEGATIVE_INFINITY || maxValue < currentValue) {
                        maxValue = currentValue;
                        maxAction = action;
                    }
                }
            }
            return (maxAction != null) ? maxAction.getActionID() : -1;
        }
public int act ( Matrix policyValueMatrix , HashSet < Integer > availableActions , boolean alwaysGreedy ) { updateActionProbabilities ( policyValueMatrix , availableActions ) ; maxAction = null ; double maxValue = Double . NEGATIVE_INFINITY ; if ( alwaysGreedy ) { for ( Integer actionID : availableActions ) { Action action = actions . get ( actionID ) ; double currentValue = action . getPolicyValue ( ) ; if ( maxValue == Double . NEGATIVE_INFINITY || maxValue < currentValue ) { maxValue = currentValue ; maxAction = action ; } } } else { incrementVisitCount ( ) ; HashMap < Integer , Double > dirichletDistribution = getDirichletDistribution ( alpha , availableActions ) ; for ( Integer actionID : availableActions ) { Action action = actions . get ( actionID ) ; double currentValue = action . getPUCT ( dirichletDistribution . get ( action . actionID ) , epsilon ) ; if ( maxValue == Double . NEGATIVE_INFINITY || maxValue < currentValue ) { maxValue = currentValue ; maxAction = action ; } } } return ( maxAction != null ) ? maxAction . getActionID ( ) : - 1 ; }
Takes action based on heuristic value.
Takes action based on heuristic value .