Zot Bot - A Stone Soup Borg [v0.1.6]


Questions, Explanations, Howtos

User avatar

Mines Malingerer

Posts: 45

Joined: Saturday, 13th August 2011, 14:21

Post Saturday, 13th August 2011, 14:47

Zot Bot - A Stone Soup Borg [v0.1.6]

What is Zot Bot?
Zot Bot is an AI script that will play DCSS by itself without any player intervention. These are commonly called "borgs" in the context of roguelikes. Mine was inspired by the APW-Borg for Angband which was eventually turned into a screensaver. Zot Bot's base code was primarily based on elliptic's autorobin FeBe bot as well as parts of N78291's and 7hm's bots. The main difference with Zot Bot is that it autoruns without any player intervention (at least in theory) and isn't specialized for a specific character build. My hope is to eventually have it perform with at least basic competency regardless of the species/background used. I'd like to turn it into a screensaver as well!


Installation and Usage (written for Windows 7, should be similar for all versions of Windows)
  • Download the ZotBot.rc file and place it in the "settings" folder of your Crawl directory.
  • Create a Windows shortcut for crawl.exe
  • Right-click the shortcut and select Properties. Go to the Shortcut tab.
  • In the Target field, add this to the end: -rc settings/ZotBot.rc
    (example: C:\Games\stone_soup-0.9\crawl.exe -rc settings/ZotBot.rc)
  • Double click the shortcut to start! Zot Bot will run automatically after you've chosen a character.
  • (Optional) Set a macro to ===s if you'd like to pause/resume Zot Bot to control the character yourself.


Current Behavior
  • Uses autotravel for most exploration.
  • Rests whenever not at max HP and MP
  • Attacks monsters at range with throwable weapons (if available)
  • Engages in melee combat when in close quarters
  • Attempts to escape when at low health (<25%)
  • Attempts to back into a corridor when fighting multiple enemies in melee combat
  • Basic scroll and potion usage
  • Eats when hungry. Will attempt to butcher corpses when no food is available.
  • Trys on rings and amulets
  • Drops unneeded items and weapons it is not trained in
  • Uses ranged weapons over melee depending on character skills
  • Automatically chooses STR on level up
Many of these functions still need improvement. I've mostly been testing it with Minotaur Fighters. A few lucky bots got down to around D:8 but the vast majority die on D:2 - D:4 right now.


