Robot Battle Home Log In | Register
Welcome Guest
Help | Search | Members | Contest Calendar | Chat

Robot Battle Registry  Discussion Forums  New Robots  At Field Ii
 
At Field Ii Track this topic | Email this topic | Print this topic 
thrasybulus
Posted: Apr 5 2005, 02:29 PM


Dedicated Player


Group: Moderators
Posts: 184 (2 robots)
Member No.: 217
Joined: 12-June 04



The modifications that i made to the AT Field permit update the shield while the bot is moving. The changes are marked with the comment style: // -------------> comments
CODE
Init{
   at.x=_xpos
   at.y=_ypos
   at=99999                                                           # encryption code for radio (can change it)
   at.id=_id
   at.dist=40                                                         # Field Distance
   at.maxid=-1
#    blocking(0)          // -------> remove this line (don't work)     # needed to be able to check each turn
   regcore(core)
   regradio(radio,1)
   regcustom (Update, 2, (_velocity != recvelocity) || (((_velocity/25)^2 == 1) && (recturn != _turns)))}
   //  ---------------> Custom event to update the shield when the bot is moving

Update                                      //   ------------> Custom section
{
   gosub(Pulse)                            // -------> update the shield                          
   at.x=_xpos
   at.y=_ypos
   radiosend(0,at)
   
   recturn = _turns                        // -------> update the rec variables
   recvelocity = _velocity
}
       
Core{
   gosub(Pulse)                                                       #Checks for field interferance every turn
   at.x=_xpos
   at.y=_ypos
   radiosend(0,at)
   
   recvelocity = _velocity   //  ------> Put this line before a Lateral Movement command
   recturn = _turns   // --------------> Put this line before a Lateral Movement command
#(e.g.)    ahead (x) or back (x)  
}                                                   # Send away the Info

Radio{    
   n=0
   while(n<_radiocomm)
#        hasprop(_radiocomm[n]._msg, "id")  //  ---------------> remove this line
#        if(_radiocomm[n]._msg==at and _result==1)  //  -------> remove this line
       if(_radiocomm[n]._msg==at)  //  ----------------------> added
           copy(sig[_radiocomm[n]._msg.id],_radiocomm[n]._msg)
           if(_radiocomm[n]._msg.id>at.maxid)
               at.maxid=_radiocomm[n]._msg.id             # only check the id's we need to
           endif
       endif
       n=n+1
   endw}

Pulse{    
   n=0
   while(n<=at.maxid)
       if(sig[n]==at)
           temp1=((_xpos-sig[n].x)^2+(_ypos-sig[n].y)^2)^.5   # distance between each bot
           temp2=at.dist+sig[n].dist                          # field distance between each bot
           if(temp1<temp2)  
               gosub(response)  
           endif
       endif
       n=n+1
   endw}

Response{}                                                      # Put what your robot wants to do here


Enjoy, and say what you think about this. biggrin.gif


--------------------
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s:+ a-- C++(++++) UL++++ P+++ L+++>++++ E W+(+++) w Y+ t+ R+ tv b+++(++++) G+++ e* h! r y?
-----END GEEK CODE BLOCK-----
 
    Top

thrasybulus
Posted: Apr 7 2005, 09:17 AM


Dedicated Player


Group: Moderators
Posts: 184 (2 robots)
Member No.: 217
Joined: 12-June 04



A more practical code to update the shield while moving.
CODE
Init{
   at.x=_xpos
   at.y=_ypos
   at=99999                                                           # encryption code for radio (can change it)
   at.id=_id
   at.dist=40                                                         # Field Distance
   at.maxid=-1
#    blocking(0)          // -------> remove this line (don't work)     # needed to be able to check each turn
   regcore(core)
   regradio(radio,1)
   regascan (Update, 2)}  //  ---------------> Event to update the shield when the bot is moving

Update                                      
{
   gosub(Pulse)                            // -------> update the shield                          
   at.x=_xpos
   at.y=_ypos
   radiosend(0,at)
}
       
Core{
   gosub(Pulse)                                                       #Checks for field interferance every turn
   at.x=_xpos
   at.y=_ypos
   radiosend(0,at)
}                                                   # Send away the Info

