Buggy code:
private short mostLikelyWinner = - 1 ; private short depth = - 1 ; short completionDepth ; private double heuristicValue ; private double heuristicWeight ; private short hyperExpansionDepth = 0 ; TreeNode ( MCTSTree xiTree , int xiPoolIndex ) { } public void setState ( ForwardDeadReckonInternalMachineState xiState ) { } public int getDepth ( ) { } public void setDepth ( short theDepth ) { } public short getCompletionDepth ( ) { } public void addParent ( TreeNode xiParent ) { } private boolean checkFixedSum ( double [ ] values ) { } private boolean checkFixedSum ( ) { } private void correctParentsForCompletion ( ) { } private void validateCompletionValues ( double [ ] values ) { } void markAsLocalLoss ( short atDepth , ForwardDeadReckonLegalMoveInfo withMove ) { } void markComplete ( double [ ] values , short atCompletionDepth ) { } public void markComplete ( TreeNode fromDeciderNode , short atCompletionDepth ) { } private void enactMarkComplete ( short atCompletionDepth ) { } void processCompletion ( ) { } public void freeChildren ( ) { } private boolean validateHasChild ( TreeNode child ) { } boolean validateHyperChain ( TreeEdge edge ) { } boolean linkageValid ( ) { } private void freeFromAncestor ( TreeNode ancestor , TreeNode xiKeep ) { } private boolean hasSiblings ( ) { } private boolean hasSiblinglessParents ( ) { } public boolean hasUnexpandedChoices ( ) { } private boolean allNephewsComplete ( ) { } private void checkSiblingCompletion ( ) { } private boolean isBestMoveInAllUncles ( Set < Move > moves , int roleIndex ) { } private TreeNode worstCompleteCousin ( Move move , int roleIndex ) { } @ SuppressWarnings ( "null" ) void checkChildCompletion ( boolean checkConsequentialSiblingCompletion ) { } public void reset ( MCTSTree xiTree ) { } TreeNode getChild ( short index ) { } TreeNode createChildIfNeccessary ( short index , ForwardDeadReckonLegalMoveInfo [ ] jointPartialMove , int choosingRoleIndex ) { } long getRef ( ) { } public double getAverageScore ( int roleIndex ) { } public void setAverageScore ( int roleIndex , double value ) { } public double getAverageSquaredScore ( int roleIndex ) { } public void setAverageSquaredScore ( int roleIndex , double value ) { } void validate ( boolean recursive ) { } private void markTreeForSweep ( TreeNode parent ) { } private void freeNode ( ) { } public void freeAllBut ( TreeNode descendant ) { } private void deleteEdge ( int xiChildIndex ) { } private void deleteHyperEdge ( int xiChildIndex ) { } public TreeNode findNode ( ForwardDeadReckonInternalMachineState targetState , int maxDepth ) { } public boolean disposeLeastLikelyNode ( ) { } private void unexpand ( ) { } private static int leastLikelyDisposalCount = 0 ; public TreeEdge selectLeastLikelyExpandedNode ( TreeEdge from ) { } private StateInfo calculateTerminalityAndAutoExpansion ( ForwardDeadReckonInternalMachineState theState ) { StateInfo result = StateInfo . bufferInstance ; result . isTerminal = false ; result . autoExpand = false ; if ( tree . underlyingStateMachine . scoresAreLatched ( theState ) ) { result . isTerminal = true ; for ( int i = 0 ; i < ( tree . numRoles ) ; i ++ ) { tree . underlyingStateMachine . getLatchedScoreRange ( theState , tree . roleOrdering . roleIndexToRole ( i ) , tree . latchedScoreRangeBuffer ) ; assert ( tree . latchedScoreRangeBuffer [ 0 ] ) == ( tree . latchedScoreRangeBuffer [ 1 ] ) ; result . terminalScore [ i ] = tree . latchedScoreRangeBuffer [ 0 ] ; } } else if ( tree . searchFilter . isFilteredTerminal ( theState ) ) { result . isTerminal = true ; for ( int i = 0 ; i < ( tree . numRoles ) ; i ++ ) { <START_BUG> result . terminalScore [ i ] = tree . underlyingStateMachine . getGoal ( tree . roleOrdering . roleIndexToRole ( i ) ) ; <END_BUG> } } if ( result . isTerminal ) { for ( int i = 0 ; i < ( tree . numRoles ) ; i ++ ) { double iScore = result . terminalScore [ i ] ; tree . bonusBuffer [ i ] = 0 ; for ( int j = 0 ; j < ( tree . numRoles ) ; j ++ ) { if ( j != i ) { double jScore = result . terminalScore [ j ] ; if ( iScore >= jScore ) { double bonus = tree . gameCharacteristics . getCompetitivenessBonus ( ) ; if ( iScore > jScore ) { bonus *= 2 ; } tree . bonusBuffer [ i ] += bonus ; } } } } for ( int i = 0 ; i < ( tree . numRoles ) ; i ++ ) { result . terminalScore [ i ] = ( ( ( result . terminalScore [ i ] ) + ( tree . bonusBuffer [ i ] ) ) * 100 ) // ( 100 + ( ( 2 * ( ( tree . numRoles ) - 1 ) ) * ( tree . gameCharacteristics . getCompetitivenessBonus ( ) ) ) ) ; } } return result ; } void createChildNodeForEdge ( TreeEdge edge , ForwardDeadReckonLegalMoveInfo [ ] jointPartialMove ) { } void createChildNodeForEdgeWithAssertedState ( TreeEdge edge , ForwardDeadReckonInternalMachineState newState , int extraDepthIncrement , boolean isPseudoNullMove ) { } private void considerPathToAsPlan ( ) { } public TreeNode expand ( TreePath fullPathTo , ForwardDeadReckonLegalMoveInfo [ ] jointPartialMove , int parentDepth ) { } public void hyperExpand ( TreePath fullPathTo , ForwardDeadReckonLegalMoveInfo [ ] jointPartialMove , short hyperDepth ) { } private TreeNode expandInternal ( TreePath fullPathTo , ForwardDeadReckonLegalMoveInfo [ ] jointPartialMove , int parentDepth , boolean isRecursiveExpansion , boolean stateChangedInForcedExpansion ) { } private void validateScoreVector ( double [ ] scores ) { } private double explorationUCT ( int effectiveTotalVisits , TreeEdge edge , int roleIndex ) { } private double getAverageCousinMoveValue ( TreeEdge relativeTo , int roleIndex ) { } private double getExplorationBias ( TreeEdge moveEdge ) { }

Fix:
result . terminalScore [ i ] = tree . underlyingStateMachine . getGoal ( theState , tree . roleOrdering . roleIndexToRole ( i ) ) ;