Contributions are welcome! If you think you can improve upon an existing function or want to write one to handle something on the to-do list, please do! I'm sure there's many better Lua scripters than me on this forum (I'm new to Lua) and there's definitely better DCSS players.

Right now, the main problem is detecting the stat choice prompt on level up. Checking you.xl() does not work, the value changes after the player inputs their choice. I've dealt with this for now by inputting an 's' after every turn, which is a horribly inefficient and limiting solution. If someone knows a better way, please let me know!

To-Do List
  • Proper detection and handling of stat choice on level up.
  • Use spells.
  • Use abilities
  • God worship
  • Define more use cases for specific scrolls and potions
  • Handle shopping
  • Stop fleeing and attack if unable to escape
  • Use stairs to aid fleeing
  • Use found weapons and armor
  • Handle invisible enemies (no idea how)
  • Actively search for corpses when hungry


Original Post:
Last year, I found a bot for Angband that allowed it to be run as a screensaver and I absolutely loved it. Great fun watching the AI progress through the levels and seeing how far it could get each time. I'd love to have the same setup for DCSS as I much prefer it to Angband and I think it'd be a lot more interesting to watch. I found this thread and have been altering elliptic's great bot, stripping it down and trying to clean up some bugs before I flesh it out for a specific build of my choice. Things are going great so far. I do have one hang-up though. I can't figure out how to make the bot run itself without having to hold down a key. All three of the bots in that thread were designed to be run via a macro binded to "d" and just holding down the key. I'm a decent programmer but I'm new to Lua and haven't played around with a roguelike's code before, so hopefully I'm just missing something obvious. Any help would be much appreciated!
Last edited by 8bitsdeep on Wednesday, 24th August 2011, 03:22, edited 4 times in total.
Wins: MuSu of Sif, DDFi of Mak
User avatar

Dungeon Master

Posts: 4031

Joined: Thursday, 16th December 2010, 20:37

Location: France

Post Saturday, 13th August 2011, 17:04

Re: Making a bot auto-run?

I don 't think that's possible, but it should be easy to implement. I'd love a crawl scrensaver too, so I'll look into it.
<+Grunt> You dereference an invalid pointer! Ouch! That really hurt! The game dies...

For this message the author galehar has received thanks:
8bitsdeep
User avatar

Mines Malingerer

Posts: 45

Joined: Saturday, 13th August 2011, 14:21

Post Saturday, 13th August 2011, 17:28

Re: Making a bot auto-run?

That'd be great! I'll keep working on my bot in the meantime.
Wins: MuSu of Sif, DDFi of Mak
User avatar

Mines Malingerer

Posts: 45

Joined: Saturday, 13th August 2011, 14:21

Post Sunday, 14th August 2011, 20:28

Re: Making a bot auto-run?

Figured I'd ask this here instead of starting a new thread.

Is there some reference I could use to find all the various players values I can access via Lua? Specifically, I'm trying to parse what spells the character has learned. A lot of handy values were already referenced in the bots I linked ( you.abilities(), you.hp(), items.inslot(x), etc. ) but not the spells. Tried some guesswork and digging around in the source code but nothing seemed to work.


Otherwise, the bot is progressing nicely. It's using melee fairly intelligently. Namely, letting an enemy come to it if there's only one space between them and attempting to back into a corridor if facing multiple opponents. (Though the latter is just as likely to end up in a corner.) It's also using throw-able missiles when at range. Loads of work to do still of course.
Wins: MuSu of Sif, DDFi of Mak
User avatar

Dungeon Master

Posts: 4031

Joined: Thursday, 16th December 2010, 20:37

Location: France

Post Sunday, 14th August 2011, 20:40

Re: Making a bot auto-run?

8bitsdeep wrote:Is there some reference I could use to find all the various players values I can access via Lua?

The lua interface is poorly documented. In fact, it's not documented at all. Just look in l_you.cc for player values. If you need more, don't hesitate to ask, most are easy to add. Or if you know some C++, you can add them yourself and submit a patch on mantis.

8bitsdeep wrote:Specifically, I'm trying to parse what spells the character has learned. A lot of handy values were already referenced in the bots I linked ( you.abilities(), you.hp(), items.inslot(x), etc. ) but not the spells. Tried some guesswork and digging around in the source code but nothing seemed to work.

you.spells(). wield.lua uses it.

8bitsdeep wrote:Otherwise, the bot is progressing nicely. It's using melee fairly intelligently. Namely, letting an enemy come to it if there's only one space between them and attempting to back into a corridor if facing multiple opponents. (Though the latter is just as likely to end up in a corner.) It's also using throw-able missiles when at range. Loads of work to do still of course.

That's awesome! It really doesn't need to be able to win the game to make a good screensaver :)
<+Grunt> You dereference an invalid pointer! Ouch! That really hurt! The game dies...
User avatar

Mines Malingerer

Posts: 45

Joined: Saturday, 13th August 2011, 14:21

Post Sunday, 14th August 2011, 21:14

Re: Making a bot auto-run?

Odd, I tried you.spells() but I couldn't get anything out of it. I'll give it another shot!

galehar wrote:That's awesome! It really doesn't need to be able to win the game to make a good screensaver :)


Haha, yeah, but the better it is the more fun it'll be to watch! Right now, I'm just hoping for some basic competency with any combination of race + background. Would be neat to be able to set it to random characters and watch the mayhem.
Wins: MuSu of Sif, DDFi of Mak
User avatar

Dungeon Master

Posts: 4031

Joined: Thursday, 16th December 2010, 20:37

Location: France

Post Sunday, 14th August 2011, 22:10

Re: Making a bot auto-run?

Hey, I just looked into it and it seems like you should be able to loop from the lua code just fine. gearset.lua for example issue several commands. There's a security in the code to detect lua infinite loops. If your bot can survive 1000 turns, the lua script will be aborted. I can add an option to disable it.
<+Grunt> You dereference an invalid pointer! Ouch! That really hurt! The game dies...
User avatar

Mines Malingerer

Posts: 45

Joined: Saturday, 13th August 2011, 14:21

Post Monday, 15th August 2011, 00:09

Re: Making a bot auto-run?

Hmmm. Looping does work but it seems to cause a lot of problems.

I've tried looping it 5, 10, 20, and 200 times. The longer the loop lasts, the longer the game hangs before the bot makes any moves. It also seems to mess up the bot's logic. I think it is triggering the command for it's initial decision repeatedly instead reevaluating on each loop. This doesn't always happen, but it's enough where the majority of the turns taken are wasted on bad actions, or maybe not even triggered at all.

Come to think of it, holding down the macro key causes the same problem. I've just been pressing it as needed for my testing, which works fine.


I must admit I'm a bit out of my depth when it comes to this kind of thing. The bulk of my programming experience is for web environments, mainly PHP, so I'm not sure how to handle this issue.
Wins: MuSu of Sif, DDFi of Mak
User avatar

Mines Malingerer

Posts: 45

Joined: Saturday, 13th August 2011, 14:21

Post Wednesday, 17th August 2011, 16:01

Re: Making a bot auto-run?

Success! \o/

The bot is no longer a macro. I patterned it off the ready() function in fireworks.rc and it works great! Autoplays without any initial button press and surpasses 1000 turns without being aborted from infinite loop detection.

Still have some hurdles to overcome before it could be a viable screen saver. The chief problem is handling special case player input scenarios (i.e. stat choice on level up, choosing a target item for some scrolls, etc). The level up one is the main problem as the others could be avoided by simply disabling certain options for the bot. I'm still hoping to make it as robust as possible though. So far the bot has managed to make it Dungeon:8 as a Minotaur Fighter with minimal intervention, which I'm pretty pleased with.

I'll revamp the first post of this thread later with the .rc file and usage instructions.
Wins: MuSu of Sif, DDFi of Mak
User avatar

Mines Malingerer

Posts: 45

Joined: Saturday, 13th August 2011, 14:21

Post Tuesday, 23rd August 2011, 21:48

Re: Zot Bot - A Stone Soup Borg [v0.1.5]

Updated the file.

v0.1.5
-Uses ranged launchers when skilled in their use.
-Prefers ranged weapons over melee only if its starting skills dictate it. It will retain its starting melee weapon regardless of its skill level with it.
-Improved inventory management. It now drops any item if it isn't skilled in its use. Should keep the inventory slots from getting clogged up.

Had a Halfing Hunter make it to D:5 before meeting an untimely end at the hands of Duvessa.

Edit: Oh, apparently it's impossible to run a console in fullscreen in Vista and Windows 7, which puts a major dent in my hopes of turning this into a screensaver. Might still be possible with the tiles version. I haven't tested it at all with tiles but I don't know of any reason it wouldn't work.

Edit 2: Oops, seems to be a rather bad bug. Launcher usage is flaky at the moment.

Edit 3: Fixed!
Wins: MuSu of Sif, DDFi of Mak
User avatar

Dungeon Master

Posts: 4031

Joined: Thursday, 16th December 2010, 20:37

Location: France

Post Wednesday, 24th August 2011, 14:55

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

I've added a lua hook to check stat game prompt. I also added one to check monster's threat level from monster_info.
<+Grunt> You dereference an invalid pointer! Ouch! That really hurt! The game dies...

For this message the author galehar has received thanks:
8bitsdeep
User avatar

Mines Malingerer

Posts: 45

Joined: Saturday, 13th August 2011, 14:21

Post Wednesday, 31st August 2011, 02:31

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

Great! That'll be a huge step in getting it to play better. Hopefully it'll let a lucky few make it down to D:8 again.
Wins: MuSu of Sif, DDFi of Mak
User avatar

Snake Sneak

Posts: 128

Joined: Friday, 13th May 2011, 12:06

Post Thursday, 1st September 2011, 11:39

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

To-Do List

•Proper detection and handling of stat choice on level up.
•Use spells.
•Use abilities
•God worship
•Define more use cases for specific scrolls and potions
•Handle shopping
•Stop fleeing and attack if unable to escape
•Use stairs to aid fleeing
•Use found weapons and armor
•Handle invisible enemies (no idea how)
•Actively search for corpses when hungry


some ideas on game logic that might be easier to code

butcher corpses if you have less than X unrotten chunks

I think autofight uses spells - could probably check if the spell in za is ranged damage one and there is an enemy in range.

for Gods either wait until you have the ability use sorted, or go for ones with mostly passive abilities. Perhaps have a list of suitable ones (perhaps varying by character class), and worship the first altar you see on that list.

for weapons and armour, perhaps switch to the first usable magic item that you see.

Abilities are likely to need to be case by case -e.g. the naga's breath could have a 20% chance of being used whenever a ranged attack is called for, or always used if the breath status is not present.

for invisible enemies - head for the closest set of down stairs?
A troll caster is a hybrid
User avatar

Tomb Titivator

Posts: 832

Joined: Saturday, 30th July 2011, 00:58

Post Sunday, 4th September 2011, 10:59

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

This is a pretty cool idea. If it could be implemented into the game it would be fun to have Xom powers to play on the poor, unfortunate adventurer.
KoboldLord wrote:I'm also morbidly curious now as to how Shatter is abusable for 'stealth tricks'. It's about as stealthy as the Kool-Aid Man smashing through the walls and running through the room
User avatar

Dungeon Master

Posts: 4031

Joined: Thursday, 16th December 2010, 20:37

Location: France

Post Sunday, 4th September 2011, 11:59

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

bobross419 wrote:This is a pretty cool idea. If it could be implemented into the game it would be fun to have Xom powers to play on the poor, unfortunate adventurer.

It is. Just start a Zot Bot game in wizmode, and do &X to torture the poor thing.
<+Grunt> You dereference an invalid pointer! Ouch! That really hurt! The game dies...

For this message the author galehar has received thanks:
bobross419
User avatar

Snake Sneak

Posts: 128

Joined: Friday, 13th May 2011, 12:06

Post Monday, 5th September 2011, 08:07

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

Gave it a try - did quite well as a troll monk, but it did keep dropping stones and darts. Not that they help much, but they shouldn't be dropped.

Have just made the following changes - will test them out later

Throwables will always be useful - (not just for these with ranged skill)
corpse will be chopped if you have no chunks.
A troll caster is a hybrid
User avatar

Mines Malingerer

Posts: 45

Joined: Saturday, 13th August 2011, 14:21

Post Monday, 5th September 2011, 15:39

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

Yeah, it used to keep and use all throwables before I had it look at skills. Was considering changing that back as well.

I need to get back to tinkering with this. Been busy lately!
Wins: MuSu of Sif, DDFi of Mak
User avatar

Snake Sneak

Posts: 128

Joined: Friday, 13th May 2011, 12:06

Post Tuesday, 6th September 2011, 08:51

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

Wouldn't mind giving you a hand on this. I split throwables into stackable and non stackable - you dont want the inventory cluttered with clubs, but you do want all the javalins, darts and stones. some questions.

1)Is there a way of telling if the main weapon is cursed? This would help with some error handling on chopping and trying to melee with a cursed sling.

2)Could also do with "if you are an abysal knight then first order is [aa]"

3) Can we tell if we have the breath status? - if so we could impliment the Naga breath weapon - a Naga fighter would probably do well.