Radio{    
   n=0
   while(n<_radiocomm)
#        hasprop(_radiocomm[n]._msg, "id")  //  ---------------> remove this line
#        if(_radiocomm[n]._msg==at and _result==1)  //  -------> remove this line
       if(_radiocomm[n]._msg==at)  //  ----------------------> added
           copy(sig[_radiocomm[n]._msg.id],_radiocomm[n]._msg)
           if(_radiocomm[n]._msg.id>at.maxid)
               at.maxid=_radiocomm[n]._msg.id             # only check the id's we need to
           endif
       endif
       n=n+1
   endw}

Pulse{    
   n=0
   while(n<=at.maxid)
       if(sig[n]==at)
           temp1=((_xpos-sig[n].x)^2+(_ypos-sig[n].y)^2)^.5   # distance between each bot
           temp2=at.dist+sig[n].dist                          # field distance between each bot
           if(temp1<temp2)  
               gosub(response)  
           endif
       endif
       n=n+1
   endw}

Response{}                                                      # Put what your robot wants to do here


Enjoy, and say what you think about this. biggrin.gif


--------------------
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s:+ a-- C++(++++) UL++++ P+++ L+++>++++ E W+(+++) w Y+ t+ R+ tv b+++(++++) G+++ e* h! r y?
-----END GEEK CODE BLOCK-----
 
    Top

MrFox
Posted: Apr 7 2005, 09:35 AM


Tactical Engineer


Group: Moderators
Posts: 1114 (8 robots)
Member No.: 27
Joined: 23-May 03



I've noticed that you and Echo Swtch have left it up to the user to decide what action to take in Response{} to the

breach.

I'd like to see some example of what to do in Response{}. I mean, would you handle it like a robot collision? i.e

RSL
CollideRobot{
    if(cldbearing<90&cldbearing>-90)
    back(15)
    else
    ahead(15)
    endif
    bodyright(10)
}


I would, of course, change the cldbearing to the bearing of the robot I am breaching. Or the bearing to (sig[n].x,sig[n].y), right?


--------------------
"Life is inevitable."
Me

See profile for Authored Robots and Contest Standings.
Robots(7): Lunatic Frenzy, JAM, ittyBot, ZenBot,
ZenBittyBot,RadFly,Omni
 
    Top

thrasybulus
Posted: Apr 25 2005, 07:32 AM


Dedicated Player


Group: Moderators
Posts: 184 (2 robots)
Member No.: 217
Joined: 12-June 04



I add the sig[n].bearing variable to avoid the need to use the sig[n].x and sig[n].y to do the calculations to achieve the bearing, and I've done some little tweak to the code.
RSL
Init{
   at=99999                                                           # encryption code for radio (can change it)
   at.id=_id
   at.dist=40                                                         # Field Distance
   at.maxid=-1
   regcore(core)
   regradio(radio,1)
   regascan (Update, 2)}  //  ---------------> Event to update the shield when the bot is moving

Update                                      
{
   gosub(Pulse)                            // -------> update the shield                          
   at.x=_xpos
   at.y=_ypos
   radiosend(0,at)
}
   
Core{
   gosub(Pulse)                                                       #Checks for field interference every turn
   at.x=_xpos
   at.y=_ypos
   radiosend(0,at)
}

Radio{    
   n=0
   while(n<_radiocomm)
       if(_radiocomm[n]._msg==at)
           copy(sig[_radiocomm[n]._msg.id],_radiocomm[n]._msg)
           sig[_radiocomm[n]._msg.id].bearing = _radiocomm[n]._bearing # Bearing to the sender when the message was received
           if(_radiocomm[n]._msg.id>at.maxid)
               at.maxid=_radiocomm[n]._msg.id             # only check the id's we need to
           endif
       endif
       n=n+1
   endw}

Pulse{    
   n=0
   while(n<=at.maxid)
       if(sig[n])
           temp1=((_xpos-sig[n].x)^2+(_ypos-sig[n].y)^2)^.5   # distance between each bot
           temp2=at.dist+sig[n].dist                          # field distance between each bot
           if(temp1<temp2)  
               gosub(response)  
           endif
       endif
       n=n+1
   endw}
Response{}                                                      # Put what your robot wants to do here

Echo Switch, if you want to use the modifications that i made to your code as a official release to me it's OK smile.gif


--------------------
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s:+ a-- C++(++++) UL++++ P+++ L+++>++++ E W+(+++) w Y+ t+ R+ tv b+++(++++) G+++ e* h! r y?
-----END GEEK CODE BLOCK-----
 
    Top

<< Back to New Robots