Commit 218b9ba1 authored by hosein's avatar hosein

thief updated

parent eaf85402
...@@ -170,49 +170,76 @@ public class Thief { ...@@ -170,49 +170,76 @@ public class Thief {
private int[][] almostRandomMove(boolean[] is, PlayGround p) { private int[][] almostRandomMove(boolean[] is, PlayGround p) {
int[][] destination = new int[1][2]; int[][] destination = new int[1][2];
boolean[] isPoliceThere = is; boolean[] isPoliceThere0 = is, isPoliceThere = new boolean[8];
if (isPoliceThere[0]) { for (int i=0;i<8;i++)
isPoliceThere0[i] = false;
System.out.println("before:");
for (int i = 0;i< 3;i++)
System.out.print(isPoliceThere0[i]+" ");
System.out.println();
for (int i = 3;i<5 ;i++)
System.out.print(isPoliceThere0[i]+" ");
System.out.println();
for (int i =5 ;i<8 ;i++)
System.out.print(isPoliceThere0[i]+" ");
System.out.println("\n\n");
if (isPoliceThere0[0]) {
isPoliceThere[1] = true; isPoliceThere[1] = true;
isPoliceThere[3] = true; isPoliceThere[3] = true;
} }
if (isPoliceThere[1]) { if (isPoliceThere0[1]) {
isPoliceThere[0] = true; isPoliceThere[0] = true;
isPoliceThere[2] = true; isPoliceThere[2] = true;
isPoliceThere[3] = true; isPoliceThere[3] = true;
isPoliceThere[4] = true; isPoliceThere[4] = true;
} }
if (isPoliceThere[2]) { if (isPoliceThere0[2]) {
isPoliceThere[1] = true; isPoliceThere[1] = true;
isPoliceThere[4] = true; isPoliceThere[4] = true;
} }
if (isPoliceThere[3]) { if (isPoliceThere0[3]) {
isPoliceThere[1] = true; isPoliceThere[1] = true;
isPoliceThere[0] = true; isPoliceThere[0] = true;
isPoliceThere[5] = true; isPoliceThere[5] = true;
isPoliceThere[6] = true; isPoliceThere[6] = true;
} }
if (isPoliceThere[4]) { if (isPoliceThere0[4]) {
isPoliceThere[1] = true; isPoliceThere[1] = true;
isPoliceThere[2] = true; isPoliceThere[2] = true;
isPoliceThere[6] = true; isPoliceThere[6] = true;
isPoliceThere[7] = true; isPoliceThere[7] = true;
} }
if (isPoliceThere[5]) { if (isPoliceThere0[5]) {
isPoliceThere[6] = true; isPoliceThere[6] = true;
isPoliceThere[3] = true; isPoliceThere[3] = true;
} }
if (isPoliceThere[6]) { if (isPoliceThere0[6]) {
isPoliceThere[4] = true; isPoliceThere[4] = true;
isPoliceThere[3] = true; isPoliceThere[3] = true;
isPoliceThere[5] = true; isPoliceThere[5] = true;
isPoliceThere[7] = true; isPoliceThere[7] = true;
} }
if (isPoliceThere[7]) { if (isPoliceThere0[7]) {
isPoliceThere[4] = true; isPoliceThere[4] = true;
isPoliceThere[6] = true; isPoliceThere[6] = true;
} }
for (int i = 0;i< 3;i++)
System.out.print(isPoliceThere[i]+" ");
System.out.println();
for (int i = 3;i<5 ;i++)
System.out.print(isPoliceThere[i]+" ");
System.out.println();
for (int i =5 ;i<8 ;i++)
System.out.print(isPoliceThere[i]+" ");
System.out.println();
if (!isPoliceThere[0] || !isPoliceThere[1] || !isPoliceThere[2] || !isPoliceThere[3] || !isPoliceThere[4] || !isPoliceThere[5] || !isPoliceThere[6] || !isPoliceThere[7]) { if (!isPoliceThere[0] || !isPoliceThere[1] || !isPoliceThere[2] || !isPoliceThere[3] || !isPoliceThere[4] || !isPoliceThere[5] || !isPoliceThere[6] || !isPoliceThere[7]) {
Random r = new Random(); Random r = new Random();
int i = 0; int i = 0;
...@@ -290,12 +317,13 @@ public class Thief { ...@@ -290,12 +317,13 @@ public class Thief {
} }
} }
i++; i++;
if (i > 50) { if (i > 1900) {
randomMove(p.getNM()[0][0], p.getNM()[0][1], p); randomMove(p.getNM()[0][0], p.getNM()[0][1], p);
return null; return null;
} }
} while (true); } while (true);
} else { } else {
System.out.println("STAYYYYYYYYYYYYYYYYYYYYYY");
destination[0][0] = x; destination[0][0] = x;
destination[0][1] = y; destination[0][1] = y;
return destination; return destination;
......
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