Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Game Artificial Intelligence

This thread is locked; no one can reply to it. rss feed Print
Game Artificial Intelligence
BitCruncher
Member #11,279
August 2009

What's up Allegro Devers,

I have a basic framework for playable objects. Now, it is time to implement some form of AI. I have thought about the different ways to approach this.

I can create separate types of entities all falling under a large 'enemy' class, or the enemies could be clones of the playable types separated in a different vector container from the playable objects. I have also read on some other techniques on other sites.

What are some of the ways that you guys handle artificial intelligence?

Jesse Lenney
Member #8,356
February 2007
avatar

It really depends on the task at hand. You cant really write a universal AI algorithm :-/

I just think about what I want the AI to do...and make them do it.

---
"No amount of prayer would have produced the computers you use to spread your nonsense." Arthur Kalliokoski

OnlineCop
Member #7,919
October 2006
avatar

Bop-the-mole: they pop up randomly, you hit them. The higher the level, the shorter time they'd stay up.

The ghosts of Pac-Man had a simple AI: Locate the player's current tile. See what direction the player was facing. Attempt to move to a location based on different algorithms for each (one chases the player, one avoids the player, one goes "3 ahead, 1 to the side" (kind of like a rook in chess), one wanders randomly.

Super Mario: enemies hit an obstacle then change direction. Some drop of ledges; others detect ledges and turn around.

Homing missiles: Some go for the player, even if it means trying to go through a wall (and essentially blowing up on the wall instead of getting the player). Some go around obstacles like "smart targeting" and try to find you and kill you dead.

Mario Kart: Try to stay on the track. If there are obstacles, try to go around without hitting the brakes. If you get bumped off the track, find the closest path to get back on it. If you get a power-up, use it according to the power-up type (aim at another racer if it's a turtle shell, use a speed boost when you're NOT going around a tight corner)...

These are all "playable objects". But what kind of game is it? What do the AI need to do?

--
You: Yeah! I'm gonna get stuff done today!
Internet: Nope! *POW*

Jeff Bernard
Member #6,698
December 2005
avatar

What do you want your AI to do? There are so many ways one could implement AI. Here's some stuff just from the table of contents of a game AI book I've got (each is not necessarily an algorithm, but maybe a concept, hey it's prolly still important, I haven't read the whole book and haven't actually coded a lot of these):

Kinematics
Steering Behaviors
Coordinated Movement/Action
Dijkstra Search
A*
Breadth First Search
Depth First Search
Decision Trees
Finite State Machines
Behavior Trees
Fuzzy Logic
Markov Decision Processes
Goal-Oriented Behavior
Rule-Based Systems
Tactical Pathfinding/Analyses
Hill Climbing
Naive Bayes
Reinforcement Learning
Neural Networks
Minimax
Flocking

I wrote a Pacman agent (not the ghosts) for one of my classes. The behavior was simply do a specialized search to find the closest pill and mark that as the target. Next calculate all of the spaces that the ghosts could be in the next 3 cycles. Move to the space that is closest to the target while staying away from the ghosts. It was better at the game than I was.

--
I thought I was wrong once, but I was mistaken.

Tomoso
Member #3,128
January 2003
avatar

There are also a lot of good articles here you may want to pick over.

Lazy Noob - Blog

Jonatan Hedborg
Member #4,886
July 2004
avatar

What are some of the ways that you guys handle artificial intelligence?

I would probably add a property to my "unit" class called "brain". Then use different brains for different AI's or controll schemees. Ie, one for the player and several for the different types of AIs. The Brain has an update function which is called each frame, and returns what action the unit should take that tick.

Depending on the game, I would use a combination of Finitive state machines and A* path-finding.

-------
Sweden: Free from the shackles of Democracy since 2008-06-18!

Go to: