Ai [Archive] - C Board

PDA

View Full Version : Ai


bobthemighty
05-14-2002, 09:03 PM
Hello. I need help with the AI that I am writing for a bomberman-type game I am making. Seeing as how I've never done any "real" AI for any of my games, I don't really have a clue what I'm doing. Up until a couple of days ago I thought I was doing okay, but the more code I write, the more weird the AI acts.

Does anyone know where I could find some tutorials, books, source code, or anything else that could help? I REALLY want to get this to work.

Basically, this is how my code works:
Every time something relevant happens (bomb layed, player died, item dropped, etc..) a message gets sent to the player. The ProcessMessage function then generates an importance level for 5 different actions (keep moving, get item, avoid explosions, kill player, destroying blocks), and adds the best choice to a list. About every half a second or so the player's go though there list of actions and insert them into a list of 2 orders based on the importance level, and prepares the neccessary information for completing the order (like a path).

Is that a good way to go about it? Or is it retarded? Please help!

Thanks

Dissata
05-14-2002, 09:36 PM
gamedev.com . . .

I bought a book on the theories of A.I. Helps a lot with the logic and creativity side.

Vicious
05-14-2002, 10:39 PM
Ive never done "real" AI. But one thing ive found is you need to prioritize that AI. Put the most important AI code on top... ect.

TechWins
05-14-2002, 11:55 PM
I, too, like Vicious have done a 'real' AI, but I still think I can give you some advice.

Yes, you have to prioritize of course. However, I think you should prioritize at more than one level; I'll explain.

The categories you listed for certain actions in the game are "bomb layed", "player died", and "item dropped". The categories you listed for certain actions the AI should take are "keep moving", "get item", "avoid explosions", "kill player", and "destroying blocks". However, I'm sure that there are more, but that is irrelevant.

For each game action there should have a list of the actions the AI should take. For example the number one response the AI should have to a bomb being layed would be for the AI to avoid an explosion. The AI's second response might be to keep moving (after the AI's action of avoiding explosions should come this). The AI's third response might be to try to kill the player (after the AI has avoided all of the explosions and went is on the 'move'). For each game action you should list the all of the possible reactions the AI should take.

You'll notice that I added in after a certain AI reaction has been performed. The AI should not only be able to react to the human, yet, act on it's own. What exactly do I mean by this? If you will have your list of (re)actions the AI should take to a game action. While the AI has to be able to react to ingame situations, it needs to be able to create it's own actions for the player to have to react to. Rather than the player constantly acting upon a reaction of the AI, the player will have to ract upon the reaction and action of the AI.

By using the method I mentioned I believe you will be able to achieve a fairly potent AI. If you are still unclear you can look at this pseudo example I'm going to give you below.



if(bomb laid)
{
detect bomb();
if(area == not safe)
{
find safe area to move to();
if(player == near && player area === safe)
{
kill_player();
}
}
if(area == safe && other area == safe)
{
find the safe area to move to();
if(player == near && player area === safe)
{
kill_player();
}
}
if(area == safe && other area == not safe)
{
wait();
while( wait() )
{
optimize wait(); //e.g. health, items, collect, etc...
}
}
}



It seems to me that an algorithm would work efficiently, but I may be wrong. Remember that I have only done tic-tac-toe AI, so I could very well be wrong in thinking that an algorithm of that sort will work. However, I think it will work and quite well too.:)

Vicious
05-15-2002, 11:56 AM
Yes, if in doubt ask tech... He will give you an essay for an answer.
(Even if he has a "real" essay he should be doing for school)

:p

TechWins
05-15-2002, 04:10 PM
Well, I figure people are better off I give a thorough post. Would ya agree? But sometimes I actually do post a short, simple answer...but typically not in this forum lol.

By the way, I started to write my essay the other night, and I got through the introduction part of it, then I decided to give it up. So basically I lost about 10% of my grade right there. The part that I did write, though, was very well written, in my opinion. In fact it was probably my most descriptive writing ever.

But what do you think of my explanation on how bobtm should do his AI?:D

TechWins
05-15-2002, 04:11 PM
BtW, typing that much isn't much for me, because I type fairly fast and the words/thoughts come to my head easily/fast. Not that I'm trying to brag or anything.:)

Vicious
05-15-2002, 04:12 PM
heh... It makes me wanna go and program a bomberman game :P
I just wish Dev-C++ had some good graphic support :(

TechWins
05-15-2002, 04:22 PM
heh... It makes me wanna go and program a bomberman game

yeah, i know programming AI is kinda fun. i wish i could spend more time concentrating on programming an AI than anything else.

I just wish Dev-C++ had some good graphic support

well, isn't that why you're learning win32 API?

school is over for me next friday (24th) so i'll be able to spend a lot more time on programming.:cool: and other things like getting in touch with my feminine side.;)

Vicious
05-15-2002, 04:27 PM
>> isn't that why you're learning win32 API?

Umm.. im kinda not any more. I figured i need to atleast make som programs with classes, strings, pointers, ect.

>>like getting in touch with my feminine side

Dude, thats like the first almost comedical thing ive ever heard, or read that you made. :p


Umm.. you were just jokin tight?

TechWins
05-15-2002, 04:37 PM
Dude, thats like the first almost comedical thing ive ever heard, or read that you made.

like i said, i typically don't make jokes on this forum. but with that kind of a response that gets me thinkin'...hmmmmmmmmm....

Umm.. im kinda not any more. I figured i need to atleast make som programs with classes, strings, pointers, ect.

that's the same exact thing i did...started to learn it then decided i needed more practice with other stuff.

and yes i was just joking...i'll actually only be doin' a few things over the summer, working, lifting, programming, playing Bill Gates' special little box, and hangin' with my friends when i get the chance...nothing involving getting in touch with my feminine side...but i wouldn't mind getting to touch a feminine side hehe, if you know what i mean.;) Summer sucks for me because I live in AZ so we are very lucky if we get one day under 100 ..........ing degrees during the whole summer!

Vicious
05-15-2002, 04:39 PM
You mean you go... outside?
Sheesh

And as for Bill's little.. er.. quite large box. Ill be playing that too. That and programming are the only things on my list.

TechWins
05-15-2002, 04:46 PM
You mean you go... outside?

As long as that big, bright yellow thing outside isn't up.

And as for Bill's little.. er.. quite large box. Ill be playing that too. That and programming are the only things on my list.

I'm going to buy World Series Baseball this Tuesday and probably Hunter: TR as well. Those games are gonna rock!

Gee, we sure do like to spam don't we?

Vicious
05-15-2002, 04:48 PM
Nah I hate proscessed meat.
OH that spam... yep sure do.

Once i stared at that big yellow thingy for a few mins.
:D

Dissata
05-17-2002, 11:11 PM
tha wxplains a lot! :p ;)

SilentStrike
05-17-2002, 11:36 PM
http://www.flipcode.com/cgi-bin/msg.cgi?showThread=00001370&forum=general&id=-1

TechWins
05-18-2002, 01:24 PM
tha wxplains a lot!

I have no idea as to what you're trying to say?:)

Dissata
05-18-2002, 03:46 PM
me neither:(

oh well probably something stupid that I thought was ingenious the night before:)

Vicious
05-18-2002, 11:44 PM
I would imagine that he was refering to my
"I stared at the sun for a few mins"
by sayin'
"That explains alot"

?????