4) there are 2 routes for spell casters that may be implimentable - one for a zap type spell caster - using the ranged attack logic for spells, and one for summoners. Necro's will be similar to summoners initially.
A troll caster is a hybrid

Snake Sneak

Posts: 105

Joined: Monday, 11th July 2011, 13:53

Post Tuesday, 29th November 2011, 13:07

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

I just wanted to mention that several lua functions have been added since September. For example one was added that can handle "Proper detection and handling of stat choice on level up".
User avatar

Mines Malingerer

Posts: 45

Joined: Saturday, 13th August 2011, 14:21

Post Tuesday, 29th November 2011, 15:12

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

Yeah, I'm looking forward tinkering with this some more when I get a chance. I've just been super busy lately. And Zelda and Skyrim aren't helping. ;)
Wins: MuSu of Sif, DDFi of Mak

7hm

Snake Sneak

Posts: 109

Joined: Wednesday, 2nd February 2011, 03:20

Post Monday, 2nd January 2012, 03:09

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

Holy shit, just saw this.

Got to play around with it now.

(and then read the rest of the thread, and make comments)
User avatar

Mines Malingerer

Posts: 45

Joined: Saturday, 13th August 2011, 14:21

Post Monday, 20th February 2012, 20:50

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

In celebration of my first win, I thought I'd work a bit more on this.

Certainly need to track down that lua hook for the level up choice and get that working at the very least.
Wins: MuSu of Sif, DDFi of Mak

For this message the author 8bitsdeep has received thanks:
TehDruid
User avatar

Eringya's Employee

Posts: 1783

Joined: Friday, 7th October 2011, 19:24

Location: Athens, Greece

Post Monday, 20th February 2012, 21:25

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

I'd love this if it were to become fully functional, alas I have no programming knowledge I could help you with.
MuCK;
  Code:
612 | D:1      | Xom revived you
614 | D:1      | Xom revived you
614 | D:1      | Slain by a gnoll
User avatar

Mines Malingerer

Posts: 45

Joined: Saturday, 13th August 2011, 14:21

Post Monday, 20th February 2012, 21:40

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

TehDruid wrote:I'd love this if it were to become fully functional, alas I have no programming knowledge I could help you with.


My Crawl experience isn't nearly as vast as many users on here. If there's any behaviors you see in the first post (or witness the bot doing) that are wrong or questionable, please do offer alternatives.

I'm just focusing on the very broad decisions right now, not the specific wrinkles that keep the game interesting, but I'll try to incorporate any worthwhile suggests within my abilities.
Wins: MuSu of Sif, DDFi of Mak
User avatar

Crypt Cleanser

Posts: 645

Joined: Wednesday, 14th September 2011, 09:36

Location: <---

Post Monday, 20th February 2012, 22:50

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

Attempts to escape when at low health (<25%)

Trys on rings and amulets

Must try to escape whenever bellow 50% hp and more than one enemy or a single attack make more than 25%.

Must not try every rings if already have two and/or have scrolls of identify/detect curse available.

Snake Sneak

Posts: 105

Joined: Monday, 11th July 2011, 13:53

Post Thursday, 5th April 2012, 10:06

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

8bitsdeep wrote:In celebration of my first win, I thought I'd work a bit more on this.

Certainly need to track down that lua hook for the level up choice and get that working at the very least.



l_crawl.cc:LUARET1(crawl_stat_gain_prompt, boolean, crawl_state.stat_gain_prompt)



grep LUARET *.cc *.h
grep LUAFN *.cc *.h

give a good overview I suppose

Dungeon Dilettante

Posts: 2

Joined: Friday, 5th October 2012, 22:04

Post Friday, 5th October 2012, 22:21

Re: Zot Bot - A Stone Soup Borg [v0.1.6]

It's very basic, but this uses the lua hook to choose STR when prompted.

  Code:
<
function choose_stat_gain()
  send_orders('s')
end
>

Return to Coding

Who is online

Users browsing this forum: No registered users and 11 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.