Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion Goto page Previous  1, 2
Progonoi Posted: Mon Feb 19, 2007 3:47 pm
Question about building a combat bot
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Mon Feb 26, 2007 2:56 pm   
 
It can be done via triggering, no it isn't too hard, and Amazing. That sort of a cycle is just what was intended. Unfortunately I'm at work and don't have the time to alter and test something specifically for this code. Sometime this evening if you haven't got it figured I'll look into it.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Mon Feb 26, 2007 9:08 pm   
 
Hello,


Going to write about a new trouble I'm facing, meanwhile. Namely agressive mobs in the path between letssay one location (bot room 1) and second location (bot room 2). As much as I can think about it, I guess suspending the walk when encountering an agro mob that has to be dealt with first should be done by triggering the mob's desc perhaps? I mean, lets say the mob is:

Code:

An agressive elephant runs you down with an angry look.


My first idea was to trigger it zerofy the mobs variable together with fighting variable. Sort of like:

[/Code]
moving to room with an agro (but also with mobs I need to kill)

An agressive elephant runs you down with an angry look.
[#TRIGGER {An agressive elephant runs you down with an angry look.} {mobs=%null;fighting=0}
[/Code]

Then I realized it was a silly move because zerofying both I made the bot think that its ok to move on and so it started to spam directions commands while I had to deal with the agro. So it more or less blew right to my face. All I can think of though, is to trigger some sort of movement suspension when countering an agro mob like that (and there are cpl others, I just gave that one as an example) and then re-enabling the movement once the agro is dead and its ok to move on. But I don't have any reasonable enough idea to accomplish this.
It shouldn't be hard though, so maybe you can suggest something ;)


Thanks in advance, as always :)


Prog
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Mon Feb 26, 2007 9:26 pm   
 
Not completely sure yet but I might have dealt with it. For now anyway, I guess.
I did the trigger with mobs=%null;fighting=1 and it seems to stop movement now for fighting and when fight is over, it moves on itself.
One thing tho, not sure if its my own problem because I'm testing the thing in a different area now, but sometimes it runs through one room really fast (albeit it shouldn't), leaving the mobs variable full of mobs from that room and then moves to the next room, screwing up the fighting part because in the next room it can't find nor the mobs in the list for attacking or anything, thus leaving fighting at 1 and movement stops. Its pretty bizarre because i didn't had a trouble like that in another area at all. Just figured I'd write about it. Maybe some sort of clitch somewhere that can be fixed.


Thanks.


Prog
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Mon Feb 26, 2007 10:11 pm   
 
For the purpose of a battling bot, which you have. It is best to set fighting to 1 whenever you wish to stop. I would like to point out though that if at any time you wish to stop walking you also have the choice of setting the @walk variable to 0. This will stop the bot in its tracks.

That said setting fighting to 1 was the right thing to do. but it was unnecessary to set mobs=%null. Mobs should have already been null when you walked into the room. Setting it to null when you get attacked could cause you to leave some living mobs behind. You would leave quickly as you put it. You might want to manually Backstab Elephant. I don't know how fighting goes on your mud.

Finally if you experience heavy lag it would appear as if it is going quickly from one room to the next. This would also cause it to suddenly stop a few rooms away from the mobs.

Edit: There are several ways around this but to my mind fails me at the moment. I put something here that may not work so I removed it.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Tue Feb 27, 2007 3:11 am   
 
Something came up tonight. I'm not going to explain this code right now. See if you can figure out how it works.

