Working with AI

I have been working on a lot of things. Mostly on learning AI implementation. This week I have been working on learning all the simple AI behaviors (I’m very new to this stuff) and finally got it all working last night. I had been stuck on getting my wondering behavior working. Turns out that while cleaning my code, I had left an old variable laying around. I hate it how this small details give you such headaches.

In the process of learning all this stuff, I have found a new love for AI. The complexities of it and the subtle things that make it great even on the most simple games. The book I’m reading is It’s is certainly a great book though I wish the pseudo code was a bit better as far as what each function needs to pass and return. I guess their idea is to make it as open as possible, the downside is that if you’re learning, you’re left wondering.

So I currently have the following behaviors:

Seek: It moves the object to a target at a set speed. Object rotates to face the target and then moves forward.
Flee: It moves the object away from a target at a set speed. Object rotates to face away from the target and then forward
Wander: It moves the object around. First forward and then with a chance of modifying the orientation left or right.
Homebound: This one I kind of invented just to experiment. Homebound moves the object to the defined starting point. It uses the Seek steering and the only real difference is that once it reaches the target, it will return to facing the last stored orientation. This can be useful for “patrolling” behaviors.
Static: Does nothing. This is an actual needed behavior. Even if there is no movement involved, having the ability to control what a object does when it’s not moving, makes it very useful.

Version 5. AI Behaviors

Finally, here is the screenshot of the program. The red rectangle is the bounding box of the object. This is basically the rectangle that determines where an object is being hit or the size of the object when rotated. There are just too many reasons to have this. Obviously, it’s just debug information to have it colored and drawn. In an actual game, this would certainly be invisible to the user.

I have also added some text on the left side. The Cylon raider are numbered 0-9 (a 10 size array) with the information on rotation and position on the screen. This was very useful when trying to find out if the objects where behaving correctly at the early stages of making the AI. Now, this is a bit redundant. However, having information displayed like that has become essential to me. Learning on my own, I used to struggle a lot trying to trace where things where going or what they were doing. I have since then learned that you can learn a lot by just letting the program run and display as much information as possible about what’s going on.

The next step will be to add the collision back into the game. I already have working collision behavior for bullets from a previous version. I just need to find a better way to manage all the interaction between the assets to minimize the number of cycles while maximizing the information output.

Comments are closed.