UNR Logo
QUAKE2AI

Compiling the Source

Even if you are using a "standard" Ubuntu installation with all the usual software development packages already installed, you will still most likely need to install additional packages with this command:
   sudo apt-get install libsvga1-dev x11proto-xf86dga-dev x11proto-xext-dev libxext-dev libxxf86dga-dev libxxf86vm-dev
Download the latest source file here, and unpack it with this command:
   tar xvfz quake2ai*.tar.gz
To compile it, do:
   pushd quake2ai
   make
This will create a sub-directory called release[ARCH] in your quake2ai directory, where [ARCH]i386 or x86_64. (Hopefully you are using i386 since graphics don't work in x86_64; if you are using 64-bit linux then you must make a 32-bit chroot environment to compile it. Once it is compiled you can use the 32-bit binary in a 64 bit environment.)

Inside that directory there will file named quake2ai.so, which is the AI interface library that allows running the game in Quake2AI mode. There is also a quake2 executable program.

Copying the id Software Copyrighted Material

Now you have a compiled binary of the game engine, but you still need to get all of the maps, textures, models, and sounds for the game. These can be obtained by purchasing a copy of Quake II. (Try e-Bay.) The Quake II media will have a directory named baseq2, which you must copy into a directory where you would like to install Quake2AI. The following example shows how to install it in ~/qtest.

Make the directory on your system:

   mkdir ~/qtest
Now copy the baseq2 directory from the Quake II media into ~/qtest:
   cp -r baseq2 ~/qtest
Now, from the quake2ai directory where you compiled the program and library, do:
   ./install ~/qtest
This will copy all the essential Quake2AI files to ~/qtest.

To test your installation, do:

   pushd ~/qtest
  ./quake2
and you should get a running program. However, you have not created the actual AI for your bot yet.

Making A Simple Bot using the C Interface

Go into your Quake2AI installation directory (qtest in the example above). Look at quake2ai.h to see what controls are offered by the Quake2AI API.

Make a file called testbot.c with this C code:

#include "quake2ai.h"

void AImain() {
	AIself_yawmove(1.0);
	return;
}

int main () {
	quake2ai_setargs("+set name Bill");

	quake2ai_launch ();

	return 0;
}
Compile testbot:
gcc -o testbot testbot.c ./libquake2ai.so -lm
Run the testbot:
./testbot
If you go to the single-player game (in Quake II) your bot will be visible, spinning slowly to the left due to the AIself_yawmove(1.0) line in the program.