ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
a smart way of making a bot walk randomly around (Sdk)
a smart way of making a bot walk randomly around // SdkkahApr 30, 2001, 5:46pm
I'm making a new free animal-bot and I wondered how I could get it to truly
walk randomly around (but within a limited area) like the HamBots and Xelagots ( I think) can... I know that some of you know, so please tell me :-)) KAH cool scripts and bots by me and others: www.kahbot.com jermeMay 1, 2001, 1:00am
Try using a combination of loops...
Get a random # If it's inside your range then move the bot to that location If not then get another random # Wait a radom ammount of time within certin limits (you don't want the bot stadning in one place for hours) Do it all again... I've got an example of this kind of random # checking.. It's in PERL, so i don't know if it would help you that much. E-mail me if you want it. -JerMe -- JerMe at nc.rr.com ---------------------- AIM: AlphaNumeric100 ICQ: 106209991 AW: JerMe (#296967) [View Quote] xelagMay 1, 2001, 1:31am
Can you make your bot move forward, back, left, right, turn etc? This is of
course the basis for any movement. The random element is just a detail really. I use a few routines to move the bot in 3D space. The implementation is visible in the script satement LocMove3D <object> <distance> <horizontal angle> <vertical angle> Trigonometry is essential here :) XelaG [View Quote] kahMay 1, 2001, 8:42am
I use this method for general walking:
sdk.AwMyX = sdk.AwMyX + 1000 'this would make the bot 1 coord to the West sdk.AwStateChange 'reports the stuff the server in C/C++ I guess it would be something like this: AW_MY_X = AW_MY_X + 1000 AW_STATE_CHANGE I dunno about that, cuzz I'm no good at C++ KAH PS. Any VB programmers are welcome to use the code in their bots :-)) [View Quote] m a k a v e l iMay 1, 2001, 4:01pm
If you want the bot to move randomly, to a certain extent in the world you
should use this (may be complicating, but it will work): NewCoord = Int(Rnd * #) + 1 NSEW = Int(Rnd * 2) + 1 If NSEW = 2 Then NewCoord = "-" & NewCoord If you replace # with a max number (Ex: If the world is a 20x20, make that number 20), the bot will generate a random number and the NSEW will pick a number of 1 or 2, if it is 1 the coord will be positive, if it is 2 the coord will be negative. Then you add the code to make it move around, and it will go nuts. If you want it to go around in a circle or something, that is a totally different process. kahMay 1, 2001, 5:45pm
thanx :-)) I actually tought that I might have to use the troncate
command... KAH PS. Do you know of some way of "detatching" parts from a string? if you've scripted HamBot, this would be a kind of Parse feature. [View Quote] grimbleMay 1, 2001, 7:45pm
If you mean to segment a string based on a delimiter, VB has a Split command
that takes a string and breaks it into an array of sub-strings which fall between the delimeters specified. No-one ever seems to know about it because its hidden in the MSDN library documentation somewhere. Check it out at http://msdn.microsoft.com/library/default.asp?URL=/library/devprods/vs6/vbas ic/vbenlr98/vafctSplit.htm Hope this is what you were after. Grims. [View Quote] grimbleMay 1, 2001, 7:47pm
Sorry ... that didn't post right for the hyperlink to make sense ... damned
wrapping!! Just plug it together if you know what I mean. Grims. [View Quote] baronMay 1, 2001, 8:38pm
Thanks, can't remember how many times I've done this manualy. Anything can be said about MS except that they don't hide info like this well :)
Baron [View Quote] rough diamondMay 1, 2001, 9:41pm
int x;
x = 0; while(x <= 10000) ///Walk to 10W { x = x + 1000; // Take 10 steps aw_int_set(AW_MY_X, x); aw_state_change(); } kahMay 4, 2001, 6:01pm
AAAAAAAAAAAAAARGHHH!!! that's a VB6 thingy! I only have VB 5 :-(( please
tell me how I could do it with my version...I guess that there's some way... KAH [View Quote] trekkerxMay 5, 2001, 9:58pm
I dont know much Triganomerty (Cuz im in 8th Grade) But I would make the
program genrate a random number (Something within -1000 thru 1000) and then have it sdk.AwMyX = (sdk.AwMyX + randnum) sdk.AwMyZ = (sdk.AwMyZ + randnum) I wouldent know the forumla for figuring out the angel the bot should face when it stops moving. XelaG or Grimble might know more about that than I would. But would would do it something like that. [View Quote] > I use this method for general walking: > > sdk.AwMyX = sdk.AwMyX + 1000 'this would make the bot 1 coord to the West > sdk.AwStateChange 'reports the stuff the server > > in C/C++ I guess it would be something like this: > AW_MY_X = AW_MY_X + 1000 > AW_STATE_CHANGE > I dunno about that, cuzz I'm no good at C++ > > KAH > PS. Any VB programmers are welcome to use the code in their bots :-)) [View Quote] xelagMay 6, 2001, 9:00am
[View Quote]
The problem with your formula is simply that you will get a bot with
parkinsons disease, jumping madly in all directions. :) You need to have some stability in the way the bot is facing and going, and some random element to deviate from that. The basis is ok: AwMyX + something1 AwMyZ + something2 you must also have AwMyYaw + something3 and may even need AwMyY + something4 if it is a bird. it's the "something1/2/3/4" which is the problem. The AwMyYaw is actually where you must start, and that's where trigonometry comes in: the bot must walk roughly in the direction it is already facing, but deviating its AWMyX, AwMyZ and maybe AwMyY slightly from it's present position, and then recalculate and adjust its new AwMyYaw for the next step. I could send you some code in Delphi, but you would have to translate it to VB... and you still need a some knowledge of trigonometry to apply it correctly. Another solution would be that MrGrimms adds some code to his sdk to help with that, something like I have in my xelagot script, to move the bot D metres at a H horizontal angle and a V vertical angle, and a way to determine the new Yaw. XelaG kahMay 6, 2001, 11:02am
the bot looks the way it runs with the code I used (thanx m a k a v e l i),
but it runs way to fast, and to get it to run at a slightly slower rate, I have parametered it only to run within a 2 coords big radius. I'd like to have it moving on a larger radius, but slow... KAH [View Quote] trekkerxMay 6, 2001, 4:12pm
I think Mr Grimm shoudl add a Follow, and Join command, cuz doign the math is
hard, and theres to many lines. And keeping track of everyones location isnt easy (the way i know how to do it) [View Quote] [View Quote] m a k a v e l iMay 6, 2001, 6:02pm
Or, you could get unlazy and do it yourself, joining someone is easy, and
follow is also. To Join: Private Sub sdk_EventChat() Message = LCase(sdk.AwChatMessage) If Message = "join" Then sdk.AwMyX = sdk.AwAvatarX <etc..> End If End Sub To Follow: Loop the above code.. very simple, all you have to do is think. trekkerxMay 6, 2001, 6:18pm
Uhhhh, yea.... But it will then join the person that moves, and it will be
right on top of them. On my bot I have it keep the location of owners. It then will apper 2 and half meeters infron of them facing them. [View Quote] > Or, you could get unlazy and do it yourself, joining someone is easy, and > follow is also. > > To Join: > > Private Sub sdk_EventChat() > Message = LCase(sdk.AwChatMessage) > If Message = "join" Then > sdk.AwMyX = sdk.AwAvatarX > <etc..> > End If > End Sub > > To Follow: > Loop the above code.. very simple, all you have to do is think. m a k a v e l iMay 6, 2001, 6:36pm
Then why should MrGrimm add a function to join people if you can do it?
| Uhhhh, yea.... But it will then join the person that moves, and it will be | right on top of them. On my bot I have it keep the location of owners. It | then will apper 2 and half meeters infron of them facing them. grimbleMay 7, 2001, 2:33am
grimbleMay 7, 2001, 2:42am
Ummm ... nope. No aw_avatar_x attribute in a chat message (read the SDK
documentation!). You need a session table and keep track of all the aw_event_avatar_change messages beforehand before you can even know where the avatar is. That will only work (by luck) if there is only one avatar in the hearing radius of the bot. TrekkerX, I'll e-mail you with something when I've put it together. Grims. [View Quote] billybobMay 15, 2001, 11:35pm
Hey KAH!
Here's how to do it. I'm not going to go into the walking part of all of it, cause that is complex and hard to explain, but u can get that else where. So here is the random. Two ways... 1. Just plain random... You do this(for VB) X = int(rnd * xlimit) - xlimit2 Z = int(rnd * zlimit) - zlimit2 then have the bot walk to that place The xlimit is the MAX east/west. It is measures in CM, so take the W/E * 1000. and remeber it is MAX so if the world is p-20 and u want the limit around the world then it would be 40000, yes 40000, cause its 20 * 1000 * ( this allows the bot to go not only west, but east) it is the same for zlimit(only W/E is N/S) The xlimit2 and zlimit2 is just half the xlimit and zlimit, this is completion of the code that allows the bot to go from -20000 to 20000(if the world is P-20) 2. U pick random. This is for worlds where the ground is really bumpy, or filled. U make a large list of places where the bot will go to and have the bot come up with a random number from 0 to the amount of loctions u have - 1. Using this method u can control the places the bot will go while still having a sense of random. The first method will make the bot walk right through some walls, so this method is recomended for perfection. Hope I helped! Remeber to check out USWF_PBL( the bot is still in debugging so please report ANY bugs or comments to Billybob or Lord Fett) THANK YOU! billybobMay 15, 2001, 11:37pm
if u really want to know how to make bots walk and have a timed walk(so it
does run like a mad man at 300,000km/s(the speed of light)) just TGram me Billybob, and i can help u. |