Post your most useful functions in here!
Preferably with comments on each inside the code, a very simple AI using them and an optional example print of each to show what they return in action.
Here is an example:
you can uncomment the ego(); inside the void function to stop the script from printing everything.
after the main id function I have quite a few more void functions that only simplify certain actions (such as defending against the target or turning around)
and after the ego function i have mostly bool functions to help easy decision making with the ego function printing all of them
right now this AI is only evasive and defensive (against all hostile objects)
i have yet to try and dodge diagonal attacks too (only doing straight ones now)
after that i might have a go at target picking and approaching
maybe this can turn into a pretty good basic AI
ALSO I CHALLENGE YOU TO TRY AND GRAB THE ABOVE AI IN A FIGHT (any original characters allowed - LOUIS D^J DOES NOT COUNT)
tell me how you did it if you succeed
Preferably with comments on each inside the code, a very simple AI using them and an optional example print of each to show what they return in action.
Here is an example:
|
C-Code:
void id(){ clr(); ego(); inputs(); if(danger()){stall();} else if(marked()){dodge();} } void defend(){ //turn against target and defend if(!facing_against()){turn_self();} D(1,0); } void dodge(){ //walk out of zrange if((zdistance()>0&&zborder1()>15)||zborder2()<=15){up(1,0);}else{down(1,0);} } void inputs(){ //void inputs up(0,0);down(0,0);left(0,0);right(0,0);D(0,0);J(0,0);A(0,0); } void stall(){ //flip or defend if(self.state==12){J(1,0);}else{defend();} } void turn_self(){ //turn around if(self.facing){right(1,0);}else{left(1,0);} } int ego(){ if(target.num==self.num){return 1;} print("target: "+target.num+" id: "+target.id+" type: "+target.type+"\n\n"); print("danger: "+danger()+"\n\n"); print("facing_against : "+facing_against()+"\n"); print("facing_distance: "+facing_distance()+"\n\n"); print("marked: "+marked()+"\n\n"); print("range(0,100,self.x): "+range(0,100,self.x)+"\n\n"); print("will_collide: "+will_collide()+"\n\n"); print("xdistance : "+xdistance()+"\n"); print("xrange(50,150): "+xrange(50,150)+"\n\n"); print("zborder1 : "+zborder1()+"\n"); print("zborder2 : "+zborder2()+"\n"); print("zdistance : "+zdistance()+"\n"); print("zrange(15,25): "+zrange(15,25)+"\n\n"); print("self_attacking : "+self_attacking()+"\n"); print("target_attacking: "+target_attacking()+"\n\n"); print("self_dop : "+self_dop()+"\n"); print("target_dop: "+target_dop()+"\n\n"); print("self_facing : "+self_facing()+"\n"); print("target_facing: "+target_facing()+"\n\n"); print("self_frame(0,8) : "+self_frame(0,8)+"\n"); print("target_frame(0,8): "+target_frame(0,8)+"\n\n"); print("self_ground : "+self_ground()+"\n"); print("target_ground: "+target_ground()+"\n\n"); print("self_hitable : "+self_hitable()+"\n"); print("target_hitable: "+target_hitable()+"\n\n"); print("self_knockable : "+self_knockable()+"\n"); print("target_knockable: "+target_knockable()+"\n\n"); print("self_open : "+self_open()+"\n"); print("target_open: "+target_open()+"\n\n"); return 1; } bool danger(){ //is there a dangerous object within range? int k=target.num; for (int i=0;i<400;++i){ if (loadTarget(i)!=-1&&target.team!=self.team&&zrange(0,15)&&xrange(0,80)&&target_attacking()){ return true; } } if(loadTarget(k)==-1){loadTarget(self.num);} return false; } bool facing_against(){ //true if self and target face opposite directions return (self.facing!=target.facing)?true:false; } int facing_distance(){ //positive: target distance to the front return -xdistance()*(2*(self.facing?1:0)-1); } bool marked(){ //is there a dangerous object intercepting with self position? int k=target.num; for (int i=0;i<400;++i){ if (loadTarget(i)!=-1&&target.team!=self.team&&will_collide()&&target_attacking()){ return true; } } if(loadTarget(k)==-1){loadTarget(self.num);} return false; } bool range(int min, int max, int value){ //true if between min and max return (value>=min&&value<=max)?true:false; } bool will_collide(){ //is there an object within zrange straight flying towards self? return((zrange(0,15)&&target.z_velocity==0)&&target.x_velocity*xdistance()<0)?true:false; } int xdistance(){ //positive: target distance to the right return target.x-self.x; } bool xrange(int min, int max){ //true if between min and max return range(min,max,abs(xdistance())); } int zborder1(){ //distance to the top return target.z-bg_zwidth1; } int zborder2(){ //distance to the bottom return bg_zwidth2-target.z; } int zdistance(){ //positive: target distance to the bottom return target.z-self.z; } bool zrange(int min, int max){ //true if between min and max return range(min,max,abs(zdistance())); } bool self_attacking(){ //true if self within state: 3* or 18 or 19 or 1002 or 2000 int x=self.state; int i=0; do{x/=10;i++;}while(x>0); x=1; for(i;i>1;--i){x*=10;} return (self.state/x==3||self.state==18||self.state==19||target.state==1002||target.state==2000)?true:false; } bool target_attacking(){ //true if target within state: 3* or 18 or 19 or 1002 or 2000 int x=target.state; int i=0; do{x/=10;i++;}while(x>0); x=1; for(i;i>1;--i){x*=10;} return (target.state/x==3||target.state==18||target.state==19||target.state==1002||target.state==2000)?true:false; } bool self_dop(){ //true if within dance of pain/catchable return (self.state==16)?true:false; } bool target_dop(){ //true if within dance of pain/catchable return (target.state==16)?true:false; } bool self_facing(){ //true if self facing target return (facing_distance()>0)?true:false; } bool target_facing(){ //true if target facing self return (xdistance()*(2*(target.facing?1:0)-1)>0)?true:false; } bool self_frame(int min, int max){ //true if between min and max return range(min,max,self.frame); } bool target_frame(int min, int max){ //true if between min and max return range(min,max,target.frame); } bool self_ground(){ //true if self on ground return (self.y==0&&self.state!=4&&self.state!=5&&self.state!=12)?true:false; } bool target_ground(){ //true if target on ground return (target.y==0&&target.state!=4&&target.state!=5&&target.state!=12)?true:false; } bool self_hitable(){ //true if self hitable return (self.blink==0&&self.state!=6&&self.state!=12&&self.state!=14)?true:false; } bool target_hitable(){ //true if target hitable return (target.blink==0&&target.state!=6&&target.state!=12&&target.state!=14)?true:false; } bool self_knockable(){ //true if self knockable return (self.blink==0&&self.state!=6&&self.state!=14)?true:false; } bool target_knockable(){ //true if target knockable return (target.blink==0&&target.state!=6&&target.state!=14)?true:false; } bool self_open(){ //true if immobile for a longer period return (self_dop()||self.state==8||self.state==13||self_frame(130,132))?true:false; } bool target_open(){ //true if immobile for a longer period return (target_dop()||target.state==8||target.state==13||target_frame(130,132))?true:false; } |
after the main id function I have quite a few more void functions that only simplify certain actions (such as defending against the target or turning around)
and after the ego function i have mostly bool functions to help easy decision making with the ego function printing all of them
right now this AI is only evasive and defensive (against all hostile objects)
i have yet to try and dodge diagonal attacks too (only doing straight ones now)
after that i might have a go at target picking and approaching
maybe this can turn into a pretty good basic AI
ALSO I CHALLENGE YOU TO TRY AND GRAB THE ABOVE AI IN A FIGHT (any original characters allowed - LOUIS D^J DOES NOT COUNT)
tell me how you did it if you succeed

Chat


I can record gameplay if u cannot do it.