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

Examples of com.barrybecker4.game.twoplayer.blockade.board.path.PathList


    }

    @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

    /**
     * @return error message if no path exists from this position to an opponent home.
     */
    private boolean missingPath(BoardAnalyzer analyzer) {
        PathList paths1 = analyzer.findAllOpponentShortestPaths(true);
        PathList paths2 = analyzer.findAllOpponentShortestPaths(false);
        GameContext.log(2, "paths1.magnitude="+paths1.size()+" paths2.magnitude ="+paths2.size() );

        int expectedNumPaths = getExpectedNumPaths();
        return  (paths1.size() < expectedNumPaths || paths2.size() <expectedNumPaths );
    }
View Full Code Here

                    queue.addAll(children);
                }
            }
        }
        // extract the paths by working backwards to the root from the homes.
        PathList paths = extractPaths(homeSet);

        unvisitAll();
        return paths;
    }
View Full Code Here

     * Extract the paths by working backwards to the root from the homes.
     * @param homeSet set of home base positions.
     * @return extracted paths
     */
    private PathList extractPaths(Set<MutableTreeNode> homeSet) {
        PathList paths = new PathList();

        for (MutableTreeNode home : homeSet) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode)home;
            Path path = new Path(node);
            // if the path is not > 0 then then pawn is on the homeBase and the game has been won.
            if (path.getLength() == 0) {
                GameContext.log(2, "found 0 magnitude path =" + path +" for home "  + node);
            }
            paths.add(path);
        }
        return paths;
    }
View Full Code Here

     * @return all the opponent's shortest paths to specified players home bases.
     */
    public PathList findAllOpponentShortestPaths(boolean player1) {

        int numShortestPaths = Homes.NUM_HOMES * Homes.NUM_HOMES;
        PathList opponentPaths = new PathList();
        Set<BlockadeBoardPosition> hsPawns = new LinkedHashSet<BlockadeBoardPosition>();
        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() && pos.getPiece().isOwnedByPlayer1() != player1 ) {
                    hsPawns.add(pos);
                    assert (hsPawns.size() <= Homes.NUM_HOMES) : "Error: too many opponent pieces: " + hsPawns ;
                    PathList paths = findShortestPaths(pos);
                    GameContext.log(2, "about to add " + paths.size() + " more paths to "
                            + opponentPaths.size() + " maxAllowed=" + numShortestPaths);
                    for (Path p: paths) {
                        opponentPaths.add(p);
                    }
                }
View Full Code Here

                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);
                }
            }
        }
View Full Code Here

        MoveList moveList = new MoveList();
        boolean player1 = (lastMove == null) || !lastMove.isPlayer1();

        // There is one path from every piece to every opponent home (i.e. n*NUM_HOMES)
        PathList opponentPaths = board.findAllOpponentShortestPaths(player1);

        List<BoardPosition> pawnLocations = new LinkedList<BoardPosition>();
        for ( int row = 1; row <= board.getNumRows(); row++ ) {
            for ( int col = 1; col <= board.getNumCols(); col++ ) {
                BoardPosition p = board.getPosition( row, col );
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.twoplayer.blockade.board.path.PathList

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.