Advertisement

AI - Where do I start?

Started by March 27, 2001 05:27 PM
16 comments, last by codeword 23 years, 9 months ago
This is my first post on gamedev.net, so, hello everyone! What I would like to know is how can I get started doing some artificial intelligence programming? Please don''t reply saying, "Get some books on AI" and if you do, can you please be specific? I don''t really know anything about AI except for the buzzwords like "neural networks" and "fuzzy logic" and the like, so any resources would help. Oh, and another thing -- I''ve searched the net for AI before and have ended up on pages that seem to be way out of my league. Is there an "AI for Dummies" book floating around that I could read? I saw a cool screensaver that inspired me and got me thinking about AI. I think it''s called "blaster" included in xscreensaver 3.30. It''s a bunch of little ships flying around shooting at each other. I thought it was pretty cool to watch, though it didn''t seem like the AI was that great. I''d like to extend the graphics to 3D and improve the AI to make it seem more realistic -- Big goals for someone who doesn''t know a thing about AI Any help would be appreciated. dea
quote:
Original post by codeword


quote:

This is my first post on gamedev.net, so, hello everyone!

What I would like to know is how can I get started doing some artificial intelligence programming? Please don''t reply saying, "Get some books on AI" and if you do, can you please be specific?



Artificial Intelligence: A Modern Approach - Russell and Norvig
Game Programming Gems - Deloura et al (Chapters 3.0 to 3.9)


quote:

I don''t really know anything about AI except for the buzzwords like "neural networks" and "fuzzy logic" and the like, so any resources would help. Oh, and another thing -- I''ve searched the net for AI before and have ended up on pages that seem to be way out of my league. Is there an "AI for Dummies" book floating around that I could read?



No "AI for Dummies" books that I know about, although I did co-moderate an "AI for Beginners" panel discussion at the recent Game Developers Conference in San Jose. It was a great session.

I would also suggest you visit http//:www.gameai.com and check out the links it offers to various sites.


quote:

I saw a cool screensaver that inspired me and got me thinking about AI. I think it''s called "blaster" included in xscreensaver 3.30. It''s a bunch of little ships flying around shooting at each other. I thought it was pretty cool to watch, though it didn''t seem like the AI was that great. I''d like to extend the graphics to 3D and improve the AI to make it seem more realistic -- Big goals for someone who doesn''t know a thing about AI



Perhaps you might want to consider something a little less ambitious for your first project. Try to figure out and implement an AI for Tic-Tac-Toe or the Traveling Saleman Problem (look it up on the web). A project that would involve less graphics and focus more on learning about AI.

AI in computer games is not a trivial topic, one that can be mastered by reading one book. It takes doing the research, the study and then implementing (many times) to "get it". The best advice I can offer is to do the research, be patient with yourself and make as many little implementations of AI as you can.

Good luck,

Eric
Advertisement
Cool! I defeinitly realized that AI would take research, but all the resources I''ve ever come across assumed that I had some kind of understanding of AI.

I appreciate the project ideas too. Those will definitely help. My goal is ambitious, but with time, effort, and persistence, (and lots of help :-P) I know I can do it. Thanks again.

dea
I'll show you some very (very) basic 'creature' AI to get you started...

