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

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


     * The dialog needs the user to dismiss it when done.
     * It is not shown if all computer players.
     * @param battle  the battle to show in a separate dialog
     */
    private void showBattle(BattleSimulation battle) {
        BattleDialog bDlg = new BattleDialog(parent_, battle, this);
        //bDlg.setLocationRelativeTo(this);

        Point p = this.getParent().getLocationOnScreen();
        // offset the dlg so the Galaxy grid is visible as a reference.
        bDlg.setLocation((int) (p.getX() + getParent().getWidth()),
                         (int) (p.getY() + 0.65 * getParent().getHeight()));
        bDlg.setModal(true);
        bDlg.setVisible(true);
    }
View Full Code Here


    }

    @Override
    protected NewGameDialog createNewGameDialog(Component parent, GameViewModel viewer )
    {
        return new GalacticNewGameDialog( parent, viewer );
    }
View Full Code Here

    }

    @Override
    protected GameOptionsDialog createOptionsDialog(Component parent, GameController controller )
    {
        return new GalacticOptionsDialog( parent, controller );
    }
View Full Code Here

     * display a dialog at the end of the game showing who won and other relevant
     * game specific information.
     */
    @Override
    public void showWinnerDialog() {
        GalacticTallyDialog tallyDialog = new GalacticTallyDialog(parent_, (GalacticController)controller_);
        tallyDialog.showDialog();
    }
View Full Code Here

     */
    private void showOrdersDialog(GalacticController gc) {

        GalacticPlayer currentPlayer = (GalacticPlayer)gc.getCurrentPlayer();

        OrdersDialog ordersDialog =
                new OrdersDialog(null, currentPlayer, gc.getNumberOfYearsRemaining());
        Point p = getParent().getLocationOnScreen();

        // offset the dlg so the Galaxy grid is visible as a reference
        ordersDialog.setLocation((int)(p.getX()+0.7*getParent().getWidth()), (int)(p.getY()+getParent().getHeight()/3.0));

        boolean canceled = ordersDialog.showDialog();
        if ( !canceled ) { // newGame a game with the newly defined options
            currentPlayer.setOrders( ordersDialog.getOrders() );
            gc.advanceToNextPlayer();
        }
    }
View Full Code Here

            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

        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

        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

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

    /**
     * @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

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.