Commit 8e1b2215 authored by hosein's avatar hosein

finish

parent 218b9ba1
......@@ -71,12 +71,17 @@ public class Main {
if (playGround.getCatchThief()) {
break;
} else playGround.show(1200);
System.out.print("\n\n\n\n");
System.out.print("\f\n\n\n\n");
/*
FIRST MOVE : POLICE
/* thiefSituation = playGround.canPoliceSeeThief();
thiefSituation = playGround.canPoliceSeeThief();
if (thiefSituation == null) {
......
......@@ -29,8 +29,10 @@ public class PlayGround {
System.out.print("-");
else if (ground[i][j] == 1) // police
System.out.print("X");
else // Dozd
else if (ground[i][j] == -1)// Dozd
System.out.print("*");
else
System.out.print("O");
}
System.out.println();
}
......@@ -75,7 +77,11 @@ public class PlayGround {
}
public void changeSituation(int xPrevious, int yPrevious, int xNew, int yNew, int k) {
if (xNew == thiefSituation[0][0] && yNew == thiefSituation[0][1] && k == 1) return;
if (xNew == thiefSituation[0][0] && yNew == thiefSituation[0][1] && k == 1) {
ground[xPrevious][yPrevious] = 0;
ground[xNew][yNew] = 100;
return ;
}
ground[xPrevious][yPrevious] = 0;
ground[xNew][yNew] = k;
if (k == -1) {
......
......@@ -219,7 +219,7 @@ public class Police {
return newSituation;
}
case 1:
if (x != p.getNM()[0][0] && p.isEmpty(x + 1, y - 1)) { // go down, left
if (x != p.getNM()[0][0]-1 && p.isEmpty(x + 1, y - 1)) { // go down, left
newSituation[0][0] = x + 1;
newSituation[0][1] = y - 1;
return newSituation;
......@@ -238,7 +238,7 @@ public class Police {
} else {
switch (r.nextInt(2)) {
case 0:
if (x != p.getNM()[0][0] && p.isEmpty(x + 1, y + 1)) { // go down, right
if (x != p.getNM()[0][0] -1&& p.isEmpty(x + 1, y + 1)) { // go down, right
newSituation[0][0] = x + 1;
newSituation[0][1] = y + 1;
return newSituation;
......@@ -294,7 +294,7 @@ public class Police {
return newSituation;
}
case 1:
if (y != p.getNM()[0][1] && p.isEmpty(x + 1, y + 1)) { // go down, right
if (y != p.getNM()[0][1] -1&& p.isEmpty(x + 1, y + 1)) { // go down, right
newSituation[0][0] = x + 1;
newSituation[0][1] = y + 1;
return newSituation;
......
......@@ -170,21 +170,7 @@ public class Thief {
private int[][] almostRandomMove(boolean[] is, PlayGround p) {
int[][] destination = new int[1][2];
boolean[] isPoliceThere0 = is, isPoliceThere = new boolean[8];
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");
boolean[] isPoliceThere0 = is, isPoliceThere = is;
if (isPoliceThere0[0]) {
......@@ -228,17 +214,6 @@ System.out.println("before:");
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]) {
Random r = new Random();
......
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