Package com.barrybecker4.common.geometry

Examples of com.barrybecker4.common.geometry.Location


     */
    private boolean allEmptiesVisited(Set<Location> visited) {
        Box bbox = tantrix.getBoundingBox();
        for (int i = bbox.getMinRow(); i < bbox.getMaxRow(); i++) {
            for (int j = bbox.getMinCol(); j <= bbox.getMaxCol(); j++)  {
                Location loc = new ByteLocation(i, j);
                if (tantrix.get(loc) == null && !visited.contains(loc))  {
                    return false;
                }
            }
        }
View Full Code Here


        TilePlacement lastPlaced = board.getLastTile();
        PrimaryPathFitter fitter = new PrimaryPathFitter(board.getTantrix(), board.getPrimaryColor());

        Map<Integer, Location> outgoing = lastPlaced.getOutgoingPathLocations(primaryColor);
        Location nextLocation = null;
        for (int i : outgoing.keySet()) {
            if (board.getTilePlacement(outgoing.get(i)) == null) {
                nextLocation = outgoing.get(i);
            }
        }
View Full Code Here

        int row = loc.getRow();
        int col = loc.getCol();

        int colOffset = (Math.abs(row) % 2 == 1) ? -1 : 0;
        Location nbrLoc = null;

        switch (direction) {
            case 0 : nbrLoc = new IntLocation(row, col + 1); break;
            case 1 : nbrLoc = new IntLocation(row - 1, col + colOffset + 1); break;
            case 2 : nbrLoc = new IntLocation(row - 1, col + colOffset); break;
View Full Code Here

    public TilePlacement getNeighbor(TilePlacement currentPlacement, byte direction) {

        if (currentPlacement == null) {
            return null;
        }
        Location loc =
            HexUtil.getNeighborLocation(currentPlacement.getLocation(), direction);
        return get(loc);
    }
View Full Code Here

     * @param direction side to navigate to to find the neighbor. 0 is to the right.
     * @return the indicated neighbor of the specified tile.
     */
    protected TilePlacement getNeighbor(TilePlacement currentPlacement, byte direction) {

        Location loc =
            HexUtil.getNeighborLocation(currentPlacement.getLocation(), direction);
        for (TilePlacement p : tiles) {
            if (p.getLocation().equals(loc)) {
                return p;
            }
View Full Code Here

        Box bbox = tantrix.getBoundingBox();
        Set<Location> empties = new HashSet<Location>();

        for (int i = bbox.getMinCol(); i <= bbox.getMaxCol(); i++) {
            Location loc = new ByteLocation(bbox.getMinRow(), i);
            if (tantrix.get(loc) == null)  {
                empties.add(loc);
            }
            loc = new ByteLocation(bbox.getMaxRow(), i);
            if (tantrix.get(loc) == null)  {
                empties.add(loc);
            }
        }

        for (int i = bbox.getMinRow() + 1; i < bbox.getMaxRow(); i++) {
            Location loc = new ByteLocation(i, bbox.getMinCol());
            if (tantrix.get(loc) == null)  {
                empties.add(loc);
            }
            loc = new ByteLocation(i, bbox.getMaxCol());
            if (tantrix.get(loc) == null)  {
View Full Code Here

        Queue<Location> searchQueue = new LinkedList<Location>();
        searchQueue.addAll(seedEmpties);
        visited.addAll(seedEmpties);

        while (!searchQueue.isEmpty()) {
            Location loc = searchQueue.remove();
            List<Location> nbrEmpties = findEmptyNeighborLocations(loc);
            for (Location empty : nbrEmpties) {
                if (!visited.contains(empty)) {
                    visited.add(empty);
                    searchQueue.add(empty);
View Full Code Here

    @Override
    public TantrixPath mutate(TilePlacement pivotTile, TantrixPath subPath) {
        TilePlacementList tiles = new TilePlacementList();
        TilePlacementList subPathTiles = subPath.getTilePlacements();
        TilePlacement firstTile = subPathTiles.get(0);
        Location firstTileLocation = firstTile.getLocation();
        int numRotations = findRotationsToSwapLocation(firstTileLocation, pivotTile);
        int directionToPivot = findOutgoingDirection(firstTile, pivotTile.getLocation());

        Location newLocation = HexUtil.getNeighborLocation(pivotTile.getLocation(), numRotations);
        Location origLocation = pivotTile.getLocation();

        numRotations = numRotations + 3 - directionToPivot;
        Rotation tileRotation = firstTile.getRotation().rotateBy(numRotations);

        TilePlacement previousTilePlacement = new TilePlacement(firstTile.getTile(), newLocation, tileRotation);
View Full Code Here

     */
    private int findRotationsToSwapLocation(Location firstTileLocation, TilePlacement pivotTile) {
        Map<Integer, Location> outgoingPathLocations = pivotTile.getOutgoingPathLocations(primaryColor);
        Set<Integer> keys = outgoingPathLocations.keySet();
        for (int key : keys) {
            Location loc = outgoingPathLocations.get(key);
            if (!firstTileLocation.equals(loc)) {
                return key;
            }
        }
        assert false;
View Full Code Here

     */
    private List<Location> findEmptyNeighborLocations(TilePlacement placement) {
        List<Location> emptyNbrLocations = new LinkedList<Location>();
        for (byte i=0; i< NUM_SIDES; i++) {

            Location nbrLoc = HexUtil.getNeighborLocation(placement.getLocation(), i);
            if (tantrix.get(nbrLoc) == null) {
                Box newBox = new Box(boundingBox, nbrLoc);
                if (newBox.getMaxDimension() <= maxHalfPathLength) {
                    emptyNbrLocations.add(nbrLoc);
                    boundingBox = newBox;
View Full Code Here

TOP

Related Classes of com.barrybecker4.common.geometry.Location

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.