Examples of SearchTreeNode


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

            return;
        }

        Enumeration it = node.children();
        while (it.hasMoreElements()) {
            SearchTreeNode child = (SearchTreeNode)it.nextElement();
            initializeTreeStats( child, depth+1 );
            node.setSpaceAllocation(node.getSpaceAllocation() + child.getSpaceAllocation());
        }
        // count the node as a descendant
        node.setSpaceAllocation(node.getSpaceAllocation() + 1);
        totalAtLevel_[depth] += node.getSpaceAllocation();
    }
View Full Code Here

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

        oldHighlightPath_ = path;
    }

    private void highlight( TreePath path, Graphics2D g2) {
        Object[] pathNodes = path.getPath();
        SearchTreeNode lastNode = (SearchTreeNode)pathNodes[0];
        int diameter = HL_NODE_DIAMETER;
        Point lastLoc = lastNode.getPosition();
        g2.drawOval(lastLoc.x - HL_NODE_RADIUS, lastLoc.y - HL_NODE_RADIUS, diameter, diameter);
        for (int i=1; i<pathNodes.length; i++) {
            SearchTreeNode node = (SearchTreeNode)pathNodes[i];
            TwoPlayerMove m = (TwoPlayerMove)node.getUserObject();
            g2.setColor(colormap_.getColorForValue(m.getInheritedValue()));

            Point nodeLoc = node.getPosition();
            g2.drawLine(lastLoc.x, lastLoc.y, nodeLoc.x,nodeLoc.y);
            g2.setColor(colormap_.getColorForValue(m.getValue()));
            g2.drawOval(nodeLoc.x-HL_NODE_RADIUS, nodeLoc.y-HL_NODE_RADIUS, diameter, diameter);
            lastLoc = nodeLoc;
        }
View Full Code Here

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

        drawNode(root, 0, 0, g2);
        List<SearchTreeNode> q = new LinkedList<SearchTreeNode>();
        q.add(root);

        while (q.size() > 0) {
            SearchTreeNode p = q.remove(0);
            numNodes++;
            depth = p.getLevel();
            // draw the arc and child root for each child c of p
            if (depth > oldDepth) {
                oldDepth = depth;
                offsetAtLevel[depth] = 0;
            }
            Enumeration enumeration = p.children();
            while (enumeration.hasMoreElements()) {
                SearchTreeNode c = (SearchTreeNode)enumeration.nextElement();
                drawArc(p, c, depth, offsetAtLevel[depth], offsetAtLevel[depth+1], g2);
                drawNode(c, depth+1, offsetAtLevel[depth+1], g2);
                offsetAtLevel[depth+1] += c.getSpaceAllocation();
                q.add(c);
            }
            offsetAtLevel[depth] += p.getSpaceAllocation();
        }
        return numNodes;
View Full Code Here

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

    /**
     * constructor - create the tree dialog.
     */
    public GameTreeViewable(TwoPlayerMove m) {
        root_ = new SearchTreeNode(m, new NodeAttributes());
    }
View Full Code Here

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

    /**
     * @return the root node of a deeply copied tree (se we do not need to worry about it changing.
     */
    public SearchTreeNode getTreeCopy() {
        SearchTreeNode rootCopy;
        synchronized (root_) {
            rootCopy = getSubtreeCopy(root_);
        }
        return rootCopy;
    }
View Full Code Here

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

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

            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

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

            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

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

            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

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

        getProfiler().startProfiling();

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

        SearchTreeNode root = null;
        if (treeViewer != null) {
            strategy_.setGameTreeEventListener(treeViewer);
            root = treeViewer.getRootNode();
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.