AI: what's best?. (simple though)
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
AI: what's best?. (simple though)
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 .
P.S
Sorry if this is a silly question, it's my first time with any AI.
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 .
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
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
-
- Posts: 199
- Joined: Wed Nov 29, 2006 4:07 am
-
- Posts: 208
- Joined: Sun Apr 02, 2006 9:20 pm
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.
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.
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.
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.
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.
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
oh
Well I sure got alot of responses!, thnks . 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 .
Thanks .
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
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.
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.
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
ah
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 .
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
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();
}
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();
}