Commit f576bb2b authored by hosein's avatar hosein

police -> cleaned warnings

parent 663ee50c
...@@ -4,12 +4,10 @@ import java.util.Random; ...@@ -4,12 +4,10 @@ import java.util.Random;
public class Police { public class Police {
private int x, y; private int x, y;
private static boolean see;
Police(int x, int y) { Police(int x, int y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
see = false;
} }
public void randomMove(int n, int m, PlayGround playGround) { public void randomMove(int n, int m, PlayGround playGround) {
...@@ -20,13 +18,10 @@ public class Police { ...@@ -20,13 +18,10 @@ public class Police {
if (y != 0) j = true; if (y != 0) j = true;
if (y != m - 1) J = true; if (y != m - 1) J = true;
if (!i && !I && !j && !J) System.out.println("truuuuuuuuuuuuuuuuuue nistan // police -> random move");
Random random = new Random(); Random random = new Random();
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);
do { do {
switch (random.nextInt(8)) { switch (random.nextInt(8)) {
case 0: case 0:
...@@ -128,76 +123,9 @@ public class Police { ...@@ -128,76 +123,9 @@ public class Police {
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];
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("c2 ============== " + c + "\n");
} }
public void targetedMove2(int[][] thiefSituation, PlayGround playGround) { private int[][] confirmTargetMove(int x, int y, int destination, PlayGround p) {
int X = thiefSituation[0][0], Y = thiefSituation[0][1];
int[][] newSituation = new int[1][2];
switch ((int) (1000 * (Math.sqrt(Math.pow(X - x, 2) + Math.pow(Y - y, 2)) - Math.sqrt(Math.pow(X - 0.3 - x, 2) + Math.pow(Y - 0.4 - getY(), 2))))) {
case 493: // up, left
case 433:
case 489:
case 492:
newSituation = confirmTargetMove(x, y, 8, playGround);
break;
case 193: // up
case 253:
newSituation = confirmTargetMove(x, y, 7, playGround);
break;
case 33:
case -112:
case -151:
case -263: //up, right
newSituation = confirmTargetMove(x, y, 6, playGround);
break;
case 372:
case 329: //left
newSituation = confirmTargetMove(x, y, 5, playGround);
break;
case -431:
case -418: //right
newSituation = confirmTargetMove(x, y, 4, playGround);
break;
case 174:
case -17:
case -140:
case 26: //down, left
newSituation = confirmTargetMove(x, y, 3, playGround);
break;
case -360:
case -334: //down
newSituation = confirmTargetMove(x, y, 2, playGround);
break;
case -496:
case -493:
case -456:
case -495: //down, right
newSituation = confirmTargetMove(x, y, 1, playGround);
}
playGround.changeSituation(x, y, newSituation[0][0], newSituation[0][1], 1);
}
public int[][] confirmTargetMove(int x, int y, int destination, PlayGround p) {
int[][] newSituation = new int[1][2]; int[][] newSituation = new int[1][2];
Random r = new Random(); Random r = new Random();
...@@ -405,20 +333,4 @@ public class Police { ...@@ -405,20 +333,4 @@ public class Police {
} }
return newSituation; return newSituation;
} }
public int[][] getSituation() {
int[][] Return = new int[1][1];
Return[0][0] = x;
Return[0][1] = y;
return Return;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
} }
\ No newline at end of file
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