Package com.barrybecker4.game.common.board

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


     */
    @Override
    protected void undoInternalMove( Move move ) {
        getProfiler().startUndoMove();
        BlockadeMove m = (BlockadeMove) move;
        BoardPosition startPos = getPosition(m.getFromRow(), m.getFromCol());
        startPos.setPiece( m.getPiece() );
        BlockadeBoardPosition toPos = getPosition(m.getToLocation());
        toPos.clear();
        if (m.capturedOpponentPawn != null) {
            toPos.setPiece(m.capturedOpponentPawn);
            m.capturedOpponentPawn = null;
View Full Code Here


    public String getToolTipText( MouseEvent e ) {
        Location loc = getBoardRenderer().createLocation(e);
        StringBuilder sb = new StringBuilder( "<html><font=-3>" );

        if (controller_.getBoard() != null) {
            BoardPosition space = ((IRectangularBoard)controller_.getBoard()).getPosition(loc);
            if ( space != null && space.isOccupied() && GameContext.getDebugMode() >= 0 ) {
                sb.append("<br>");
                sb.append( loc );
            }
            sb.append( "</font></html>" );
        }
View Full Code Here

    {
        GoBoardPosition diagPos = (GoBoardPosition)board_.getPosition( r + rowOffset, c + colOffset );
        if (diagPos == null || diagPos.isUnoccupied() || diagPos.getPiece().isOwnedByPlayer1() == groupP1 )
            return false;

        BoardPosition pos1 = board_.getPosition( r + rowOffset, c );
        BoardPosition pos2 = board_.getPosition( r, c + colOffset );

        return (pos1.isOccupied() && (pos1.getPiece().isOwnedByPlayer1() == groupP1) &&
                pos2.isOccupied() && (pos2.getPiece().isOwnedByPlayer1() == groupP1) &&
                groupAnalyzer_.isTrueEnemy(diagPos));
    }
View Full Code Here

        boolean player1 = stone.isOwnedByPlayer1();

        if ( !board_.inBounds( r + incr, c + incc ) ) {
            return 0;
        }
        BoardPosition adjacent1 = board_.getPosition( r + incr, c );
        BoardPosition adjacent2 = board_.getPosition( r , c + incc);
        BoardPosition diagonal = board_.getPosition( r + incr, c + incc);

        int severityScore = 0;

        if (adjacent1.isOccupied() && adjacent2.isOccupied())  {
            if (   adjacent1.getPiece().isOwnedByPlayer1() == player1
                && adjacent2.getPiece().isOwnedByPlayer1() == player1)
                severityScore += getBadShapeAux(diagonal, player1);
        }

        if (adjacent1.isOccupied() && diagonal.isOccupied())  {
            if (   adjacent1.getPiece().isOwnedByPlayer1() == player1
                && diagonal.getPiece().isOwnedByPlayer1() == player1)
                severityScore += getBadShapeAux(adjacent2, player1);
        }

        if (adjacent2.isOccupied() && diagonal.isOccupied())  {
            if (   adjacent2.getPiece().isOwnedByPlayer1() == player1
                && diagonal.getPiece().isOwnedByPlayer1() == player1)
                severityScore += getBadShapeAux(adjacent1, player1);
        }
        return severityScore;
    }
View Full Code Here

            return 0;
        }
        // determine the side we are checking for (one or the other)
        boolean sideTest = sameSideOnly ? friendPlayer1 : !friendPlayer1;
        if ( (nbr.getPiece().isOwnedByPlayer1() == sideTest) && !nbr.isVisited()) {
            BoardPosition diag1 = board_.getPosition(r + rowOffset, c);
            BoardPosition diag2 = board_.getPosition(r, c + colOffset);
            if (!isDiagonalCut(diag1, diag2, sideTest) )  {
                stack.add( 0, nbr );
                return 1;
            }
        }
View Full Code Here

        // don't add it if it is in atari
        //if (nbr.isInAtari(board_))
        //    return 0;
        if ( nbr.isOccupied() &&
            (!samePlayerOnly || nbr.getPiece().isOwnedByPlayer1() == friendPlayer1) && !nbr.isVisited() ) {
            BoardPosition oneSpacePt;
            if ( rowOffset == 0 ) {
                int col = c + (colOffset >> 1);
                oneSpacePt = board_.getPosition(r, col);
            }
            else {
View Full Code Here

        //}

        if ( nbr.isOccupied() &&
            (!sameSideOnly || nbr.getPiece().isOwnedByPlayer1() == friendPlayer1) && !nbr.isVisited() ) {

            BoardPosition intermediate1, intermediate2;
            if ( Math.abs( rowOffset ) == 2 ) {
                int rr = r + (rowOffset >> 1);
                intermediate1 = board_.getPosition(rr, c);
                intermediate2 = board_.getPosition(rr, c + colOffset);
            }
View Full Code Here

        PenteBoard board = (PenteBoard) controller.getBoard();

        // if there is already a piece where the user clicked or its
        // 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()));
View Full Code Here

            throw new RuntimeException(e);
        }

        try {
            // initial update to the game tables for someone entering the room.
            GameCommand cmd = new GameCommand(GameCommand.Name.UPDATE_TABLES, cmdProcessor.getTables());
            update(cmd);

            while (!stopped) {
                // receive the serialized commands that are sent and process them.
                cmd = (GameCommand) iStream.readObject();
View Full Code Here

            default:
                assert false : "Unhandled command: "+ cmd;
        }

        if (useUpdateTable) {
            GameCommand response = new GameCommand(GameCommand.Name.UPDATE_TABLES, getTables());
            responses.add(0, response)// add as first command in response.
        }

        return responses;
    }
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.