Well, I'll assume that you know a thing or two about C or C++. I'm new to AI as well, but I'm almost done my first AI project. The project is about a creature who is named BOB; he becomes hungry, lonely, tired and sick. You can just test for some cases while in the main loop of the application like so:

  while(1){	switch(feeling)	{		case MOVE:		{			MoveBob();		} break;		case HUNGRY:		{			FindFood();		} break;		case LONELY:		{			FindFriend();		} break;		default:		{			//shows he doesn't have to do anything right now.			return (1);		} break;	} //end switch()}  


Basically, well... what I did anyways, you make a fairly long switch or if statement to determine what Bob's feelings are and act based upon that. Of course, this is only the very base of programming a creature like BOB: all the functions, such as FindFriend() and what not have to be programmed, but using a little simple mathematics, imagination and some tricky programming, you can make a fairly complex creature.

Edited by - Fredric on April 9, 2001 8:13:13 AM
3D Math- The type of mathematics that'll put hair on your chest!
the best way to go about designing ai in my opinion is called the "iterative design process"

1. start off with something really simple like switch (rnd(4))
2. wait until the ai does something stupid
3. build on the code so the ai doesnt do that stupid thing again
4. goto 2
..Though, as our lecturer said in the first AI course we had: The mere use of if-statements (switches) is never AI!

Quite simplified, of course, since you can''t draw a definite line where a program becomes complex enough to be AI in his eyes. Still, he was quite upset when anyone suggested that a code snippet such as the one mentioned above could be called AI, and he does have a point.
Advertisement
It''s the problem of defining intelligence. Anything you can break down and analyse until you understand, by default, cannot be intelligent.
By that reasoning if an alien being so advanced as to be able to analyse us completely (because we merely use those simple neural network style decision making algorithms) were to look at us they would not find us intelligent.
As Marvin Minsky once said, artificial intelligence is the study of the simulation of any process which, if carried out by a human being, would be considered intelligent. Therefore you should be studying behaviour not mechanism when looking for intelligence.

Mike
I think that Fredric code is a very good start to build a good AI.
Does every one have a best main loop (w/ genetic or neural maybe)?
My own is very the same:
My bot have a Stat[] array that stock both input an output as float like:
input:
ENV_HIT if the bot was hit this frame (1 or 0)
ENV_HEAL store the % of heal ( between 1 & 0)
ENV_SEE if the bot see an ennemi
output:
NEED_ATTACK if the bot wants to attack
NEED_PATROL if the bot wants to patrol
NEED_FOLLOW if the bot wants to follow the ennemi

and somme rules like the LS-1 rules ( but i writre like if...then statement here):
if( Stat[ENV_SEE] ) then Stat[NEED_ATTACK] += Stat[ENV_SEE];
if( Stat[ENV_SEE] && Stat[ENV_HEAL]) then Stat[NEED_FOLLOW] += Stat[ENV_HEAL];
if (1) then Stat[NEED_PATROL] += 0.5;

After doing this assignement, I scan all the need by type ( for legs, for eyes , for gun) and I choose the most rated state.
In this case it's simple ( max 2 states for the movement follow or patrol) but i hope it would works for many states.



Edited by - jesterlecodeur on April 13, 2001 7:08:58 AM

Edited by - jesterlecodeur on April 13, 2001 7:12:23 AM
_______________
Jester, studient programmerThe Jester Home in French
My method for implementing what I prefer to call synthetic intelligence (SI, because it imitates true intelligence) is based on the concepts of behavior and personality. Personality can be thought of as the pattern of repeated behavior (actions) and the frequency thereof. So a Coward has only a, say, 25% probability of fighting an enemy while a Hero might have a 70% probability when faced with the same opponent. A Berzerker, on the other hand, might have a 99% probability!

Thus, if this particular tendency is represented on a scale of 1 to a 100 (percentage), then

if ( (rand() % 100) < threshold ) // proper alignment
{
fight();
}
else
{
wuss_out();
}

This same principle can be applied to skill levels, such that a more skilled character is more likely to successfully achieve a certain objective, from throwing a ball into a hoop to correctly timing a jump. These "base abilities" can be modified by user input to allow the skill of the character controlled affect the user''s level of play.
Andre Lamothe''s book "Teach Yourself Game Programming in 21 Days" has a decent introduction to game AI techniques.

Simple AI techniques are easy to program. Start out with two people on either side of the screen who shoot at each other.

PERSON 1 AI



if (enemy bullet exists)
if(person1.y==enemy_bullet.y)
person1.y++
if
if (person1.y>person2.y)
person1.y++
else if (person1.y person1.y--
else if (person1.y==person2.y)
fire_bullet()



Just reverse it for person 2. This should create two little men who move up and down the left and right sides of the screen, firing bullets at each other and avoiding the bullets fired at them.

Start with basic behavior like this, and gradually add more complexity. For instance, you could check how far the bullet is from the person and decide whether to snap off a quick shot or evade, or you could add health and have a person flee when his health gets too low.

You can obviously also allow the people to move along the x axis, but this will involve a little trigonometry to calculate the bullet vectors.

Anywho, hope this helped.

You''''re just jealous because the voices are talking to me!
You''re just jealous because the voices are talking to me!

This topic is closed to new replies.

Advertisement