objectdef brain { variable point3f Sav variable uint Thought=0 variable point3f Destination variable bool Iam=0 variable int WaitForIt=${Math.Calc[${LavishScript.RunningTime}+(250*1)]} method Initialize() { This:ImHere ;Self Test This:SelfTest } method ErrorCycle() { ;Upper brain needs a nap Controlo.ErrorON:Set[1] do { } while ${Script[robot](exists)} Controlo.ErrorON:Set[0] } method SelfTest() { echo Right ${body.Right5metersBlocked} echo Left ${body.Left5metersBlocked} echo Eyes ${eyes.Blocked} } method PureImpulse() { if ${Iam} Iam:Set[0] } method Motivate(float gohereX,float gohereY,float gohereZ) { echo GOX ${gohereX} GOY ${gohereY} Destination.X:Set[${gohereX}] Destination.Y:Set[${gohereY}] Destination.Z:Set[${gohereZ}] ;face ${gohereX} ${gohereY} Iam:Set[1] } method Think() { if ${Math.Distance[${Me.X},${Me.Y},${Me.Z},${Destination.X},${Destination.Y},${Destination.Z}]}<5 { Iam:Set[0] } ;if ${Math.Distance[${Me.X},${Me.Y},${Me.Z},${Sav.X},${Sav.Y},${Sav.Z}]}>5 ; { ; This:ImHere ; } if ${body.moving}&&!${Thought}==0 { if ${mybrain.Iam} { move forward } Thought:Set[0] echo "FORWARD!" return } if !${body.moving}&&!${Thought}==1 { if ${mybrain.Iam} { move backward } echo "BACK!" Thought:Set[1] } if ${Thought}==0&&!${body.moving} { if !${body.Left5metersBlocked} { echo "Back right" Face -heading ${Math.Calc[${Me.Heading}-10]} } if !${body.Right5metersBlocked} { Face -heading ${Math.Calc[${Me.Heading}+15]} echo "back left" } if ${body.Right5metersBlocked}&&${body.Left5metersBlocked} { Face -heading ${Math.Calc[${Me.Heading}-180*100%36000/100]} } Thought:Set[0] return } if ${eyes.Blocked}&&${Iam} { if !${body.Ground}&&${Iam} { echo "NO FUCKING GROUND" move -stop ;face ${Destination.X} ${Destination.Y} } if !${body.Left5metersBlocked} { ;move left ;if !${body.Ground} Face -heading ${Math.Calc[${Me.Heading}-10]} ;move left return } if !${body.Right5metersBlocked} { ;move right Face -heading ${Math.Calc[${Me.Heading}+10]} ;if !${body.Ground} ;Face -heading ${Math.Calc[${Me.Heading}+50]} ;move right Thought:Set[1] return } if ${body.Right5metersBlocked}&&${body.Left5metersBlocked} { ;variable int reverse ;reverse:Set[${Math.Calc[${Me.Heading}-180]}] ;if ${reverse}<0 ;reverse:Set[${Math.Calc[${reverse}+360]}] ;echo ${reverse} ;move -stop ;Face -heading ${Math.Calc[${Me.Heading}+10]} ;face ${Destination.X} ${Destination.Y} Face -heading ${Math.Calc[${Me.Heading}-180]} ;wowpress jump ;Script[fnrobot]:End return } } ; ;Hrm where is the destination ;if ${LavishScript.RunningTime}<${WaitForIt} ; { ;echo "in ${Time.Timestamp}" ;if ${Math.Distance[${Me.X},${Me.Y},${Me.Z},${SavX},${SavY},${SavZ}]}>7 ;{ ;Face -heading ${Math.Calc[${Me.Heading}+3]} ;This:ImHere ;} ;look ahead turn random left or right if blocked ;WaitForIt:Set[${Math.Calc[${LavishScript.RunningTime}+(1000*1)]}] ;} } method ImHere() { Sav.X:Set[${Me.X}] Sav.Y:Set[${Me.Y}] Sav.Z:Set[${Me.Z}] } } objectdef bodyo { variable bool moving variable point3f StoredLocation variable uint FeelAhead=3 method Initialize() { This:ImHere } method Feel() { ;echo ${Me.X} ${Me.Y} ; ${Math.Distance[${Me.X},${Me.Y},${This.StoredLocation.X},${This.StoredLoction.Y}]} if ${Math.Distance[${Me.X},${Me.Y},${StoredLocation.X},${StoredLocation.Y}]}>1 { This.moving:Set[1] StoredLocation.X:Set[${Me.X}] StoredLocation.Y:Set[${Me.Y}] StoredLocation.Z:Set[${Me.Z}] mybrain.WaitForIt:Set[${Math.Calc[${LavishScript.RunningTime}+(250*1)]}] } else { moving:Set[0] } } member Left5metersBlocked() { variable point3f FeelPoint variable float bearing bearing:Set[${Math.Calc[${Me.Heading}-45]}] if ${bearing}<360 bearing:Set[${Math.Calc[${bearing}+360]}] FeelPoint.X:Set[ ${Me.X} + ${Math.Cos[${Math.Calc[${bearing}]}].Precision[6]} * ${FeelAhead} ] FeelPoint.Y:Set[ ${Me.Y} - ${Math.Sin[${Math.Calc[${bearing}]}].Precision[6]} * ${FeelAhead} ] ;echo Left X :${FeelPoint.X} Y : ${FeelPoint.Y} heading ${Me.Heading} Distance ${Math.Distance[${Me.X},${Me.Y},${FeelPoint.X},${FeelPoint.Y}]} if ${Me.IsPathObstructed[${FeelPoint.X},${FeelPoint.Y},${Math.Calc[${Me.Z}]},10]} { echo "Left BLIND" return 1 } ;echo "I SEE" return 0 } member Right5metersBlocked() { variable point3f FeelPoint variable float bearing variable float radians bearing:Set[${Math.Calc[${Me.Heading}+45]}] if ${bearing}>360 bearing:Set[${Math.Calc[${bearing}-360]}] FeelPoint.X:Set[ ${Me.X} + ${Math.Cos[${Math.Calc[${bearing}]}].Precision[6]} * ${FeelAhead} ] FeelPoint.Y:Set[ ${Me.Y} - ${Math.Sin[${Math.Calc[${bearing}]}].Precision[6]} * ${FeelAhead} ] echo Right X :${FeelPoint.X} Y : ${FeelPoint.Y} heading ${Me.Heading} new bearing ${bearing} Distance ${Math.Distance[${Me.X},${Me.Y},${FeelPoint.X},${FeelPoint.Y}]} if ${Me.IsPathObstructed[${FeelPoint.X},${FeelPoint.Y},${Math.Calc[${Me.Z}]},10]} { echo "Right BLIND" return 1 } echo "Right Good" return 0 ;Script[test]:End } member Ground() { variable point3f FeelPoint FeelPoint.X:Set[ ${Me.X} + ${Math.Cos[${Me.Heading}].Precision[6]} * 5 ] FeelPoint.Y:Set[ ${Me.Y} - ${Math.Sin[${Me.Heading}].Precision[6]} * 5 ] echo Right X :${FeelPoint.X} Y : ${FeelPoint.Y} heading ${Me.Heading} new bearing ${bearing} Distance ${Math.Distance[${Me.X},${Me.Y},${FeelPoint.X},${FeelPoint.Y}]} if ${Me.IsPathObstructed[${FeelPoint.X},${FeelPoint.Y},${Math.Calc[${Me.Z}-3]},5]} { echo "Heres ground" return 1 } echo "no ground" return 0 ;Script[test]:End } method ImHere() { StoredLocation.X:Set[${Me.X}] StoredLocation.Y:Set[${Me.Y}] StoredLocation.Z:Set[${Me.Z}] } ;ok give me a chance to move } objectdef consciouso { ;I want cheese ;whats the map member Left(float X,float Y) { variable point3f FeelPoint variable float bearing bearing:Set[${Math.Calc[${Me.Heading}-45]}] if ${bearing}<360 bearing:Set[${Math.Calc[${bearing}+360]}] FeelPoint.X:Set[ ${X} + ${Math.Cos[${Math.Calc[${bearing}]}].Precision[6]} * ${Look} ] FeelPoint.Y:Set[ ${Y} - ${Math.Sin[${Math.Calc[${bearing}]}].Precision[6]} * ${Look} ] ;echo Left X :${FeelPoint.X} Y : ${FeelPoint.Y} heading ${Me.Heading} Distance ${Math.Distance[${Me.X},${Me.Y},${FeelPoint.X},${FeelPoint.Y}]} if ${Me.IsPathObstructed[${FeelPoint.X},${FeelPoint.Y},${Math.Calc[${Me.Z}]},10]} { echo "Left BLIND" return 1 } ;echo "I SEE" return 0 } member Right(float X,float Y) { variable point3f FeelPoint variable float bearing variable float radians bearing:Set[${Math.Calc[${Me.Heading}+45]}] if ${bearing}>360 bearing:Set[${Math.Calc[${bearing}-360]}] FeelPoint.X:Set[ ${Me.X} + ${Math.Cos[${Math.Calc[${bearing}]}].Precision[6]} * ${Look} ] FeelPoint.Y:Set[ ${Me.Y} - ${Math.Sin[${Math.Calc[${bearing}]}].Precision[6]} * ${Look} ] echo Right X :${FeelPoint.X} Y : ${FeelPoint.Y} heading ${Me.Heading} new bearing ${bearing} Distance ${Math.Distance[${Me.X},${Me.Y},${FeelPoint.X},${FeelPoint.Y}]} if ${Me.IsPathObstructed[${FeelPoint.X},${FeelPoint.Y},${Math.Calc[${Me.Z}]},10]} { echo "Right BLIND" return 1 } echo "Right Good" return 0 } member ahead(float X,float Y) { SeePoint.X:Set[ ${X} + ${Math.Cos[${Math.Calc[${Me.Heading}]}].Precision[6]} * ${Look} ] SeePoint.Y:Set[ ${Y} - ${Math.Sin[${Math.Calc[${Me.Heading}]}].Precision[6]} * ${Look} ] } ;move towards the cheese please } objectdef eyeso { variable uint LookAhead=1 variable point3f SeePoint member Blocked() { ;variable uint i=${LookAhead} ;do ;{ SeePoint.X:Set[ ${Me.X} + ${Math.Cos[${Math.Calc[${Me.Heading}]}].Precision[6]} * ${LookAhead} ] SeePoint.Y:Set[ ${Me.Y} - ${Math.Sin[${Math.Calc[${Me.Heading}]}].Precision[6]} * ${LookAhead} ] ;${i:Dec} ;} ;while ${Me.IsPathObstructed[${SeePoint.X},${SeePoint.Y},${Math.Calc[${Me.Z]},5]}&&${i}<=${LookAhead}&&${i}>0 ;if ${i}<4&&${i<0} ;{ ;face ${SeePoint.X} ${SeePoint.Y} ;echo Front X :${SeePoint.X} Y : ${SeePoint.Y} heading ${Me.Heading} Distance ${Math.Distance[${Me.X},${Me.Y},${SeePoint.X},${SeePoint.Y}]} ;return ;} if ${Me.IsPathObstructed[${SeePoint.X},${SeePoint.Y},${Math.Calc[${Me.Z}]},10]} { ;look up if !${Me.IsPathObstructed[${SeePoint.X},${SeePoint.Y},${Math.Calc[${Me.Z}+7]},10]} { ;move -stop echo "INCLINE" return 2 } ;Script[fnrobot]:End echo "BLIND" return 1 } ;echo "I SEE" return 0 } } function main() { declare Nerves string global declare mybrain brain global declare body bodyo global ;declare Destination point3f global declare eyes eyeso global ;Destination:Set[10697.55,764.85,1321.47] Event[OnFrame]:AttachAtom[Pulseon] do { } while 1 } function atexit() { move -stop } atom(global) Pulseon() { mybrain:Think conscious:Drive ears:Balance mybrain:Do mybrain:Move eyes:Look if ${LavishScript.RunningTime}>${mybrain.WaitForIt} body:Feel }