3D Space Game AI Ideas?
Hi all,
I am working on a 3D space game and would love to hear everyones ideas on the best AI routines to use in it? (I expect to use different routines for different ship types!)
See my blog here for ingame videos and stuff...
SpaceUnlimited
My main AI routine for fighter ships uses a Flocking idea where each ship creates a vector for each direction that he might want to go in.
ie a vector towards baddy ships, one away from nearest friendly ship, one away from weapons fire etc, each vector is normalize and then weighted depending on importance. (ie x 5, x 10 x 100 etc etc)
The vectors are then added and the result normalized which finally gives a vector direction for the ship to head towards! See ingame videos if your not sure what I mean!
What I would like from you guys is your ideas on how you would create space ship AI routines?
Many thanks in advance.
Seems to me, that more than just going towards your enemy, you'd want to try and intercept his future position based on current velocity and distance.
And if trying to escape, do the opposite, by trying to move towards his inverse velocity.
Might also be good to consider enemey's current orientation, since thats the direction the main engine can fire to alter his current velocity, as well as where he can shoot.
Probably a good attack position is a combo of those factors, interecepting velocity, while also 'behind' the direction facing.
And if trying to escape, do the opposite, by trying to move towards his inverse velocity.
Might also be good to consider enemey's current orientation, since thats the direction the main engine can fire to alter his current velocity, as well as where he can shoot.
Probably a good attack position is a combo of those factors, interecepting velocity, while also 'behind' the direction facing.
Have the enemies synchronise their attacks, e.g.
the kamakaze units hit you just after you have been targeted by homing missiles,
close combat units stay away when kamakaze units are near you, to avoid being caught in the resulting kaboom.
kamakaze units stay out of range of your primary weapon until they are sufficient in number to take you down.
long range units fire in salvos.
bosses attack you all at once. (seriously, why do they never do that? They would be invincible if they worked together.)
Nice videos, nice game. I assume you will have large motherships that the fighters launch from, or something, to give the battlefield a sense of location? (imagine a team deathmatch, with one team launching from each mothership, with an asteroid field in the middle, or CTF with the teams raiding each others hanger in order to steal a flag.
When will you have a playable demo up?
the kamakaze units hit you just after you have been targeted by homing missiles,
close combat units stay away when kamakaze units are near you, to avoid being caught in the resulting kaboom.
kamakaze units stay out of range of your primary weapon until they are sufficient in number to take you down.
long range units fire in salvos.
bosses attack you all at once. (seriously, why do they never do that? They would be invincible if they worked together.)
Nice videos, nice game. I assume you will have large motherships that the fighters launch from, or something, to give the battlefield a sense of location? (imagine a team deathmatch, with one team launching from each mothership, with an asteroid field in the middle, or CTF with the teams raiding each others hanger in order to steal a flag.
When will you have a playable demo up?
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
If I am correct, you are working with the typical "fighter" model in that you fire forward only. In that case, you need to make sure you are not in front of enemies but rather behind them. Also, you are trying to keep enemies in front of you and not behind you.
That, in and of itself is a challenge. One way you can approach it is through the use of "flow fields" around each unit. At that point, the vectors in the flow field will give the units a directional nudge that biasses them toward certain places. In a 1-on-1, the math is fairly simple... but as other agents are added (ally or enemy) the vectors start to add up and almost start to act like an influence map saying "this is a good place... this one here... no so much."
Toting around all those vectors around each unit can get expensive, btw, depending on how many units are active at one time and how big you make the flow fields. Watch your processing power and memory.
Is it the best solution? That depends on far more factors that what you gave use here. Is it one solution... or partial solution? Sure.
Good work so far, btw!
That, in and of itself is a challenge. One way you can approach it is through the use of "flow fields" around each unit. At that point, the vectors in the flow field will give the units a directional nudge that biasses them toward certain places. In a 1-on-1, the math is fairly simple... but as other agents are added (ally or enemy) the vectors start to add up and almost start to act like an influence map saying "this is a good place... this one here... no so much."
Toting around all those vectors around each unit can get expensive, btw, depending on how many units are active at one time and how big you make the flow fields. Watch your processing power and memory.
Is it the best solution? That depends on far more factors that what you gave use here. Is it one solution... or partial solution? Sure.
Good work so far, btw!
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
I've never tried it, but how about if you divided the map up into a grid, and each cell has a count of the number of ships pointing into that grid square. Enemy ships can then use a modified zone-of-influence algorithm to head into the grid squares which are less well covered by their enemies, therefore statistically being able to attack more of them from behind.
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
Thanks for the ideas all. Much to think about.
Anyone got an opionion of using a simple learning Neural Net method?
somthing simple like below maybe?
ie i1,i2,i3,i4
n, n, n, n either 1 or 2 hidden layers!
n, n, n, n
o1,o2,o3,o4 like this but with maybe 16 input fiels not 4!
It could start of randomized and if a ship destroys another ship, then it could pass its net data onto the next ship created (but with slight random changes!)
Of course I would have to save a decent starting net data to stop the ships being too crazy and random to start with.
Over time the ships that attack the player would slowly get better and better at killing that particular game player! The ships AI would only be passed on if that Net gets a kill!
Practical or not? Would it be worth it? or just go for hard coded routines?
Thanks
Steve
ps Yes there will be big base ships for fighters to swarm from! As for a demo, yes there will be a demo over the next month or two!
Anyone got an opionion of using a simple learning Neural Net method?
somthing simple like below maybe?
ie i1,i2,i3,i4
n, n, n, n either 1 or 2 hidden layers!
n, n, n, n
o1,o2,o3,o4 like this but with maybe 16 input fiels not 4!
It could start of randomized and if a ship destroys another ship, then it could pass its net data onto the next ship created (but with slight random changes!)
Of course I would have to save a decent starting net data to stop the ships being too crazy and random to start with.
Over time the ships that attack the player would slowly get better and better at killing that particular game player! The ships AI would only be passed on if that Net gets a kill!
Practical or not? Would it be worth it? or just go for hard coded routines?
Thanks
Steve
ps Yes there will be big base ships for fighters to swarm from! As for a demo, yes there will be a demo over the next month or two!
I'm not really sure if neural nets are applicable in pointing out directions for movement in combat - for the most part, movement decisioning is based on knowledge, not training.
So, neural nets can deliver decision parts based on training, but you'll have to consider knowledge (which can change rapidly, this is why neural nets alone won't cut it) as well.
Randomizing neural nets is dangerous here, too - it can, under bad circumstances, result in absolutely random and unpredictable steering behaivour, odd things like "Oh, I must attack, let's move away from the enemy, as my brain tells me to do so". That's something to avoid!
So, neural nets can deliver decision parts based on training, but you'll have to consider knowledge (which can change rapidly, this is why neural nets alone won't cut it) as well.
Randomizing neural nets is dangerous here, too - it can, under bad circumstances, result in absolutely random and unpredictable steering behaivour, odd things like "Oh, I must attack, let's move away from the enemy, as my brain tells me to do so". That's something to avoid!
Using your brain doesn't hurt at all.
you can do most AI with state machines...
define all your possible game states, and all the events...
States are like.... cruising.. looking for enemy, turning towards enemy l/r/u/d, escaping from enemy l/r/u/d, evasive action, fly to mission waypoint, fly in formation, re-charging, flee, static
then a bunch of events...
got shot at, got hit, shields went below 50%, shields near depleted etc.....
for each state, you can do different things, depending on what events happen.
e.g while in state cruising... event get hit occurs.. you can change to state, attack enemy
but if event occurs "shields nearly depleted" then you change to state flee.
Now the control of the ship and flying is something different altogether...
for each state, you can have target positions... so for 'attacking the enemy' state... the main goal is to point at the enemy. point the heading vector of your ship towards the enemy. (or aiming at a point in front of the enemy if he is moving)
For 'evasive action' state, you probably want to fly full throttle, and keep turning.
For 'fly in formation' you would have a lead ship, and following ships, each would have a position offset from the lead ship. and they would try to maintain the same heading as the lead ship while maintaining the offset position.
If you define everything as states like this, its easy to manage your code into bite-sized chunks for the AI, and for the control code.
for each ship, give them control stats, and combat stats..
combat... Shields, weapon strength, speed of shot, recharge rate, overheat, etc....
Controls... X turn rate, Y turn rate, acceleration, top speed, braking speed, strafe speed, etc....
avoid neural nets
good luck
define all your possible game states, and all the events...
States are like.... cruising.. looking for enemy, turning towards enemy l/r/u/d, escaping from enemy l/r/u/d, evasive action, fly to mission waypoint, fly in formation, re-charging, flee, static
then a bunch of events...
got shot at, got hit, shields went below 50%, shields near depleted etc.....
for each state, you can do different things, depending on what events happen.
e.g while in state cruising... event get hit occurs.. you can change to state, attack enemy
but if event occurs "shields nearly depleted" then you change to state flee.
Now the control of the ship and flying is something different altogether...
for each state, you can have target positions... so for 'attacking the enemy' state... the main goal is to point at the enemy. point the heading vector of your ship towards the enemy. (or aiming at a point in front of the enemy if he is moving)
For 'evasive action' state, you probably want to fly full throttle, and keep turning.
For 'fly in formation' you would have a lead ship, and following ships, each would have a position offset from the lead ship. and they would try to maintain the same heading as the lead ship while maintaining the offset position.
If you define everything as states like this, its easy to manage your code into bite-sized chunks for the AI, and for the control code.
for each ship, give them control stats, and combat stats..
combat... Shields, weapon strength, speed of shot, recharge rate, overheat, etc....
Controls... X turn rate, Y turn rate, acceleration, top speed, braking speed, strafe speed, etc....
avoid neural nets
good luck
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement