Commit 1d3d3207 authored by hosein's avatar hosein

police -> TargetedMove updated

parent 45fa18bd
...@@ -26,7 +26,7 @@ public class Police { ...@@ -26,7 +26,7 @@ public class Police {
boolean confirm = false; boolean confirm = false;
int X = 0, Y = 0; int X = 0, Y = 0;
System.out.println("x = "+x+" y = "+y+"\n i "+i+"\n I "+I+"\n j "+j+"\n J "+J); System.out.println("x = " + x + " y = " + y + "\n i " + i + "\n I " + I + "\n j " + j + "\n J " + J);
do { do {
switch (random.nextInt(8)) { switch (random.nextInt(8)) {
case 0: case 0:
...@@ -96,23 +96,13 @@ public class Police { ...@@ -96,23 +96,13 @@ public class Police {
playGround.changeSituation(x, y, X, Y, 1); playGround.changeSituation(x, y, X, Y, 1);
x = X; x = X;
y = Y; y = Y;
} }
public void targetedMove(int[][] thiefSituation, PlayGround playGround) { public void targetedMove(int[][] thiefSituation, PlayGround playGround) {
int X = thiefSituation[0][0], Y = thiefSituation[0][1]; int X = thiefSituation[0][0], Y = thiefSituation[0][1];
int[][] newSituation; int[][] newSituation;
int c = 0;
for (int j, z = 0; z < playGround.getNM()[0][0]; z++)
for (j = 0; j < playGround.getNM()[0][1]; j++)
if (playGround.getGround()[z][j] == 1)
c++;
System.out.println("\nc1 ============== " + c);
if (x > X) { if (x > X) {
if (y > Y) // down, right if (y > Y) // down, right
newSituation = confirmTargetMove(x, y, 1, playGround); newSituation = confirmTargetMove(x, y, 1, playGround);
...@@ -135,19 +125,11 @@ public class Police { ...@@ -135,19 +125,11 @@ public class Police {
} }
c = 0;
for (int j, z = 0; z < playGround.getNM()[0][0]; z++)
for (j = 0; j < playGround.getNM()[0][1]; j++)
if (playGround.getGround()[z][j] == 1)
c++;
System.out.println("c1.5 ============ " + c);
playGround.changeSituation(x, y, newSituation[0][0], newSituation[0][1], 1); playGround.changeSituation(x, y, newSituation[0][0], newSituation[0][1], 1);
x = newSituation[0][0]; x = newSituation[0][0];
y = newSituation[0][1]; y = newSituation[0][1];
c = 0; int c = 0;
for (int j, z = 0; z < playGround.getNM()[0][0]; z++) for (int j, z = 0; z < playGround.getNM()[0][0]; z++)
for (j = 0; j < playGround.getNM()[0][1]; j++) for (j = 0; j < playGround.getNM()[0][1]; j++)
if (playGround.getGround()[z][j] == 1) if (playGround.getGround()[z][j] == 1)
...@@ -210,10 +192,9 @@ public class Police { ...@@ -210,10 +192,9 @@ public class Police {
} }
if (newSituation[0][0] != x || newSituation[0][1] != y)
playGround.changeSituation(x, y, newSituation[0][0], newSituation[0][1], 1); playGround.changeSituation(x, y, newSituation[0][0], newSituation[0][1], 1);
} }
public int[][] confirmTargetMove(int x, int y, int destination, PlayGround p) { public int[][] confirmTargetMove(int x, int y, int destination, PlayGround p) {
...@@ -361,7 +342,7 @@ public class Police { ...@@ -361,7 +342,7 @@ public class Police {
} }
case 1: case 1:
if (p.isEmpty(x + 1, y)) { // go down if (p.isEmpty(x + 1, y)) { // go down
newSituation[0][0] = x - 1; newSituation[0][0] = x + 1;
newSituation[0][1] = y; newSituation[0][1] = y;
return newSituation; return newSituation;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment