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

Examples of com.barrybecker4.game.twoplayer.blockade.board.BlockadeBoardPosition


     * Factory method to create the game controller via reflection.
     * The server should not have a ui component.
     */
    private void createController(String gameName) {

        GamePlugin plugin = PluginManager.getInstance().getPlugin(gameName);
        GameContext.loadResources(gameName);

        // for now, also create a corresponding viewer. The server should really not have knowledge of a UI component.
        // fix this by doing plugin.getModelInstance, then getting the controller from that.
        GamePanel panel  = plugin.getPanelInstance();
        panel.init(null);
        GameBoardViewer viewer = panel.getViewer();

        controller_ = viewer.getController();
    }
View Full Code Here


        GamePlugin plugin = PluginManager.getInstance().getPlugin(gameName);
        GameContext.loadResources(gameName);

        // for now, also create a corresponding viewer. The server should really not have knowledge of a UI component.
        // fix this by doing plugin.getModelInstance, then getting the controller from that.
        GamePanel panel  = plugin.getPanelInstance();
        panel.init(null);
        GameBoardViewer viewer = panel.getViewer();

        controller_ = viewer.getController();
    }
View Full Code Here

        // for now, also create a corresponding viewer. The server should really not have knowledge of a UI component.
        // fix this by doing plugin.getModelInstance, then getting the controller from that.
        GamePanel panel  = plugin.getPanelInstance();
        panel.init(null);
        GameBoardViewer viewer = panel.getViewer();

        controller_ = viewer.getController();
    }
View Full Code Here

    void ok() {
        GameContext.setDebugMode( dbgLevelField_.getIntValue() );
        GameContext.setProfiling( profileCheckbox_.isSelected() );
        GameContext.getLogger().setDestination( logDestination_ );

        GameBoardViewer v = ((GameBoardViewer)controller_.getViewer());
        v.setBackground( boardColorButton_.getBackground() );
        v.setGridColor( gridColorButton_.getBackground() );

        LocaleType[] locales = LocaleType.values();
        GameContext.setLocale(locales[localeComboBox_.getSelectedIndex()]);

        // game specific options
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());
                    if (toPosition.isHomeBase(opponentIsPlayer1)) {
                        homeSet.add(node);
                    }
                    List<DefaultMutableTreeNode> children = findPathChildren(toPosition, node, opponentIsPlayer1);
                    queue.addAll(children);
                }
View Full Code Here

     * @return either the top/north or the left/west board position
     *  depending on whether this is a vertical or horizontal wall, respectively.
     */
    public BlockadeBoardPosition getFirstPosition() {
        Iterator<BlockadeBoardPosition> it = positions_.iterator();
        BlockadeBoardPosition pos1 = it.next();
        BlockadeBoardPosition pos2 = it.next();
        if (isVertical_) {
            return (pos1.getRow() < pos2.getRow())? pos1 : pos2;
        }
        else {
            return (pos1.getCol() < pos2.getCol())? pos1 : pos2;
        }
    }
View Full Code Here

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

    public PlayerPathLengths findPlayerPathLengths() {
        PlayerPathLengths playerPaths = new PlayerPathLengths();

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

     */
    BlockadeWallList checkWallsForEast(BlockadeBoardPosition eastPos, BlockadeBoardPosition pos) {
        BlockadeWallList wallsToCheck = new BlockadeWallList();
        if (eastPos!=null && !pos.isEastBlocked())  {

            BlockadeBoardPosition northPos = pos.getNeighbor(Direction.NORTH, board);
            BlockadeBoardPosition southPos = pos.getNeighbor(Direction.SOUTH, board);
            BlockadeBoardPosition northEastPos = pos.getNeighbor(Direction.NORTH_EAST, board);
            if (northPos != null && !northPos.isEastBlocked()
                 && !(northPos.isSouthBlocked() && northPos.getSouthWall() == northEastPos.getSouthWall())) {
                wallsToCheck.add( new BlockadeWall(pos, northPos) );
            }
            if (southPos != null && !southPos.isEastBlocked()
                && !(pos.isSouthBlocked() && pos.getSouthWall() == eastPos.getSouthWall())) {
                wallsToCheck.add( new BlockadeWall( pos, southPos) );
View Full Code Here

     * Add valid wall placements to the west.
     */
    BlockadeWallList checkWallsForWest(BlockadeBoardPosition westPos, BlockadeBoardPosition pos) {
        BlockadeWallList wallsToCheck = new BlockadeWallList();
        if (westPos!=null && !westPos.isEastBlocked())  {
            BlockadeBoardPosition northPos = pos.getNeighbor(Direction.NORTH, board);
            BlockadeBoardPosition southPos = pos.getNeighbor(Direction.SOUTH, board);
            BlockadeBoardPosition northWestPos = pos.getNeighbor(Direction.NORTH_WEST, board);
            if (northPos !=  null && !northWestPos.isEastBlocked()
                && !(northWestPos.isSouthBlocked() && northWestPos.getSouthWall() == northPos.getSouthWall())) {
                wallsToCheck.add( new BlockadeWall(westPos, northWestPos) );
            }
            BlockadeBoardPosition southWestPos = pos.getNeighbor(Direction.SOUTH_WEST, board);
            if (southPos != null && !southWestPos.isEastBlocked()
                && !(westPos.isSouthBlocked() && westPos.getSouthWall() == pos.getSouthWall())) {
                wallsToCheck.add( new BlockadeWall(westPos, southWestPos) );
            }
        }
        return wallsToCheck;
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.twoplayer.blockade.board.BlockadeBoardPosition

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.