Code:
#ALIAS agmob {#show An agressive elephant runs you down with an angry look.} "WalkBot"
#ALIAS cWalkc {walk=1;walkcircle=1;#T+ MoveOn} "WalkBot"
#ALIAS step {#if (@walk=1 and @path!=%null) {nextstep=%exec( .%pop( path));@nextstep;#if (@path=%null) {#if (@walkcircle=1) {walkcircle} {#say End of path.;walk=0;#call %walkmode(@walkmode)}}}} "WalkBot"
#ALIAS StopWalk {walkcircle=0;walk=0} "WalkBot"
#ALIAS WalkCircle {walkcircle=1;#alarm +2 {go %exec( "#case %ismember( %roomid, @roomlist)+1 {@roomlist.1} {@roomlist.2} {@roomlist.3} {@roomlist.4}")}} "WalkBot"
#VAR roomlist {Room1|Room2|Room3|Room4} {_nodef} "WalkBot"
#VAR walkcircle {0} {0} "WalkBot"
#TRIGGER {An agressive elephant runs you down with an angry look.} {Fighting=1;backstab Elephant} "WalkBot"
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Tue Feb 27, 2007 1:00 pm   
 
Okay.

First off. About the agro mob. I think adding the fighting=1 to the trigger solved it. It does attack all the other mobs now, after it has dealt with the agro one. Anyway, there's one downside to it. If I enter a room with several mobs I need to kill (but who aren't agro) and there's also the agro mob, I need to deal with that first, right. That isn't an issue if the agro mob would the first standing mob in the room. But at times, it looks like this:

Code:

moving to room...

Silentmob1, who I need to kill.
Agromob, who attacks me when i enter the room.
Silentmob2
Silentmob3



I think you realize what happens. When I enter the room, bot triggers the attack towards the FIRST mob in the room, thus firing backstab at it which isn't working because I'm ALREADY in a fight with the agro mob. Basically it moves along well after that though, just the mob who's attacking failed will be left unkilled, everything else will be killed. Just a minor issue really, but figured I might well bring it up.

Now, about the walkcircle code :) First off, loads of thanks. I think I figured out most of it though and made cpl of my own additions for example my roomlist grew a lot bigger :P Anyway, there are some parts I more or less understand but don't know where to put (going to write about it soon though, but maybe not having knowleadge of some those parts are causing my problems atm...)

First, where does cWalkc alias belong? I understand StopWalk though, but can't realize atm where I should place it as well. Step alias is understable fine, just placed the walkcircle part within that and its ok. Understanding walkcircle alias and roomlist variable tho, just as I said, added a lot more rooms into it (up to 21), hopefully that wasn't a bad thing to do (as I needed it etc). Anyway, now I'm going to talk about troubles I'm facing atm....

Firstly, still having the issue with randomly firing more than one direction at once. To be honest I first thought about lag myself, too, but once there was no reason whatsoever for lag anymore, it sometimes still did it. I don't know how to fix it tho, you said there are ways around it but you didn't have time yesterday to think about it more. Only thing, pretty much, that I have thought about doing is to add some sort of alarm/wait or delay of sorts after killing the mobs (when mobs is %null and fighting is 0) and before moving on. But I'm not sure at all about it.

Secondly, I'm experiencing some weird thing with the several number of rooms to kill in loop. The problem might well be that i have 21 rooms listed in total but somehow I think it shouldn't affect the walk. Anyway, going to try to explain whats going on atm.

I start the walkcircle, it goes to botroom1, kills stuff if there is any, goes to botroom2, same thing, goes to botroom3 etc, until at some point, quite possible in the middle of all the rooms it needs to run through, it starts to loop back and forth with 2 directions, lets say up and down. At first I thought its the order of rooms and rewrote the shortIDs they're having to make the walking less hard for the bot. But then it pretty much did the same thing at one point, while using just some another 2 directions. I have no idea why its doing that.
Yesterday I tried the thing with just one room to walk to while killing everything in its way and it worked all fine, but I really do need actually, that it'd visit all the 21 rooms. Well, I understand its most likely impossible to understand what I'm saying but I really can't explain it any better :P

If you get some spare time, get back to me :) as always, any help is appreciated A LOT.


Prog
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Tue Feb 27, 2007 8:32 pm   
 
