Spent some time over the weekend coding an angband borg (sort of . Instead of hardcoding the borg into the angband source as has been done previously, I decided to use a python script to control the character via pexpect. Here's the result:
This will probably only run on *unix systems given the use of pexpect. Two *simple*functions are included - #uncomment# on or the other. Diver attempts to dive into the dungeon and Finder looks for stuff Nothing fancy - just wanted to demonstrate the concept.
To start the borg the character must be on a down staircase. You need to disable -more- prompts. Note that the borg use roguelike commands.
The tt parameter in the code is the time in seconds to wait on pexpect before timeout - you can try reducing this to speed up the borg.
Also - use this on a new character, don't risk your existing character
Andre
Code:
import sys import pexpect tt=0.05 class Borg(): def __init__(self): self.proc=pexpect.spawn("./angband -mgcu") #fout = file("borg.log","w") #self.proc.logfile = fout self.proc.logfile = sys.stdout self.proc.expect("[Press any key to continue]") self.proc.send("a") raw_input(">>> Press any key to begin <<<") def FindDown(self): self.proc.send("+") try: self.proc.expect("down staircase",timeout=tt) return True except pexpect.TIMEOUT: return False def FoundStuff(self): self.proc.send("+") try: self.proc.expect([ "down staircase", #Ammo "Pebble", "Arrow", "Shot", "Bolt", #Bows "Sling", "Bow", "Crossbow", #Weapons "Dagger", "Sword", "Shovel", "Gauche", "Whip", "Spear", "Rapier", "Sabre", "Pick", "Cutlass", "Trident", "Mace", "Tulwar", "Quarterstaff", "Chain", "Hammer", "Lance", "Scimitar", "Axe", "Flail", "Pike", "Glaive", "Star", "Katana", "Halbert", "Mattock", "Scythe", "Blade", #Armor "Armor", "Leather", "Mail", "Cloak", "Gloves", "Boots", "Cap", "Gauntlets", "Shield", "Helm", "Crown", #Amulates "Amulet", #Rings "Ring" #Scrolls "Scroll", #Potions "Potion", #Food "Mushroom", "Food" "Waybread", #Rods" "Rod", #Wands "Wand", #Staffs "Staff", #Books "Book", #Chests "chest", #Misc "Spike", "Torch", "Lantern", "Flask", "Phial", "Star", "Arkenstone", "Palantir" ],timeout=tt) return True except pexpect.TIMEOUT: return False def Diver(self): while True: self.proc.send("x") try: self.proc.expect("up staircase",timeout=tt) if self.FindDown(): self.proc.send("g") self.proc.send("x") try: self.proc.expect("on a down staircase",timeout=tt) self.proc.sendcontrol("[") self.proc.send(">") except pexpect.TIMEOUT: break else: self.proc.sendcontrol("[") self.proc.send("<") self.proc.send(">") except pexpect.TIMEOUT: break def Finder(self): while True: self.proc.send("x") try: self.proc.expect("up staircase", timeout=tt) if self.FoundStuff(): break else: self.proc.sendcontrol("[") self.proc.send("<") self.proc.send(">") except pexpect.TIMEOUT: break def Run(self): #self.Diver() self.Finder() if __name__ == "__main__": borg=Borg() borg.Run()
To start the borg the character must be on a down staircase. You need to disable -more- prompts. Note that the borg use roguelike commands.
The tt parameter in the code is the time in seconds to wait on pexpect before timeout - you can try reducing this to speed up the borg.
Also - use this on a new character, don't risk your existing character
Andre
Comment