Examples of TantrixPath


Examples of com.barrybecker4.puzzle.tantrix.solver.path.TantrixPath

     * @return list of moves to a solution.
     */
    @Override
    public TilePlacementList solve()  {

        ParameterArray initialGuess = new TantrixPath(board);
        assert(initialGuess.size() > 0) : "The random path should have some tiles!";
        long startTime = System.currentTimeMillis();

        Optimizer optimizer = new Optimizer(this);
        optimizer.setListener(this);

View Full Code Here

Examples of com.barrybecker4.puzzle.tantrix.solver.path.TantrixPath

     * We show the current status.
     * @param params
     */
    public void optimizerChanged(ParameterArray params) {
        // update our current best guess at the solution.
        TantrixPath path = (TantrixPath)params;
        solution_ = new TantrixBoard(path.getTilePlacements(), path.getPrimaryPathColor());
        puzzlePanel_.refresh(solution_, numTries_++);
    }
View Full Code Here

Examples of com.barrybecker4.puzzle.tantrix.solver.path.TantrixPath

            //if (placement == null) {
            //    currentBoard.undoLastPlaced();
            //}
            currentBoard = currentBoard.placeTile(placement);
        }
        return new TantrixPath(currentBoard.getTantrix(), initialBoard.getPrimaryColor());
    }
View Full Code Here

Examples of com.barrybecker4.puzzle.tantrix.solver.path.TantrixPath

            tiles.add(currentTilePlacement);
            origLocation = previousTilePlacement.getLocation(); //currentTilePlacement.getLocation();
            previousTilePlacement = currentTilePlacement;
        }

        return new TantrixPath(tiles, primaryColor);
    }
View Full Code Here

Examples of com.barrybecker4.puzzle.tantrix.solver.path.TantrixPath

        this.originalPath = path;
        this.color = path.getPrimaryPathColor();
    }

    public TantrixPath permute(List<Integer> oldIndices, List<Integer> newIndices) {
        TantrixPath permutedPath = originalPath.copy();

        TilePlacementList auxList = new TilePlacementList();

        //System.out.println("new indices = " + newIndices);
        //System.out.println("old indices = " + oldIndices);

        for (int i=0; i<oldIndices.size(); i++) {
           auxList.set(i, permutedPath.getTilePlacements().get(newIndices.get(i)));
        }

        PrimaryPathFitter fitter =
                new PrimaryPathFitter(permutedPath.getTilePlacements(), color);

        TilePlacementList origPlacements = permutedPath.getTilePlacements();
        for (int i=0; i<newIndices.size(); i++) {

            int oldIndex = oldIndices.get(i);
            TilePlacement oldPlacement = auxList.get(i);
            TilePlacement newPlacement =
View Full Code Here

Examples of com.barrybecker4.puzzle.tantrix.solver.path.TantrixPath

        PathTilePermuter permuter = new PathTilePermuter(originalPath);

        if (indices.size() == 2) {
            List<Integer> newOrder = new ArrayList<Integer>(indices);
            Collections.reverse(newOrder);
            TantrixPath permutedPath = permuter.permute(newOrder, indices);
            permutedPaths.add(permutedPath);
        }
        else if (indices.size() > 2) {
            // add the original originalPath for now, to be sure we do not duplicated it, but return at end.
            permutedPaths.add(originalPath);

            int numIter = Math.min(originalPath.size() + 1, MAX_ITER);

            for (int i = 0; i < numIter; i++) {
                List<Integer> newOrder = new ArrayList<Integer>(indices);
                Collections.shuffle(newOrder, MathUtil.RANDOM);
                TantrixPath permutedPath = permuter.permute(newOrder, indices);
                if (!permutedPaths.contains(permutedPath)) {
                    permutedPaths.add(permutedPath);
                }
            }
            permutedPaths.remove(0);
View Full Code Here

Examples of com.barrybecker4.puzzle.tantrix.solver.path.TantrixPath

             tiles.add(currentTilePlacement);
             origLocation = previousTilePlacement.getLocation();
             previousTilePlacement = currentTilePlacement;
         }

         return new TantrixPath(tiles, primaryColor);
    }
View Full Code Here

Examples of com.barrybecker4.puzzle.tantrix.solver.path.TantrixPath

        int lowerIndexStart = 1;
        int upperIndexStop = path_.size() - 2;

        for (int i=lowerIndexStart; i<upperIndexStop; i++) {
            for (int j=upperIndexStop; j>=i; j--) {
                TantrixPath subPath1 = path_.subPath(i - 1, 0);
                pivotPath = path_.subPath(i, j);
                TantrixPath subPath2 =  path_.subPath(j + 1, path_.size() - 1);
                pathPermutations.addAll( createPermutedPathList(subPath1, subPath2));
            }
        }

        return pathPermutations;
View Full Code Here

Examples of com.barrybecker4.puzzle.tantrix.solver.path.TantrixPath

    public List<TantrixPath> findPermutedPaths(int pivotIndex1, int pivotIndex2) {

        int lowerIndex = Math.min(pivotIndex1, pivotIndex2);
        int upperIndex = Math.max(pivotIndex1, pivotIndex2);

        TantrixPath subPath1 = path_.subPath(lowerIndex - 1, 0);
        pivotPath = path_.subPath(lowerIndex, upperIndex);
        TantrixPath subPath2 =  path_.subPath(upperIndex + 1, path_.size() - 1);

        return createPermutedPathList(subPath1, subPath2);
    }
View Full Code Here

Examples of com.barrybecker4.puzzle.tantrix.solver.path.TantrixPath

        SubPathMutator swapper = new SubPathSwapper(primaryColor);
        SubPathMutator reverser = new SubPathReverser(primaryColor);
        TilePlacement firstPivot = pivotPath.getFirst();
        TilePlacement lastPivot = pivotPath.getLast();

        TantrixPath subPath1Reversed = reverser.mutate(firstPivot, subPath1);
        TantrixPath subPath2Reversed = reverser.mutate(lastPivot, subPath2);
        TantrixPath subPath1Swapped = swapper.mutate(firstPivot, subPath1);
        TantrixPath subPath2Swapped = swapper.mutate(lastPivot, subPath2);
        TantrixPath subPath1RevSwapped = swapper.mutate(firstPivot, subPath1Reversed);
        TantrixPath subPath2RevSwapped = swapper.mutate(lastPivot, subPath2Reversed);

        List<TantrixPath> pathPermutations = new ArrayList<TantrixPath>();

        addIfNotNull(createPermutedPath(subPath1, subPath2Reversed), pathPermutations);
        addIfNotNull(createPermutedPath(subPath1Reversed, subPath2), pathPermutations);
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.