Ok, going to write more clearly without any pointless babble as I tested around some and can give somewhat more accurate responses about my troubles.
I removed all the walkcircle related stuff you gave me and tried to 'go botroom9' and once it was achived, 'go botroom 21' etc. And it all worked out perfectly well. Then I added walkcircle stuff again and made it with two rooms, 'botroom9' and 'botroom21'. Ideally it should go to first, while killing everything on its way, and then move to last one etc. Well, it didn't. It basically started to loop between two directions before even managing it to 'botroom9'. Nothing like that happend when I tried to move to same rooms with simple 'go'. Thus I'm pretty much clueless what might be happening because as of now, I can't find any reasonable explanation to all this.

About agro mob bit.... forget about it for now. Its working fairly well with fighting=1 addition and while having more than one agro in a room might screw it up and start firing nextroom direction commands, I guess its just some another random thing that needs to be dealt at one point. But just now, in case you check the thread and/or have some time to try and figuring out what I might be having wrong, I really need to figure out whats making walkcircle part not working.

Thanks a lot in advance.

Prog
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Tue Feb 27, 2007 10:10 pm   
 
Again me :P (Yes, I know I'm spammy. And that most likely at one point I will be told to PM people instead of spamming public boards :P) Anyway... I haven't stopped playing around with stuff at the moment. So, I started to wonder about one thing and partly its working right now though (using it to re-start the cycle I'm using at the moment). Namely, if I'd write it to Step alias that I'd want to move to botroom9 while being in botroom3 and killing mobs there, how exactly should I do it. I figured myself to do an if with %roomid and mobs=%null and fighting=0 but it doesn't seem to move it anywhere. Let me write it down.

Code:

#if (%roomid="botroom3" AND mobs=%null AND fighting=0) {go botroom9}
tried it the other way tho, once that wasn't doing anything...
#if (mobs=%null AND fighting=0 AND %roomid="botroom3") {go botroom9}
and still nothing...


I guess I'm thinking incorrect here again though because #if sentence itself should be correct. Anyway, was just some sort of alternative I stumbled upon in my thoughts for walkcircle part and figured that might work. Thought I'll share my recent conquest :P


Prog
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Wed Feb 28, 2007 9:32 pm   
 
Fine, I guess that was sort of like a test if I could crack it myself eventually :P Well, I did. cycled movement is OK now. Added cWalkc alias to Step alias #IF part before nextstep. No idea if it was the correct move to do but now its looping through all the 21 rooms I gave it in roomlist. However, I have been unable to finish the cycle in several occasions because of interference of sorts I have already written before. Namely, as it usually moves without any problem, there are times when the bot takes 2 directions quickly after another (and while doing that, pretty much screws up the automaticy the thing is supposed to have because if there are killable mobs in one of those directions, all the variables will be filled etc and it just stops because fighting is still set to 1). You mentioned the lag and I'm not really arguing with it although I have been having the same problem when I'm running my internet connection in full speed without any speedbumps as well. I'm pretty much clueless as to how fix it tho (Last time you wrote, you said that there are several ways around this...). I tried with #WAIT tho, put it into MorK alias info #IF. #WAIT should fire before Step in case mobs variable is clean. Well, #WAIT didn't make any difference at all. To be honest its the only trouble I have left to deal with. Agro mobs I guess are just a reality I need to face and take a risk.


Thanks.

Prog
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Thu Mar 01, 2007 1:15 am   
 
Well, I did mention that it takes a lot of time to help you with this right? My life stepped in for a few days, and you did need that test you mentioned. :p

One way Zugg handles the lag is to match room names or exits in the mapper. I don't like the way that works, but Below is a method of handling the Lag similar to Zugg's.


Create a trigger that matches the word Exit.

#trigger {exit} {madeit=1}

Then somewhere in the step alias do a check for @madeit=1. Then if you take a step set madeit to 0.

#if (@fightng=0 and @madeit=1) {set madeit to 0 and take the next step}

I tried to make sure that you KNEW how to use everything I gave you. So that you would eventually be able to alter it to your needs. I said in the beginning that it was more about IDEAS than code. There is usually more than one way to do a thing. Sometimes one way is better than another sometimes not. The way you handled the walkcircle was a different way than I would have. But if it is working for you then GREAT. I never used anything like walkcircle in my other bots, but the IDEA is sound and I'll use it in my next one.


as for the agro bot causing you to miss the others in the room, I can think of two things off the top of my head to handle it. (My brain was sore from work the last time.)

First, create TWO lists of mobs, Mobs and Mobs2. Leave the backstab %pop(Mobs) but if you get attacked by an agro mob set mobs = to mobs2.

Second one, clear mobs when the agro mob attacks you and look. The act of looking will reload your mobs list and since you are in a fight it will not try to attack any of them.

While I was writing the first two I thought of a third way that I'm not gonna list. Point being there are MULTIPLE ways to handle almost every problem.

You will always find things that need changing on your bot as long as you use it. That is how it should be. But these forums are for helping, not for doing for you. At this point I KNOW you have enough information at hand to figure out most problems. And you are gonna have to really work to get me to SHOW you how the code should look from now on.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Thu Mar 01, 2007 2:57 am   
 
When requesting we make a complex bot I woud actually suggest posting a large block of the mud text inside code tags.
DO post contiguous blocks with commands shown.
DO include multiple movements.
DO include multiple attacks.
DO include examples of other players.
DO include examples of what is currently failing.
DO explain specific lines in the examples when needed.

DO NOT post tiny snippets.
DO NOT use made up text.
DO NOT expect us to be mind readers.

In general, a bot such as what your asking for is very complex. I more or less haven't read a single thing posted in this entire topic because every time I looked at it you were doing the exact opposite of the above. So here is what I am going to really suggest; start a new topic with all the above things in the post, and also include the full script you currently have.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Fri Mar 02, 2007 12:59 pm   
 
Hello again,


I know I'm supposed to figure it out myself but I'm really stuck with that Exits idea at the moment. I figured it'll come down to using exits line eventually though, but I just don't seem to figure out how to place variables correctly for the thing to work. Tried various ways. First put true variable into MorK alias that hits after mob is dead and and =0 into Step alias and then other way around, now I tried with having exits trigger as a completely other class and disabling and enabling it together with madeit setting and I still couldn't get it to work. I guess I'm doing something completely wrong tho, but I'm getting totally blank in this, unfortunetly. One thing tho, yesterday when I tried with simple madeit variable additions to both said aliases, it ended up spamming a lot of code into the mud and then disconnected me :P So I figured today that maybe having Exits trigger just as a usual trigger causes it. So i put it into the class and tried disabling/enabling it as I said. I do think that it should work somewhat like that, because ideally exits trigger shouldn't be enabled all the time. I just can't seem to figure out how to place everything together so that it'd work.

Now, about the agro mobs issue. One of the troubles I'm currenly facing is this:

Code:

when moving to room...

Mob1 is here. (non-agro mob, mob from mobs list)
AGROMOB (attacks me when i enter room)
Mob2 is here. (non-agro mob, mob from mobs list)



Let me explain now. Once I enter the room, attack action meant for first mob in mobs variable fires, but can't succeed because I'm already in the fight with the agro (speaking of which, agro mob ATTACKS THE MOMENT I ENTER the room, thus can't do any direct attack actions at it as you suggested earlier). So, to clarify some more: when I enter the room with given agro, but also with several mobs that are ok, mobs variable gets filled but the first mob in the list (in case its above the agro mob in the room), gets an attack that doesn't go through and thus bot thinks that I'm done with it and of course deletes it from the list. In concept its not bad, but I really don't want to see it spamming commands it can't go through with if you understand what I mean. However, when agro mob is the first mob in the room, there are no problems whatsoever.
You suggested cleaning mobs variable and looking but as much as I saw, firing an attack command to first mob in the mobs variable still went through even tho then it cleared the list and looked etc. So I don't know.

Thanks in advance.


Prog
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Fri Mar 02, 2007 3:43 pm   
 
Okay okay, I know I tend to get all worked up too early :P I thinked I solved the Exits issue now, though. Finally. Put check for madeit=1 to MorK alias into #if sentence with #fighting=0. Put #madeit=1 right there with it. Now, as Exits line sets madeit variable to 1 each time, I put a set to make madeit=0 in Step alias, more exactly in the #if part right before cWalkc alias. I'm still watching how it goes at the moment as I changed all the alarms to lower number as they were before (and back then, when it was lower than 5 for both, it started to take several directions at once), set both to 2 at the moment but haven't seen troubles yet. Thing seems to wait for Exits line before doing anything at all via movement.
Just figured I'll write about it as it seems to be solved issue hopefully :) Troubles with agro mobs still stay, though.


Thanks,


Prog
Reply with quote
Odoth
Wanderer


Joined: 13 Nov 2004
Posts: 54
Location: Visalia, CA

PostPosted: Fri Mar 02, 2007 5:26 pm   
 
Prog,
What I would suggest to you, and what I do in my own combat bot, is to make a small delay from after you enter the room till the time you attack the mob using #alarm. That way, you can set up a check to see if you have been attacked by an aggro mob, and if so, don't attack a mob until the aggro one is dead.
_________________
*ribbit*
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Fri Mar 02, 2007 11:04 pm   
 
Yeah, I had more or less same thought while ago myself, to be honest. The thing is that I'm not completely sure if I know how to set one up so that it'd actually work, given that I'm still in a learning phase of everything more detailed and sophisticated :P Ideally, there could be an alarm that would fire #alarm to sort of disable mobs variable in case agromobs variable doesn't equal %null. But at least for now, I don't know how to make one like that.

Basically something like:

Code:


#if (fighting=0) {fighting=1;#ALARM +2 {#if (agromobs "doesn't equal" %null) {mobs=%null;look}}}




Basically, the alarm could well be general one tho, it just needs the check to clear mobs list and look to refresh them in case the agromobs list doesn't equal null (meaning most likely I'm in fight with one). Setting agromobs back to zero in the same sentence isn't needed though, already set up other triggers to remove the mob name with %pop once its dead. So there ya go, again something I'm not completely sure how to do :)


Prog


Edit: Most likely though, it makes most sense to write the #alarm trigger into a different class and use #t-/#t+ inside the bot code itself. Just wanted to point it out in case, there's still the actual #if sentence factor to deal with. Thats the first idea I got of how to do it, I guess there can be more and/or easier ways to accomplish this, though.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sat Mar 03, 2007 12:17 am   
 
Look back at how I turned on and off an alarm that was there permanently. The MoveOn Alarm. You don't have to have a trigger/alarm/whatever inside of another class to disable it.

So inside your MorK alias you already have some crazy stuff going on. Wink But for the purpose of adding this delay we can take out the backstab %pop(mobs) and put #T+ Alarm that does if not fighting backstab %pop(mobs). #t- myownAlarmName. You can use the simliar principle for the lag btw...
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Sat Mar 03, 2007 2:55 pm   
 
Nods... I understand the concept. Just can't seem to figure out how to write the thing down. Basically I need to make alarm to remove attacking %pop(mobs) option and re-enabling it once the agro mob causing all the trouble, is dead. Among other ways I guess is to make alarm clear mobs variable and look, or something. I'm continuing to wonder about it though, just figured I'd write something here meanwhile :P


Prog
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sat Mar 03, 2007 4:50 pm   
 
No, not one to remove it. REMOVE it and turn on the alarm that does it... Look I'll help but. The more things you do on your own the more complex the thing becomes. Look back at what Vijilante said. More people would help if you took his suggestion to heart. If you want me to show you what to do from now on you will have to follow his advice. I've been as he put it practically mind reading. If you don't want to paste your code where everyone else can see it PM me. But this thread has REALLY gotten out of hand.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net