Package com.barrybecker4.game.twoplayer.common.search.tree

Examples of com.barrybecker4.game.twoplayer.common.search.tree.SearchTreeNode


        return rootCopy;
    }

    /** @return a copy of the subtree rooted at root */
    private SearchTreeNode getSubtreeCopy(SearchTreeNode root) {
        SearchTreeNode rootCopy = (SearchTreeNode) root.clone();
        Enumeration enumeration = root.children();
        while (enumeration.hasMoreElements())  {
            SearchTreeNode child = (SearchTreeNode) enumeration.nextElement();
            rootCopy.add(getSubtreeCopy(child));   // recurse
        }
        return rootCopy;
    }
View Full Code Here


            if (pauseInterrupted())
                return lastMove;
            updatePercentDone(depth, list);

            searchable.makeInternalMove( theMove );
            SearchTreeNode child = addNodeToTree(parent, theMove, window );

            // search with minimal search window
            selectedMove = searchInternal( theMove, depth-1, new SearchWindow(-newBeta, -window.alpha), child);
            searchable.undoInternalMove( theMove );
View Full Code Here

            if (pauseInterrupted())
                return lastMove;
            updatePercentDone(depth, list);

            searchable.makeInternalMove( theMove );
            SearchTreeNode child = addNodeToTree(parent, theMove, window );

            // search with minimal search window
            selectedMove = searchInternal( theMove, depth-1, new SearchWindow(-newBeta, -window.alpha), child );

            searchable.undoInternalMove( theMove );
View Full Code Here

            if (pauseInterrupted())
                return lastMove;
            updatePercentDone(depth, list);

            searchable.makeInternalMove( theMove );
            SearchTreeNode child = addNodeToTree(parent, theMove, window); i++;

            selectedMove = searchInternal( theMove, depth-1, window.negateAndSwap(), child );

            searchable.undoInternalMove( theMove );
View Full Code Here

        getProfiler().startProfiling();

        strategy_ = getSearchOptions().getSearchStrategy(this, weights);

        SearchTreeNode root = null;
        if (treeViewer != null) {
            strategy_.setGameTreeEventListener(treeViewer);
            root = treeViewer.getRootNode();
        }
View Full Code Here

            TwoPlayerMove theMove = getNextMove(list);
            updatePercentDone(depth, list);

            searchable.makeInternalMove( theMove );
            SearchTreeNode child = addNodeToTree(parent, theMove, window); i++;

            // recursive call
            selectedMove = searchInternal( theMove, depth-1, window.copy(), child );

            searchable.undoInternalMove( theMove );
View Full Code Here

            if (pauseInterrupted())
                return lastMove;
            updatePercentDone(depth, list);

            searchable.makeInternalMove( theMove );
            SearchTreeNode child = addNodeToTree(parent, theMove, window); i++;

            selectedMove = searchInternal( theMove, depth-1,
                     new SearchWindow(-window.beta, -Math.max(window.alpha, bestInheritedValue)), child );

            searchable.undoInternalMove( theMove );
View Full Code Here

               nextNode = uctSelect(lastMoveNode);
            }

            // may be null if there are no move valid moves or lastMoveNode won the game.
            if (nextNode != null) {
                SearchTreeNode nextParent = parent!=null ? parent.findChild(nextNode.move) : null;
                searchable.makeInternalMove(nextNode.move);
                player1Score = playSimulation(nextNode, nextParent);
                searchable.undoInternalMove(nextNode.move);
            } else {
                player1Score = WinProbabilityCaclulator.getChanceOfPlayer1Winning(lastMoveNode.move.getValue());
View Full Code Here

     * @param attributes arbitrary name value pairs to display for the new node in the tree.
     * @return the node added to the tree.
     */
    protected SearchTreeNode addNodeToTree( SearchTreeNode parent, TwoPlayerMove theMove,
                                            NodeAttributes attributes) {
        SearchTreeNode child = null;
        if (gameTree_ != null) {
            child = new SearchTreeNode(theMove, attributes);
            gameTree_.addNode(parent, child);
        }
        return child;
    }
View Full Code Here

        TreePath path = tree.getPathForRow( row );
        treeViewer_.highlightPath( path );

        int chainLength = path.getPathCount();
        Object[] nodes = path.getPath();
        SearchTreeNode lastNode = (SearchTreeNode)nodes[chainLength-1];
        List<TwoPlayerMove> moveList = new LinkedList<TwoPlayerMove>();
        TwoPlayerMove m = null;
        for ( int i = 0; i < chainLength; i++ ) {
            SearchTreeNode node = (SearchTreeNode) nodes[i];
            m = (TwoPlayerMove) node.getUserObject();
            if ( m == null )
                return; // no node here
            moveList.add( m );
        }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.twoplayer.common.search.tree.SearchTreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.