Package com.barrybecker4.game.common.board

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


        BoardPosition position = board.getPosition( loc );
        // if there is no piece or out of bounds, then return without doing anything
        if ( (position == null) || (position.isUnoccupied()) ) {
            return;
        }
        GamePiece piece = position.getPiece();
        if ( controller.isPlayer1sTurn() != piece.isOwnedByPlayer1() )
            return; // wrong players piece

        getRenderer().setDraggedPiece(position);
    }
View Full Code Here


        TwoPlayerMove m = (TwoPlayerMove)move;
        if ( !m.isPassOrResignation() ) {
            BoardPosition pos = getPosition(m.getToLocation());
            assert(m.getPiece() != null) : "move's piece was null :" + m;
            pos.setPiece(m.getPiece());
            GamePiece piece = pos.getPiece();
            assert (piece != null):
                    "The piece was " + piece + ". Moved to " + m.getToRow() + ", " + m.getToCol();
            if ( GameContext.getDebugMode() > 0 ) {
                piece.setAnnotation( Integer.toString(getMoveList().getNumMoves()) );
            }
        }
        return true;
    }
View Full Code Here

    protected Move createMoveFromToken( SGFToken token)
    {
        TwoPlayerMoveToken mvToken = (TwoPlayerMoveToken) token;
        boolean player1 = token instanceof Player1MoveToken;

        return TwoPlayerMove.createMove(mvToken.getToY(), mvToken.getToX(), 0, new GamePiece(player1));
    }
View Full Code Here

        for ( int row = 1; row <= board.getNumRows(); row++ ) {
            for ( int col = 1; col <= board.getNumCols(); col++ ) {
                BlockadeBoardPosition pos = board.getPosition( row, col );
                if ( pos.isOccupied() ) {
                    GamePiece piece = pos.getPiece();

                    // should reuse cached path if still valid.
                    PathList paths = board.findShortestPaths(pos);

                    playerPaths.getPathLengthsForPlayer(piece.isOwnedByPlayer1()).updatePathLengths(paths);
                }
            }
        }
        return playerPaths;
    }
View Full Code Here

        int baseOffset = Math.round(increment);
        for (int i=0; i<NUM_HOMES; i++) {
            int c = baseOffset + Math.round(i*increment);

            p1Homes_[i] = new BlockadeBoardPosition(new ByteLocation(homeRow1, c), null, null, null, true, false);
            p1Homes_[i].setPiece(new GamePiece(true));
            p2Homes_[i] = new BlockadeBoardPosition(new ByteLocation(homeRow2, c), null, null, null, false, true);
            p2Homes_[i].setPiece(new GamePiece(false));
        }
    }
View Full Code Here

             wall = new BlockadeWall(new BlockadeBoardPosition(mvToken.getWallPoint1().y, mvToken.getWallPoint1().x),
                                                       new BlockadeBoardPosition(mvToken.getWallPoint2().y, mvToken.getWallPoint2().x));

         return BlockadeMove.createMove(new ByteLocation(mvToken.getFromY(), mvToken.getFromX()),
                 new ByteLocation(mvToken.getToY(), mvToken.getToX()),
                 0, new GamePiece(player1), wall);
    }
View Full Code Here

        // if there is no piece, or out of bounds, then return without doing anything
        if ( (position == null) || (position.isUnoccupied()) ) {
            return;
        }
        GamePiece piece = position.getPiece();
        if ( viewer.get2PlayerController().isPlayer1sTurn() != piece.isOwnedByPlayer1() )
            return; // wrong players piece

        getRenderer().setDraggedPiece(position);
    }
View Full Code Here

      */
    private boolean checkForWin(boolean player1) {

        BoardPosition[] homes = getBoard().getPlayerHomes(!player1);
        for (BoardPosition home : homes) {
            GamePiece p = home.getPiece();
            if (p != null && p.isOwnedByPlayer1() == player1)
                return true;
        }
        return false;
    }
View Full Code Here

    /**
     * this draws the actual piece.
     */
    @Override
    public void render( Graphics2D g2, BoardPosition position, int cellSize, int margin, Board b) {
        GamePiece piece = position.getPiece();
        if (piece != null)  {
            // render the piece as normal
            super.render( g2, position, cellSize, margin, b);
        }
        // render the south and east walls if present
View Full Code Here

            else if (!forPlayer1 && pos.getScoreContribution() < 0)  {
                territoryEstimate -= val;  // will be positive
            }
        }
        else { // occupied
            GamePiece piece = pos.getPiece();
            IGoGroup group = pos.getGroup();
            assert(piece != null);
            if (group != null) {
                // add credit for probable captured stones.
                double relHealth = analyzerMap_.getAnalyzer(group).getRelativeHealth(board_, isEndOfGame);
                if (forPlayer1 && !piece.isOwnedByPlayer1() && relHealth >= 0) {
                    territoryEstimate += val;
                }
                else if (!forPlayer1 && piece.isOwnedByPlayer1() && relHealth <= 0)  {
                    territoryEstimate -= val;
                }
            }
        }
        return territoryEstimate;
View Full Code Here

TOP

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

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.