Examples of PathList


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

    /**
     * @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

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

                    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

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

     * 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

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

     * @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

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

                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

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

        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

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

     */
    private int addMoves( BoardPosition position, MoveList moveList, PathList opponentPaths, ParameterArray weights) {
        int numMovesAdded = 0;

        // first find the NUM_HOMES shortest paths for p.
        PathList paths = board.findShortestPaths((BlockadeBoardPosition)position);

        WallPlacementFinder wallFinder = new WallPlacementFinder(board, opponentPaths, weights);

        // for each of these paths, add possible wall positions.
        // Take the first move from each shortest path and add the wall positions to it.
View Full Code Here

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

        // after making the first move, the shortest paths may have changed somewhat.
        // unfortunately, I think we need to recalculate them.
        BlockadeBoardPosition newPos =
                board.getPosition(firstStep.getToRow(), firstStep.getToCol());
        PathList ourPaths = board.findShortestPaths(newPos);

        List<BlockadeMove> wallMoves = wallFinder.findWallPlacementsForMove(firstStep, ourPaths);
        GameContext.log(2, "num wall placements for Move = " + wallMoves.size());
        board.undoMove();
View Full Code Here

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

        BasicStroke pathStroke =
                new BasicStroke((float)cellSize * PATH_WIDTH_RATIO, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
        g2.setStroke(pathStroke);
        if (pos == null || pos.isUnoccupied()) return;

        PathList paths = b.findShortestPaths(pos);
        boolean p1 = pos.getPiece().isOwnedByPlayer1();
        Color pathColor = p1? BlockadePieceRenderer.getRenderer().getPlayer1Color() :
                              BlockadePieceRenderer.getRenderer().getPlayer2Color();
        pathColor = pathColor.darker();

View Full Code Here

Examples of de.sciss.gui.PathList

  {
    super();
   
    root    = app;
 
    openRecentPaths = new PathList( 8, root.getUserPrefs(), KEY_OPENRECENT );
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.