Tutorial- a game of tag

Well, after months of studying for my big test, it’s over now and I can spend my time doing something else other than memorizing information.

I decided that I would make a short program, less than 300 lines, about some simple computer AI so I made a simulation of a game of tag mostly as a tutorial to help newbies see that it’s not that hard to get the computer to have some basic game intelligence.

mavasher.p3dp.com/Tag.zip

I think’s it’s commented appropriately- if you have any questions, let me know.

The red ball goes after the blue balls which try to avoid it. When a ball is tagged, it becomes the tagger and the red ball turns green for a time to show that it has a period of time free to prevent tag backs.

You just observe, there isn’t any player interaction with the program.

Pretty cool. How do you steer the characters? I was actually thinking of implementing a game of tag in Panda, as a demo of my steering behaviours code form a while back. Just use the pursue and evade steering behaviours, and when a players gets tagged they use messenger to send a message saying they are now it, which the rest receive and start evading this player now.

Your steering behaviors could be used the same way I used mine here. If I understand your code correctly your Vehicle class uses forces to move the node around.

My Guide classes (Guide2D and Guide3D) are very similar but use Panda’s HPR system directly to steer the node while the node advances in its Y-axis.

In practice they probably look exactly the same. Your code is probably closer to actual physics where mine tries to just treat the node as a steering vehicle .

I use just the standard “Seek” and “Flee” behavior because as far as the code is written it doesn’t matter if the target is static or moving. The Guide2D in the program is a little stripped down- In my space game there is also a “Dodge” routine that tries to fly at 90 degrees to the pursuer to avoid being hit by blaster fire.