Sunday, April 17, 2005

Bots and pipe dreams

I actually suspected this blog would turn out to be something that I will rarely update. Perhaps I should let people know about it, which might very well motivate me to continue. Anyway, on with the post that has been gathering dust as a draft, for weeks I think.

When the Playstation 2 I borrowed broke down, I had to find something else to do with my free hours. That something should have been learning to use the Source SDK but alas, I have spent very little time with that.

I don't remember what exactly gave me the idea, but I started writing the foundations of a Java program that could communicate with various web sites and other internet resources, such as forums, search sites, e-mail, dictionaries, blogs etc. I had, or perhaps still have, vague ideas of creating an AI bot that could pass as a human internet user and be useful to real people in some way. My current plans have scaled down a bit...

I started with a vBulletin forum interface, but then got stuck. I had no idea what exact functions the bot would have. As a quick distraction, I wrote a very simple console application for browsing vBulletin forums. I tried it out on a couple of forum sites, but it only seemed interesting for a little while.

Then I revealed my coder's block at Idle Thumbs and asked for suggestions on what the bot should do. Jake Rodkin came up with the idea of people playing interactive fiction (otherwise known as text adventure games) cooperatively on the forums. I liked the idea and soon had a somewhat functioning Zork I running on the Idle Thumbs forums. The "bot" communicated with a DOS version of Zork, which I found quite lacking both in performance and security. Being a layman when it comes to IF, I only found out that there were lots of interpreters for the Infocom games after a short discussion with Jake about how he would like to put the bot to use. I found some open source Java Z-Machines, like Zax, Zplet and Zinc.

Zinc seemed the most recent (possibly even alive) and flexible, and I decided to go with that. After hours of reading the Zinc source code, I finally realized that I was looking in all the wrong places -- an unused import threw me off, until I decided to let Eclipse organize the imports. I was then able to extract just the Z virtual machine and modify it's wrapper to suit my own needs. After some more hours of input/output hassles, I finally saw my error in thinking and got it working well enough for what I needed, if not the most efficiently. I have still a lot to learn about multithreaded programming.

Since then, I think the bot has evolved quite well, and is more and more starting to resemble something that could be called a bot instead of a set of small, disposable applications. It now supports TADS 2 games as well as the Z-code games, handles exceptions better and can be run as a service/daemon on many platforms (tested on Windows XP and Mandrake Linux). At the moment I'm busy with getting the code as stable as I can, and release the initial version to the Idle Thumbs staff, who will put it to use on their forums.

No comments: