AI: what's best?. (simple though)

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

AI: what's best?. (simple though)

Post by 3DModelerMan »

Hi I was wondering if you could help me with a simple question I have.
When I implement AI in my game ("when" is tomorrow) how should I detect when the enemy should move left or right?. Should I use a couple greater than's on the position?, or maybe test the distance then check if it's on either side of a character and move it?, or maybe something else?.
Thanks :D .

P.S
Sorry if this is a silly question, it's my first time with any AI.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Check out irrAI.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Well really, to be honest, artificial intelligence is a bit of an application-specific topic. He may want waypoints, which IrrAI provides, but he also may have the need for steering behavior.

Not enough information has been provided.
TheQuestion = 2B || !2B
oldskoolPunk
Posts: 199
Joined: Wed Nov 29, 2006 4:07 am

Post by oldskoolPunk »

I think what he wants is a starting point? Maybe an idea of ow its done by the big boys? (no offence intended, I would also like to know more)

So far my AI has consisted of a bunch of IF THEN ELSE type statements. What else is there?
Signature? I ain't signin nuthin!
Frank Dodd
Posts: 208
Joined: Sun Apr 02, 2006 9:20 pm

Post by Frank Dodd »

IrrAI does look like an tool that is worth spending some time investigating, as a library it obviously provides a fixed set of functionality but that functionality looks impressive. I have looked into AI a little myself while putting together a project concept and i'm getting the feeling that there are two techniques that are worth knowing in particular.

A* is a path finding algorithm that works on a series of interconnected cells the most conventional being a, it appears quite simple to implement and allows your characters to seek paths to particular objectives, i suspect that it can be applied to waypoints too. There is a nice tutorial over at http://www.policyalmanac.org/games/aStarTutorial.htm

State Machines are a common programming technique and a simple way of controlling an NPC's state and a way of giving them the appearance of reacting to their environment and making considered decisions. There is a good analysis of it at http://www.ai-junkie.com/architecture/s ... tate1.html

In fact http://www.ai-junkie.com/ai-junkie.html is a great resource for giving you a good understanding of simple implementations of some the more sophisticated AI techniques of Genetic Algorithms and Neural Networks, while you probably wouldn't want to use them they are still fun to check out.
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

3dModMan, if you want to simply detect whether to turn left or right, see this topic. I posted a snippet there that will do just that.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yeah you need to provide a lot more information for us to help you. From what you've suggested your game could be pong. I'm thinking it probably isn't so tell us a bit more about what your NPCs are required to do and when they should do it etc.

Certainly look into IrrAI and see if it would fit your requirements... 0.5 is on its way and should hopefully be out fairly soon (depending on certain career decisions i'm currently making). Waypoints are something you can use but they're not a requirement, you can fairly easily write your own AI Entity which would not require waypoints at all (in the new version, not so easy to do that in 0.4). I have to say that 0.5 is going to be a rather different API, mostly in class names, so might be rather hard to upgrade to from 0.4 so you may just want to wait until 0.5 to get stuck into it, if you decided to, but by all means check out the examples and see if anything there looks vaguely useful, i'd be glad to discuss your project's AI requirements more in depth via PM.
Image Image Image
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

oh

Post by 3DModelerMan »

Well I sure got alot of responses!, thnks :D . I'm doing a smash bros type fighting game, where it's in 3D but it's played 2D,and what I want is my oponent character to be able to seek out the player character until it's a certain distance away, the problem is that I don't know if I should just have the computer player seek out till it reaches a certain distance from the player, or if I should have it do something else. Though I'm sure I can figure it out with the help that I got.
Thanks :D .
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
fmx

Post by fmx »

smash-bros type fighting game? Definitly wouldn't have been able to guess that from your first post, and I don't think the AI requirements would be quite so simple either.

Imagine a human player playing the game, what would they see and take into consideration before making their next move?

in smash-bros, all the players are all visible, so we would normally just go towards the nearest player (distance checks) who doesn't have some kind of special power (basic IF..THEN checks), then start attacking then (no checks, just attack!).

some players like to wait until an opponent comes near enough, others just go gung-ho and attack anyone and everyone. Having different AI profiles will make your game(s) more interesting, so don't fall into the trap of thinking theres only one way to do this, the more variety the better.

just think it through step-by-step and you'll be able to make a simple working system in no time.

:)
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yeah it should be fairly simplistic in a simple case. Just get the vector between the AI and the player and move in that direction if the magnitude is above a threshold (the distance you have to be within for your attack to make contact).
Image Image Image
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

ah

Post by 3DModelerMan »

The movement is really working good now, With the attacking though would it be best to check the distance to the vector with "=="?, and what should I use for a random seed?, maybe the timer?. I've got four different moves that I can use, I have one that can be used from underneath, one that's a single sword swing, one that's a spinning swing attack, and the last one is similar to the final smash(you need a special power up to use it). Thanks for the help so far, I really appreciate it :D .
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
CodyCer0
Posts: 41
Joined: Mon Dec 08, 2008 3:07 am

Post by CodyCer0 »

Well, what I honestly would do is put in a function called "makeDecision()" that acts as a random chooser effected by a numerical variable called "stress" and multple variables that will bool true or false called "situation1" "situation2" "situation3" etc. Will depend on developers of "said" game what that situation entails.

Say a situation where more than 1 player is really close to the aiNode(lets say DK from super smash for example). Say the above situation is "situation2"

you would put something like

makeDecision()
{

if(situation2 == true)
{
doublePalmSmash();
}

}

And the higher that numerical variable "stress" is, the more powerful(yet stupider, maybe, depends on developer's) attack decisions he will make.

You should get the idea of what I'm saying.

And with that, I'm out.

But to go more in depth, I will pull out some more stuff for it, BUT I DON'T KNOW IF C++ DOES RANDOM LIKE THIS, I AM GOING TO BASICALLY USE ACTIONSCRIPT FOR THAT!

makeDecision()
{

randomChooser = Math.random(5);

if(situation2 == true)
{
doublePalmSmash();
}

if(randomChooser == 1)
{
followNearestEnemy();
}

if(randomChooser == 2)
{
followAnyEnemy();
}

if(randomChooser == 3)
{
dropBanana();
}

if(randomChooser == 4)
{
sonicBello();
}

if(randomChooser == 5)
{
throwBarrel();
}
Post Reply