import java.util.*; public class ai { private int xl, yl, nl; private int xp, yp, np; private int[] pr = {0,1,2,3}; private int[] n = {0,1,2,3}; private int num1; private Random rnd; private boolean n1, n2, n3, n4; public ai() { rnd = new Random(); cont cont = new cont(); } /* тута статик написал */ public static void intel(int x, int y, int w, int h, int nap, int dx, int dy) { loader(x,y,nap); analizer(x, y, w, h); switch(nap){ case 0: pr[2] = 0; break; case 1: pr[3] = 0; break; case 2: pr[0] = 0; break; case 3: pr[1] = 0; break; } analizePr(x, y, dx, dy); count(); nl = 0; cont.nx = xl; cont.ny = yl; cont.nn = nl; } public void count(){ int App = 0; switch(num1){ case 0: yl -= cont.speed; nl = 1; App = 1; break; case 1: xl += cont.speed; App = 1; nl = 2; break; case 2: yl += cont.speed; App = 1; nl = 3; break; case 3: xl -= cont.speed; App = 1; nl = 4; break; } if (App == 0) { int state2 = 0; if ( n[0] == 1) { yl -= cont.speed; state2 = 1; } if (n[1] == 1&&state2 == 0) { xl += cont.speed; state2 = 1; } if (n[2] == 1&&state2 == 0) { yl += cont.speed; state2 = 1; } if (n[3] == 1&&state2 == 0) { xl -= cont.speed; state2 = 1; } if (state2 == 0) { if (n[0] == 0) yl -= cont.speed; if (n[1] == 0) xl += cont.speed; if (n[2] == 0) yl += cont.speed; if (n[0] == 0) xl -= cont.speed; } } } /* тута статик написал */ private static void analizePr(int x,int y,int desx,int desy) { for (int i=0;i<4;i++) { pr[i] = 1; } if (x-desx<0) n[1] = 2; if (x-desx>0) n[3] = 2; if (y-desy<0) n[2] = 2; if (y-desy>0) n[0] = 2; if (pr[0] == 0&&pr[1] == -1&&pr[2] == -1&&pr[3] == -1) pr[0] = 2; if (pr[1] == 0&&pr[0] == -1&&pr[2] == -1&&pr[3] == -1) pr[1] = 2; if (pr[2] == 0&&pr[1] == -1&&pr[0] == -1&&pr[3] == -1) pr[2] = 2; if (pr[3] == 0&&pr[1] == -1&&pr[2] == -1&&pr[0] == -1) pr[3] = 2; if (n[0] == 2) num1 = 0; if (n[1] == 2) num1 = 1; if (n[2] == 2) num1 = 2; if (n[3] == 2) num1 = 3; } /* тута статик написал */ private static void loader(int x,int y,int nap) { xp = x; yp = y; np = nap; xl = xp; yl = yp; } /* тута статик написал */ public static void analizer(int x,int y,int w, int h) { for (int i=0;i<3;i++) { for (int alti=0;alti<2;alti++) { if (check(x,y,w,h,cont.x[alti],cont.y[alti],cont.w[alti],cont.h[alti])) pr[i] = -1; } } } public int rand(int max) { return rnd.nextInt(max+1); } private boolean check(int x,int y,int w,int h,int tx,int ty,int tw,int th) { if (x+w>tx&&xx&&txx&&txtx&&x