Advertisement

How can I program a small AI program????

Started by March 31, 2001 09:36 PM
2 comments, last by ProgrammingMan 23 years, 7 months ago
If you can give me any help by either emailing me or posting any info or any web sites you know of about AI please do. Thanks, ProgrammingMan chris42386@hotmail.com
www.gameai.com


Need help? Well, go FAQ yourself.


Edited by - Nazrix on April 1, 2001 9:44:41 PM
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
Advertisement
Probably your better bet is www.generation5.org

they have sample programs and code on the site for various things from neural networks to GA''s



regards,

GeniX

www.cryo-genix.net
regards,GeniXwww.cryo-genix.net
It all depends on the type of game you are building. If it''s a game like chess it''s going to be a lot more different than if you are writing an RTS or a FPS game. Very different.

One of the most common technique to program AI is to use Finite State Machines (FSM) or Hierarchical Finite State Machines (HFSM). These are very simple/easy to program and perform very well. This is one of the technique I would look first if I was building a simple game. An FSM is composed of states (such as ATTACKING, DEFENDING, PATROLLING, ETC) and transitions. So by example when PATROLLING if the unit is attacked it should transit to the ATTACKING state. Each state contains the code that correspond to the behavior the unit must perform in that state. This can get very confusing though if you have more than 7-8 states as it is very hard to maintain the FSM manually (there are visual tools that can help).

After that you may want to look at Genetic Algorithm and Neural Nets. But I attended the Game Developer Conference 2001 and I can tell you that their use are still not spread out in the industry (from what I can tell of the audience of the AI conference I attended, at least 90% of games still use FSM or HFSM as their primary technique for AI). Genetic Algorithm and Neural Nets are more complex but more satisfying in certain ways. Genetic Algorithm and Neural Nets have the capability of learning as their name implies. But this also has it''s drawback, Neural Nets you have to feed your AI with some example and teach it if what is doing is right or wrong. This can be very cumbersome to feed the example as they can get very complex. But eventually if you have the right examples you''ll have a good ai.

Genetic Algorithm is better than Neural Nets imo because you don''t have to feed it with example, it learns by itself by crossing and merging AI. You create a pool of AI instances (small program/scripts/whatever) and then you calculate the fitness of each indivual AI in the pool. This function is the key to the GA AI. You have to be able to evaluate good candidate for crossing/merging.

So to wrap this up, you should stick with FSM or HFSM for a first project! : )

One book I would take a look at to get more infos on AI is the Game Programming Gems. They have some articles on FSMs.

Hope this helps,
Patrick Lafleur

This topic is closed to new replies.

Advertisement