Package com.barrybecker4.game.twoplayer.common

Examples of com.barrybecker4.game.twoplayer.common.TwoPlayerMove


     * @param attributes list of name values to show.
     */
    public void addPrunedChildNodes( List list, int i, NodeAttributes attributes) {
        int index = i;
        while ( !list.isEmpty() ) {
            TwoPlayerMove theMove = (TwoPlayerMove) (list.remove(0));
            SearchTreeNode child = new SearchTreeNode( theMove, attributes );
            this.insert( child, index );
            index++;
        }
    }
View Full Code Here


        if (children == null) return null;
        Enumeration enumeration = children();

        while (enumeration.hasMoreElements()) {
            SearchTreeNode node = (SearchTreeNode)enumeration.nextElement();
            TwoPlayerMove m = (TwoPlayerMove)node.getUserObject();
            if (m.isSelected())
                return node;
        }
        return null;
    }
View Full Code Here

        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
View Full Code Here

     */
    private static List<TwoPlayerMove> addSuccessiveMoves(List<TwoPlayerMove> moveList, SearchTreeNode finalNode) {

        SearchTreeNode nextNode = finalNode.getExpectedNextNode();
        while (nextNode !=  null)  {
            TwoPlayerMove m = (TwoPlayerMove)((Move)nextNode.getUserObject()).copy();
            m.setFuture(true);
            moveList.add(m);
            nextNode = nextNode.getExpectedNextNode();
        }
        return moveList;
    }
View Full Code Here

    }

    private static Color getFGColor( Object value ) {

        SearchTreeNode node = (SearchTreeNode) value;
        TwoPlayerMove m = (TwoPlayerMove) node.getUserObject();
        if ( m == null )
            return Color.gray;

        if ( m.isSelected() )
            return SELECTED_COLOR;

        return Color.black;
    }
View Full Code Here

        Color c;
        SearchTreeNode node = (SearchTreeNode) value;
        int numChildren = node.getChildCount();
        setText( getText() + " kids=" + numChildren );
        TwoPlayerMove m = (TwoPlayerMove) node.getUserObject();
        if ( m == null ) return Color.gray;    // passing move?

        if (colormap_ != null) {
            c = colormap_.getColorForValue(m.getInheritedValue());
        }
        else {
            int val = (int) (2.0 * Math.sqrt( Math.abs( m.getInheritedValue() ) ));
            if ( m.getInheritedValue() < 0 )
                val = -val;
            int v1 = 255 - Math.min( Math.max( val, 0 ), 255 );
            int v2 = 255 - Math.min( Math.max( -val, 0 ), 255 );
            int v3 = 255;
            c = new Color( v1, v2, v3 );
View Full Code Here

        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

    /**
     * Draw one of the game tree nodes
     */
    private synchronized void drawNode( SearchTreeNode node, int depth, int offset, Graphics2D g2) {
        TwoPlayerMove m = (TwoPlayerMove)node.getUserObject();
        g2.setColor( colormap_.getColorForValue(m.getValue()));
        int x = MARGIN + (int) (width_ * (offset + node.getSpaceAllocation() / 2.0) / totalAtLevel_[depth]);
        int y = MARGIN + depth*levelHeight_;
        node.setLocation(x, y);

        int width = 2;
        if (m.isSelected()) {
            width = 3;
            g2.fillRect(x, y, width, 3);
        }
        else {
            g2.fillRect(x, y, width, 3);
View Full Code Here

    @Override
    public void paint(Graphics g) {
        drawCellBackground(g);

        Graphics2D g2 = (Graphics2D) g;
        TwoPlayerMove move = (TwoPlayerMove) node_.getUserObject();
        if (move == null) {
            return;
        }

        drawStoneIcon(move.isPlayer1(), g2);
        drawMoveText(move, g2);
    }
View Full Code Here

    /**
     *  For pente, undoing a move is just changing that space back to a blank.
     */
    @Override
    protected void undoInternalMove( Move move ) {
        TwoPlayerMove m = (TwoPlayerMove)move;
        getPosition(m.getToRow(), m.getToCol()).clear();
    }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.twoplayer.common.TwoPlayerMove

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.