Examples of TwoPlayerMove


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

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

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

    }

    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

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

        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

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

        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.TwoPlayerMove

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

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

    @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

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

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

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

    public void computerMovesFirst() {
        int delta = getWinRunLength() - 1;
        Board b = (Board) getBoard();
        int c = (int) (GameContext.random().nextFloat() * (b.getNumCols() - 2 * delta) + delta + 1);
        int r = (int) (GameContext.random().nextFloat() * (b.getNumRows() - 2 * delta) + delta + 1);
        TwoPlayerMove m = TwoPlayerMove.createMove( r, c, 0, new GamePiece(true) );
        makeMove( m );
    }
View Full Code Here

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

        // out of bounds, then return without doing anything
        BoardPosition p = board.getPosition( loc);
        if ( (p == null) || !p.isUnoccupied() )
            return;

        TwoPlayerMove m =
            TwoPlayerMove.createMove( loc.getRow(), loc.getCol(), 0,
                                      new GamePiece(controller.isPlayer1sTurn()));

        viewer.continuePlay( m );
    }
View Full Code Here

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

        int nrows = pb.getNumRows();

        for (int i = 1; i <= ncols; i++ ) {
            for (int j = 1; j <= nrows; j++ ) {
                if ( pb.isCandidateMove( j, i )) {
                    TwoPlayerMove m;
                    if (lastMove == null)
                       m = TwoPlayerMove.createMove( j, i, 0, new GamePiece(player1));
                    else
                       m = TwoPlayerMove.createMove( j, i, lastMove.getValue(), new GamePiece(player1));
                    searchable_.makeInternalMove( m );
                    m.setValue(searchable_.worth( m, weights));
                    // now revert the board
                    searchable_.undoInternalMove( m );
                    moveList.add( m );
                }
            }
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.