import java.util.*; public class ai { private int xl,yl,nl; private int xp,yp,np; private int pr=new int[4]; private int n=new int[4]; private int num1; private Random rnd; private boolean n1,n2,n3,n4; /** * constructor */ public ai() { rnd=new Random(); cont cont=new cont(); triger t= new triger(); } public 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 1: pr[2]=0; break; case 2: pr[3]=0; break; case 3: pr[0]=0; break; case 4: pr[1]=0; break; } analizePr(x,y,dx,dy); count(); cont.nx=lx; cont.ny=ly; cont.nn=ln; } 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 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 void loader(int x,int y,int nap){ xp=x; yp=y; np=nap; xl=xp; yl=yp; } public void analayzer(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) 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