Advertisement

Is AI fun to program and one question about direction threory.

Started by May 26, 2008 03:36 AM
7 comments, last by Treb 16 years, 5 months ago
Hello I am still searching for the position that I am well good at in the game development world and collision detection isn't sort of my thing. I think AI for simulation would be kinda easy depending on how you want to do it. So whats it like programming AI? What is the obstacle that is usual that you need to over come when programming AI for simulation or game? Also I looked over on how the Doom Engine AI worked with some other source codes and haven't or bothered going over the East, West, South, North dir is something I wouldn't mind knowing how they define in a game world that is only composed of x,z axes for a AI facing direction. I already layed down a entity properties system for my simulation program of AI. I.E health, attack distance, damage, team what not to each entity AI that is spawned in the game. I just need to know how to calculate east and west and so forth on setting up a goal system for the AI. One other thing is lets say I want a entity to be attacked to something. I.E Health, but not give up attacking a foe. Sorry if this posted seemed like giving home work, but I wanted to be a bit detailed on what I am doing.
Check out my open source code projects/libraries! My Homepage You may learn something.
Is it fun to program AI? - Well, I suppose that depends on who you ask? Some people find it very interesting, others might not. And what difference does it really make for you, if some people find it interesting or not interesting? Try to make some sort of AI yourself and find out if you think it's fun. And if you think it's fun, then that's just great. :-)
Advertisement
Quote: Original post by ajm113
I think AI for simulation would be kinda easy depending on how you want to do it.

That would depend on what you're trying to achieve with your AI. If you want your NPCs to merely follow pre-defined paths on a map, or human-scripted sequences of actions, then yes, the objective is fairly easy to translate to code. If, however, you want an NPC capable of solving complex decision problems about which goals to satisfy at the present time, which tasks it believes will solve achieve those goals and how to do this in real time, in an information poor, computationally restricted environment... well, now it's going to get tougher! ;)

If all game AI were easy, most games out there wouldn't be far more interesting than they presently are.

Cheers,

Timkin
Quote: Original post by ajm113
I think AI for simulation would be kinda easy depending on how you want to do it.

Oh brother...

I suppose I will let you off the hook because of your escape clause "depending on how you want to do it." That's true. You could always limit yourself to flipping coins or something. Simulation AI is not terribly simple, however. If you have discovered a secret, let me know.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Writing AI is one of my favorite topics. The best way to find out if you like it is, of course to try it yourself. Watching little creatures run around (and kill each other) based on the algorithm you have written is immensely satisfying (at least to me). Being able to tweak a couple lines of code to completely change them is also fun. I also like writing shaders for this same reason.

I never really thought of breaking programming up into sections like you have. I just keep programming my game, and do whatever I have to do. If you have about $30 to spare, you can check out Mat Bucklands great AI programming book.
http://www.amazon.com/Programming-Game-Example-Mat-Buckland/dp/1556220782

If you don't like math, then watch out because I've used the following many times in working with AI. Vectors (dot products, cross products), Trigonometry (sin, cos, tan, some calculus stuff like cosine law), and a lot of mathematical thinking.

Compass Direction is just a system that you set up usually based on cartesian coordinates with one axis (ie X) representing the West-East position and Nort = South position using the Y ( or Z axis if you are using 3D you might chose 'up/down ' to be the Z or Y axis).

I usually use West as down the X axis and East as up the X axis (North South are a bit more complicated because many graphics systems have 0:0 in the upper left corner (4th quadrant system) so North is down/lower on the Y axis and South up/higher. If you are using 3D the graphics relation is effected by how the library's coordinate system works (left or right habd rule) and that might effect your choice of Y Z for up/down or North/South and which way the directions work (higher/lower on the axis).

Some position system only use positive values for coordinates, other dont care (the relation between 2 object will be a positive or negative value along each axis). So game systems have local coordinates (when you have bubble/zones/rooms that you enter/exit through portals, each 'zone' might have its own coordinate system to be used by all objects in that subset of the larger 'world' map.)

Its up to you how to define the system (or upto the game engine if you are using someone else's)





One thing I learned ages ago (even before I took physics) when I started 2D type games -- the direction to move an object to get nearer another obvject is the target (object) coordinates minus the initial position (of the moving seeker object). Add that value (or a fraction of it to the position of the seeker to get closer to the target. Conversely subtract it to move directly away (as in avoidance)
--------------------------------------------[size="1"]Ratings are Opinion, not Fact
Advertisement
Ok thanks guys! Though my game is 3d world. I am only basicly using a large one leveled room of maybe about 10 AI entitys that only run around and shoot red lines across one of each other representing that entity is attacking another in a 2d perspective. Just giving a simulation of a war.

Then try to work from their. Like have the AI communicate if one of them is low on health and needs help or knows when to go retreat and so forth.

My logic for the AI is to detect which opposing AI is closer by z or x and move closer check other opposing AI for their threat level so the AI won't go after a guy then a tank right near by and know when to back away. So I got the directions figured out thanks wodinoneeye!

Though the missing part of my logic is when to tell the AI to wonder around with out going out of the battle field.

I mite get the AI, book as a reference and see what I can gain off of it, thanks Treb.



Check out my open source code projects/libraries! My Homepage You may learn something.



"Though the missing part of my logic is when to tell the AI to wonder around with out going out of the battle field."


There is a method called 'influence mapping where either staticly or dynamicly you use a gridmap (overlay of your game map) where objects map out their 'influence' (like box or square patterns with cnters being strongest working outward getting weaker).

Its a spacial analysis (in your game you could recreate it every move so it reshapes as enemies/friendlies move). You then can fairly quickly calculate if a particular direction (moving on the grid points) will take you into more threat or less.

Extending the system using projections from centerpoints (ray tracing) doing checking against terrain features (obstructions) to see where areas of cover from fire are and where protected points are (so you could figure where a good point to fire at one enemy is without being under fire from many OR where to move thru to pickup the powerups or to aid a friedly without being under fire.
--------------------------------------------[size="1"]Ratings are Opinion, not Fact
I was reading about how they used influence mapping in Halo 2 in AI programming Wisdom 3. If I was making an FPS, I would definitely implement something like that. It seems like it opens a pathways for a wide range effective AI tactics. Not to mention the AI has always been impressive and entertaining in Halo.

This topic is closed to new replies.

Advertisement