Package com.barrybecker4.game.twoplayer.blockade.board.move

Examples of com.barrybecker4.game.twoplayer.blockade.board.move.BlockadeMove


    }

    @Override
    protected NewGameDialog createNewGameDialog(Component parent, GameViewModel viewer )
    {
        return new GalacticNewGameDialog( parent, viewer );
    }
View Full Code Here


    }

    @Override
    protected GameOptionsDialog createOptionsDialog(Component parent, GameController controller )
    {
        return new GalacticOptionsDialog( parent, controller );
    }
View Full Code Here

     * display a dialog at the end of the game showing who won and other relevant
     * game specific information.
     */
    @Override
    public void showWinnerDialog() {
        GalacticTallyDialog tallyDialog = new GalacticTallyDialog(parent_, (GalacticController)controller_);
        tallyDialog.showDialog();
    }
View Full Code Here

     */
    private void showOrdersDialog(GalacticController gc) {

        GalacticPlayer currentPlayer = (GalacticPlayer)gc.getCurrentPlayer();

        OrdersDialog ordersDialog =
                new OrdersDialog(null, currentPlayer, gc.getNumberOfYearsRemaining());
        Point p = getParent().getLocationOnScreen();

        // offset the dlg so the Galaxy grid is visible as a reference
        ordersDialog.setLocation((int)(p.getX()+0.7*getParent().getWidth()), (int)(p.getY()+getParent().getHeight()/3.0));

        boolean canceled = ordersDialog.showDialog();
        if ( !canceled ) { // newGame a game with the newly defined options
            currentPlayer.setOrders( ordersDialog.getOrders() );
            gc.advanceToNextPlayer();
        }
    }
View Full Code Here

                                          ParameterArray weights, List<BlockadeMove> moves) {
        int value = 0;
        // @@ we should provide the value here since we have all the path info.
        // we do not want to compute the path info again by calling findPlayerPathLengths.
        // The value will change based on how much we shorten our paths while lengthening the opponents.
        BlockadeMove m =
               BlockadeMove.createMove(ourmove.getFromLocation(),
                                       ourmove.getToLocation(),
                                       value, ourmove.getPiece(), wall);
        // for the time being just call worth directly. Its less efficient, but simpler.
        board.makeMove(m);
        PlayerPathLengths pathLengths = board.findPlayerPathLengths();
        board.undoMove();

        if (pathLengths.isValid()) {
            m.setValue(pathLengths.determineWorth(SearchStrategy.WINNING_VALUE, weights));
            moves.add(m);
        }
        else {
            GameContext.log(2, "Did not add "+ m+ " because it was invalid.");
        }
View Full Code Here

            // do a breadth first search until you have spanned/visited all opponent homes.
            while (homeSet.size() < Homes.NUM_HOMES && !queue.isEmpty()) {
                // pop the next move from the head of the queue.
                DefaultMutableTreeNode node = queue.remove(0);
                BlockadeMove nodeMove = (BlockadeMove)node.getUserObject();
                BlockadeBoardPosition toPosition =
                        board.getPosition(nodeMove.getToRow(), nodeMove.getToCol());
                if (!toPosition.isVisited()) {
                    toPosition.setVisited(true);
                    MutableTreeNode parentNode = (MutableTreeNode)node.getParent();
                    node.setParent(null);
                    parentNode.insert(node, parentNode.getChildCount());
View Full Code Here

     * return the SGF (4) representation of the move
     * SGF stands for Smart Game Format and is commonly used for Go
     */
    @Override
    protected String getSgfForMove(Move move) {
        BlockadeMove m = (BlockadeMove) move;
        // passes are not represented in SGF - so just skip it if the piece is null.
        if (m.getPiece() == null)
             return "[]";
        StringBuilder buf = new StringBuilder("");
        String player = "P2";
        if ( m.getPiece().isOwnedByPlayer1() )
        {
            player = "P1";
        }
        buf.append( ';' );
        buf.append( player );
         buf.append( '[' );
        buf.append( (char) ('a' + m.getFromCol() - 1) );
        buf.append( (char) ('a' + m.getFromRow() - 1) );
        buf.append( ']' );
        buf.append( '[' );
        buf.append( (char) ('a' + m.getToCol() - 1) );
        buf.append( (char) ('a' + m.getToRow() - 1) );
        buf.append( ']' );
        // also print the wall placement if there is one
        if (m.getWall() != null) {
            buf.append("wall");
            for (BlockadeBoardPosition pos : m.getWall().getPositions()) {
                serializePosition(pos.getLocation(), buf);
            }
        }
        else {
            buf.append("nowall");
View Full Code Here

                board.getPosition(getRenderer().getDraggedPiece().getLocation());

        // valid or not, don't show the dragged piece after releasing the mouse.
        getRenderer().setDraggedPiece(null);

        BlockadeMove m = checkAndGetValidMove(position, loc);
        if (m == null) {
            return false;
        }

        // make sure that the piece shows while we decide where to place the wall.
        currentMove = m;
        GameContext.log(1, "legal human move :" + m.toString());
        position.getPiece().setTransparency((short) 0);
        boolean isPlayer1 = position.getPiece().isOwnedByPlayer1();
        BlockadeBoardPosition newPosition =
                board.getPosition(currentMove.getToRow(), currentMove.getToCol());
        newPosition.setPiece(position.getPiece());
View Full Code Here

        }
        // verify that the move is valid before allowing it to be made.
        Iterator it = possibleMoveList.iterator();
        boolean found = false;

        BlockadeMove m = null;
        while ( it.hasNext() && !found ) {
            m = (BlockadeMove) it.next();
            if ( (m.getToRow() == destpos.getRow()) && (m.getToCol() == destpos.getCol()) )
                found = true;
        }

        if ( !found ) {
            return null; // it was not valid
View Full Code Here

     *   A big negative value means a good move for p2.
     */
    @Override
    public int worth( TwoPlayerMove lastMove, ParameterArray weights ) {
        getProfiler().startCalcWorth();
        BlockadeMove m = (BlockadeMove)lastMove;
        // if its a winning move then return the winning value
        boolean player1Moved = m.isPlayer1();

        if (checkForWin(player1Moved)) {
            GameContext.log(1, "FOUND WIN!!!");
            return player1Moved ? SearchStrategy.WINNING_VALUE : -SearchStrategy.WINNING_VALUE;
        }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.twoplayer.blockade.board.move.BlockadeMove

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.