package pathgame.algorithm; public class Permutation { private final int size; private int[] vals; private int[] minVals; private int minCost = Integer.MAX_VALUE; private final int thingsPerPos; public Permutation(int listSize, int thingsPerPos) { this.thingsPerPos = thingsPerPos; this.size = (listSize / thingsPerPos) - 1; vals = new int[size]; } public int getValAtPos(int pos) { return vals[pos]; } public boolean isPosAtMax(int pos) { if(vals[pos] == getMaxOfPos(pos)) { return true; } return false; } public int getMaxOfPos(int pos) { return thingsPerPos * (size - pos); } public int size() { return size; } public void increaseAtPos(int pos) { vals[pos]++; for(int i = pos + 1; i < size; i++) { vals[i] = 0; } } public int getMinCost() { return minCost; } public void setMinCost(int minCost) { this.minCost = minCost; minVals = vals.clone(); } public void makePermutMinimal() { vals = minVals.clone(); } public void printPermut() { for(int i = 0; i < size; i++) { System.out.print(vals[i] + " "); } System.out.println(); } public void printMinPermut() { for(int i = 0; i < size; i++) { System.out.print(minVals[i] + " "); } System.out.println(); } }