Lua scripted "bots"


Although the central place for design discussion is ##crawl-dev on freenode, some may find it helpful to discuss requests and suggestions here first.

7hm

Snake Sneak

Posts: 109

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

Post Sunday, 27th March 2011, 05:59

Lua scripted "bots"

I know not everyone who frequents the forum goes on IRC, so for those who weren't aware, there are a couple people working on "bots" using the lua scripting that crawl allows.

Right now they're pretty simple. This thread isn't really about the coding or anything, just a general thread about them, about any questions people may have, and also because I'm working on one and want some ideas for it. :) (and I thought it would fit in a design forum better than the general forum)

If you want to try out the bots yourself, these are the three that I'm aware of:

elliptic's (autorobin):
http://crawl.akrasiac.org/rcfiles/crawl ... torobin.rc

N78291's (xw):
http://crawl.akrasiac.org/rcfiles/crawl-git/xw.rc

mine (auto7hm):
http://crawl.akrasiac.org/rcfiles/crawl-git/auto7hm.rc

To actually use them, you copy the rc file contents into your init.txt file. The messages on mine and elliptic's bot (not sure about xw) are muted to make playing on cao more of a clean look - so change the following line:
message_colour = mute:.*
to
message_colour = mute:
so that you can read messages (or don't, your call)

After copying the rc file over, you start (and run) the bot by creating a macro within crawl itself.
the trigger key should be "d"
the macro action should be
(for mine) "===start_autoplay" or (for elliptic's) "===s" or (for N78291's) "===a"

After that the bot will basically run itself. The three bots act differently. Elliptic's and N78291's are by far more successful and bot have some rudimentary item identification. They can clear Lair and make headway into orc, and with player intervention can get really good speeds and have some modicum of success. As an example, phybot was run using an early version of elliptic's rc and... "121. phybot the Eviscerator (L20 FeBe), worshipper of Trog, shot by a yaktaur (runed bolt) (led by a yaktaur captain) on D:25 on 2011-03-23, with 268493 points after 71102 turns and 2:05:57."

Mine works a little bit different, in that none of the monsters are special-cased in the bot itself. It learns monster difficulty / danger based on past experience, by tracking a couple stats, creating a table to store monster data, and occasionally pushing the table into the chardump notes, so that I can copy it over multiple games and have the bot learn over a longer period of time.

If you're interested in this stuff or know lua (or want to screw around with lua) then you can basically just edit any of these rc files and adjust things to your heart's content. Or just start over. All these bots are based off of autofight.lua and go from there. If you have questions you can ask here or on IRC and I'll (and I'm sure others) will do their best to help. If you have ideas for further improvements to the bots, those are also appreciated by me at least.

....

Now on to my own bot and some help that I need with it.

I wasn't sure what data to learn about each monster. I'm limited a bit by the lua hooks available and can't tell which monster actually hit me, so right now it tracks the following data.

Monster Name / Times Seen / Melee Damage / Ranged Damage / Dungeon Level

1) Monster name is obvious.
2) Times seen isn't. It refers to the total number of turns that monster of that type are in LOS - not how many times each individual monster is seen. (If two monsters of the same type are in LOS, it increases by 2 each turn. If 3, by 3, etc.)
3) Melee Damage refers to amount of damage done (not neccesarily by this monster) while the monster was in melee range. This is an imperfect number for two reasons. A) It could represent damage that you took from a different source and b) it could represent damage done while the monster wasn't actually beside you. But it's an approximate value so it's good enough.
4) Ranged damage is similar to melee but refers to damage done while the monster isn't in LOS. This suffers from similar drawbacks, but it also assigns a danger level to monsters like giant eyeballs and orc priests.
5) Dungeon level is a cumulative stat that refers to the absolute dungeon level you are on when you see each monster. So if I see a rat on D:1, I add one to this stat. If I see a rat on D:3, I add 3. Etc. When you take DL / Time Seen you get an approximate difficulty level based on spawning depth. Not perfect, but over time it should be pretty good.

So that's the info I'm collecting. I'm also collecting status info (but not storing it past the turn) such as distance (is the monster in melee range), status effects (is the monster confused, sleeping, etc) that could be used to assess danger level. My issue is that the danger assessment I've got right now is garbage. It's convoluted and it doesn't address actual danger level (though it does have funny consequences, such as the bot freaking out a couple games ago whenever he saw hobgoblins, and not worrying about ogres).

Does anyone have any suggestions for how I could take that data and create some kind of effective danger assessment?

(I'm also basing danger on non-monster factors of course, such as HP, whether or not I can berserk, cumulative monster danger (for when there are multiple monsters in LOS), etc.)

For this message the author 7hm has received thanks:
mageykun
User avatar

Vestibule Violator

Posts: 1459

Joined: Sunday, 19th December 2010, 05:45

Location: New England

Post Sunday, 27th March 2011, 06:11

Re: Lua scripted "bots"

Crawl Playing AIs? Cool! I'm definitely going to give these a try- but make sure they have their own high scores table.

Vaults Vanquisher

Posts: 447

Joined: Thursday, 16th December 2010, 22:10

Post Sunday, 27th March 2011, 06:23

Re: Lua scripted "bots"

Notes:
phybot isn't purely a bot; phyphor occasionally helped it.
the current bots are designed to play FeBe
I'm assuming putting the trigger on d is so it will choose dexterity on levelup, so put it somewhere else if you would prefer a different stat

I might make my own bot sometime, or at least an assistant to do things I don't like doing manually, in the vein of autoexplore and autofight

7hm

Snake Sneak

Posts: 109

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

Post Sunday, 27th March 2011, 07:25

Re: Lua scripted "bots"

MrMisterMonkey wrote:Notes:
phybot isn't purely a bot; phyphor occasionally helped it.
the current bots are designed to play FeBe
I'm assuming putting the trigger on d is so it will choose dexterity on levelup, so put it somewhere else if you would prefer a different stat

I might make my own bot sometime, or at least an assistant to do things I don't like doing manually, in the vein of autoexplore and autofight


Yeah phybot does need the manual assistance. The bots are designed to play Bes, and FeBe works best because of the sInv, lack of weaponry, and easy eating. If not for lack of sInv I think TrBe would be even better than FeBe for a bot's purposes (weaponry isn't THAT big of a deal, just go axes and make him upgrade when he sees an upgraded base type until the bot has real itemid ).

Vaults Vanquisher

Posts: 447

Joined: Thursday, 16th December 2010, 22:10

Post Sunday, 27th March 2011, 07:54

Re: Lua scripted "bots"

extra lives also help a lot as a stupidity/badstuff failsafe; even if the bot dies, any summoned BiA will probably take out the killy threat
with better risk assessment/management, though, that would probably matter a lot less

Return to Game Design Discussion

Who is online

Users browsing this forum: No registered users and 164 guests

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