I need help because I can not see where my problem is. I have function swapping and it looks like this:
public static void swapping(int[] curr, Integer i, Integer j, Integer k, Integer l, int z, int dist) {
int tmp;
int[] tmpCurr = curr;
if (i >= 0 && j >= 0 && k < 0 && l < 0) {
tmp = tmpCurr[i];
tmpCurr[i] = tmpCurr[z];
tmpCurr[z] = tmp;
nodesHM.put(1, tmpCurr);
for(int s = 0; s<tmpCurr.length; s++)
System.out.println(tmpCurr[s]);
tmpCurr = curr;
tmp = tmpCurr[j];
tmpCurr[j] = tmpCurr[z];
tmpCurr[z] = tmp;
nodesHM.put(2, tmpCurr);
for(int s = 0; s<tmpCurr.length; s++)
System.out.println(tmpCurr[s]);
}
}
i,j,k,l tell me what to swap with z. So if i put that somethig is -1 that means I do not want to swap it. Like it this case k and l.
And I call it from main, like this:
public static void main(String[] args) {
swapping(ourStartState, 3, 7, -1, -1, 6, 5);
}
private static final int[] ourStartState = { 1, 2, 3, 4, 5, 6, 0, 7, 8 };
And it should write me something like: 1,2,3,0,5,6,4,7,8 and 1,2,3,4,5,6,7,0,8
but it give me 1,2,3,0,5,6,4,7,8 and 1,2,3,0,5,6,7,4,8
Where I am going wrong? Thanks