Package com.barrybecker4.game.common.board

Examples of com.barrybecker4.game.common.board.BoardPosition


        return Math.pow(base, value / scale);
    }

    @Override
    public Range getDomain() {
        return new Range(0, Double.MAX_VALUE);
    }
View Full Code Here


        return (value - offset) / scale;
    }

    @Override
    public Range getDomain() {
        return new Range(Double.MIN_VALUE, Double.MAX_VALUE);
    }
View Full Code Here

    /**
     * Constructor.
     */
    public ErrorFunction() {
        interpolator = new LinearInterpolator(ERROR_FUNCTION);
        inverseInterpolator = new LinearInterpolator(INVERSE_ERROR_FUNCTION);
    }
View Full Code Here

     */
    protected boolean processToken(SGFToken token, MoveList moveList) {

        boolean found = false;
        if (token instanceof PlacementToken ) {
            Move move = createMoveFromToken( token );
            GameContext.log(2, "creating move="+ move);
            moveList.add( move );
            found = true;
        } else {
            GameContext.log(0, "ignoring token "+token.getClass().getName());
View Full Code Here

     */
    protected void restoreGame( SGFGame game )
    {
        parseSGFGameInfo(game);

        MoveList moveSequence = new MoveList();
        extractMoveList( game.getTree(), moveSequence );
        GameContext.log( 1, "move sequence= " + moveSequence );
        controller_.reset();

        for (Move m : moveSequence) {
View Full Code Here

     * This renders the current state of the Board to the screen.
     */
    public void render(Graphics g, Player currentPlayer, PlayerList players,
                       IBoard board, int panelWidth, int panelHeight ) {

        Board b = (Board)board;
        cellSize = calcCellSize( b, panelWidth, panelHeight );

        if ( draggedShowPiece_!=null) {
            draggedShowPiece_.getPiece().setTransparency( DRAG_TRANSPARENCY );
        }

        Graphics2D g2 = (Graphics2D)g;

        int gridOffset = 0;
        int start = 0;
        int nrows = b.getNumRows();
        int ncols = b.getNumCols();
        int nrows1 = nrows;
        int ncols1 = ncols;
        // if the grid is offset, it means the pieces will be shown at the vertices.
        if ( offsetGrid() ) {
            gridOffset = cellSize >> 1;
View Full Code Here

     * fill a row with pieces during setup.
     */
    private void fillRow( int row, int odd, boolean player1 ) {

        for ( int j = 1; j <= SIZE/2; j++ )
            setPosition(new BoardPosition(row, (TWO * j - odd),
                                          new CheckersPiece(player1, CheckersPiece.REGULAR_PIECE)));
    }
View Full Code Here

     */
    @Override
    protected void undoInternalMove( Move move ) {

        CheckersMove m = (CheckersMove) move;
        BoardPosition startPos = getPosition(m.getFromRow(), m.getFromCol());

        startPos.setPiece( m.getPiece().copy() );
        if ( m.kinged ) {
            // then it was just kinged and we need to undo it
            startPos.setPiece(new CheckersPiece(m.isPlayer1(), CheckersPiece.REGULAR_PIECE));
        }
        // restore the captured pieces to the board
        m.restoreCaptures( this );

        getPosition(m.getToRow(), m.getToCol()).clear();
View Full Code Here

        // add all the moves that it can make.
        for ( row = 1; row <= CheckersBoard.SIZE; row++ ) {
            int odd = row % 2;
            for ( j = 1; j <= CheckersBoard.SIZE/2; j++ ) {
                col = 2 * j - odd;
                BoardPosition p = board_.getPosition( row, col );
                if ( p.isOccupied() && p.getPiece().isOwnedByPlayer1() == player1 ) {
                    addMoves(p, lastMove, moveList);
                }
            }
        }
        return moveList;
View Full Code Here

     * @param pos the piece to check
     * @return the number of moves added
     */
    private int addMovesForDirection( BoardPosition pos,
                                      int rowInc, int colInc, TwoPlayerMove lastMove, MoveList moveList) {
        BoardPosition next = board_.getPosition( pos.getRow() + rowInc, pos.getCol() + colInc );
        if (next!=null)
        {
            if (next.isUnoccupied()) {
                addSimpleMove(pos, rowInc, colInc, lastMove, moveList);
                // only one move added
                return 1;
            }
            // if just a simple move was not possible, we check for jump(s)
            BoardPosition beyondNext = board_.getPosition( pos.getRow() + 2 * rowInc, pos.getCol() + 2 * colInc );
            if (next.isOccupied() &&
                (next.getPiece().isOwnedByPlayer1() != pos.getPiece().isOwnedByPlayer1()) &&
                 beyondNext!=null && beyondNext.isUnoccupied()) {
                return addJumpMoves(pos, rowInc, lastMove, next, beyondNext, moveList);
            }
        }
        return 0; // no moves added
    }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.common.board.BoardPosition

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.