I was approached recently by a client wanting a 3D game environment in which players could talk to “bots” (artificially intelligent chat bots) by typing text and receiving replies. The chat bots were to live on a server while players would launch a 3D game client to login to the server.
As part of the login process users would select an “activity” (a scene). Each scene was to be populated only by certain chat bots; every chat bot was to have its own ‘AI brain’ and would thus converse differently with the user to other bots.
A tall order! The screen shots below show how it panned out:
So where to begin? The obvious starting point was the server. All that was required was the ability for it to host bots, allow user login and exchange chat (text). XMPP is a common ‘instant messaging’ protocol – in fact, it is used by Google Talk (on that note, our final software can actually be used with Google services as easily as our own server!). The XMPP protocol was originally named Jabber. Openfire Server is a free, cross-platform, open source Jabber server. It’s what was opted for and installed on the server. It was installed and user accounts created for real players and the non-player characters (NPCs, our bots).
With the server up and running the next logical step was a Jabber Bot. No need for 3D at this stage, we just wanted some software that would connect to Jabber, accept messages, process those messages and send back a reply. The simplest starting point is an “echo bot”, a bot that simply repeats back whatever you type to it (very annoying!).
Since it was already known we would be using Panda3D for the 3D engine (see later in this article) it made sense to keep the technology consistent and write out Jabber Bots in the Python programming language. It also turned out there was an excellent Python library for communicating via XMPP called SleekXMPP. A working echo bot was nailed in no time!
The bots now needed some intelligence. The artificial intelligence mark-up language (AIML) was chosen. AIML is simple to grasp and was deemed sufficient for our purposes. Constructing ‘brains’ in AIML (i.e., different bot personalities/responses) consists essentially of copying a set of XML files and modifying them to suit.
There is an ‘example’ of implementing an AIML chat bot in Python called Howie. Essentially, a new generic bot was written (affectionately known as “Bob the Bot”) that was a combination of Howie and SleekXMPP. Bob the bot gets his specifics from a configuration file detailing who to login as, which brain to load etc. Thus, “new bots” are simply “new configuration files for the generic bot”.
The 3D Client
As we noted earlier, Panda3D was chosen as the game engine. The reasoning is outside of the scope of this short article but the short answer would be “Panda3D is awesome!”. There’s not much to discuss in this section – see the screen shots above! Essentially a 3D scene is selected and loaded. The room was created using Sweet Home 3D. The scene is populated by designated bots, our actor models came from Code3D (open source). All of the Jabber functionality comes from SleekXMPP. The rest was just raw coding!
That’s All Folks!
I hope this has been useful to some. I am hopeful of open sourcing the project in the near future, pending consent from my client.