PDA

Click to See Complete Forum and Search --> : Artifical Intelligence


Xero
Nov 27th, 2000, 02:53 PM
I don't see much of this in the VB Games scene, and it obviously has to be dealt with, AI that is. Well, I am totally clueless when it comes to this, and I was wondering if anyone had any ideas as to how the *&^% it works!? Any samples or links to information would help as well. I don't really have any speicific examples, but anything general giving me a simple idea of how AI works, and any source in VB. Thanks!

Nov 27th, 2000, 03:14 PM
I will do a samll programming example.

If KeyAscii = vbKeySpace Then Player.Shoot(Enemy)

If Enemy.Hit = True Then
Enemy.Shoot(Player)
End If

Xero
Nov 27th, 2000, 03:48 PM
Well now, thats quite some complex code there, i think a *bit* simplier wud make it all clear. [ahem... sarcasm meter of the scale...] =)

But well, say i wanted the enemy to dodge that fire and then fire back at the player, hmmmmmm!?

parksie
Nov 27th, 2000, 03:49 PM
Do I detect a hint of sarcasm there, Megatron? :D

Anyway, take a look at neural nets, which are supposed to imitate how the brain works - basically a parallel computer with very simple processors, but millions of them.

One edit later...
Hmm...you noticed too ;)

kedaman
Nov 27th, 2000, 03:59 PM
Nope, Megs code is as complicated as anything can be :) All AI's are basically just a bunch of if's.
Thats absolutely correct, AI is simulation of intelligence by detecting conditions and acting according to it.
Those complex AI you are thinking of are just a a bunch of lookup tables and dynamical memory storages that is connected to the conditions.

/\/\isanThr0p
Nov 27th, 2000, 07:29 PM
YOu can pretend intelligent behaviour with state machines. Of course this has nothing to do with real intelligence, and is nothing against Neural Nets, but it has the advantage, that it is easy to implement in games. Go to http://www.ur.co.nz to read the real basics of this in the voidman tutorial.

Koralt
Nov 28th, 2000, 05:08 PM
AI *can* be made as just a set of If statements which detect conditions and react, but those ... don't do very well. Especially not for strategy or tactical games.

What I recommend to do in developing AI -- and I know this is contoversial -- is to think. Yup, to think. Think about what the AI has to be able to do (what are its potential goals?). Think about what the human player may do, and what they will most likely do. Think about what you would do in different AI situations. Then, think about how to best code it. That's vague advice, I know, but I use it, and it rarely falls short! ;)

For example, if you wanted to make a pong AI, what factors are involved?

1) Paddles
2) Ball
3) Walls

The goal of any AI is to handle the widest possible set of situations as effectively as possible. In Pong, you want your AI to make sure it will *not* let the ball past it and, if possible, send the ball to a spot that the enemy paddle CANNOT reach in time. A truly well developed pong AI would automatically be able to react to having extra balls--even without needing neural nets. I am not going to show how to make a truly well developed pong AI, just a simple one.

The way I would suggest doing it is quite simple: at any given point of time, there is a range of X coordinates at which the ball may be when it reaches the AI paddle. For example:


_ = range of x positions
= = friendly paddle
- = enemy paddly
o = ball
x = ball trajectory

##############
++

o Ball heading straight down
x
_ ==
##############
++
o
x
x
_ ==
##############


So far, it's simple: when the ball is coming at you, you know exactly where it will end up, because it goes in a straight line. The enemy is unpredictable, though: when the ball is heading towards the enemy, you need to figure out the range of directions the ball may go, and thus the range of horizontal positions that the ball may end up at. For a really smart AI, you could find the chance that it would end up at each position, and play accordingly.

So, with your range, you need to try to get to a position from which you will be able to hit the greatest portion of the possible horizontal postions by the time the ball gets back. From the time the ball starts to travel away from the AI paddle towards the enemy, the range of positions shrinks constantly. When the enemy hits the ball, you know the exact place to move to, and, hopefully, are in range thanks to predicting velocities. Of course, adding in a random element would make the game more fun ... ;)

Also, if you just want a super easy Pong AI, this always works, but is far less effective:


If AI.x < ball.x Then AI.x = AI.x + AI.vel
If AI.x > ball.x Then AI.x = AI.x - AI.vel


It works, but for most current games you want something more like what I was talking about above.

Xero
Nov 29th, 2000, 05:39 PM
Aaah... interesting. Now that was the kinda thing i was looking for! Also, im checking out this site right now that has some info on finite state machines and all that in Vb... so i might find some interesting information...

Btw, the site is http://members.home.net/theluckyleper/, very nice site for VB Game Programming- i mean, it compares to Fox's website! which i have seeked help from many o' time... plus, i wud be clueless with DDraw without it =)