AI for Galaxian Game
Hi,
Please, If someone has some stuff about ai for a kind of game like Galaxian or Phoenix Arcades, I will appreciate so much
I have some questions like:
When the enemies must attack?
When the enemies must fire?
What kind of techniques can I use?
Please, I you have some examples o you can tell me where can I find some stuff, I will apreciatte so much
Thanks a lot
Cheers,
Arcangel
arcangelg@yahoo.com
Arcangel
I don''t know the answer. All I can tell you is that Galaxian always kicked my butt. Man, I sucked at that game.
While I''m far from an AI expert here''s a couple of points:
* An enemy can attack at a regular interval or randomly, your choice. Neither is particularly hard to implement.
* An enemy would probably fire similarly, again your choice.
* To implement this you could do something like:
An enemy could the following variables to handle this:
An action variable that would be an enumerated value - ACTION_IDLE, ACTION_ATTACKING, ACTION_REGROUP, etc.
A variable to determine when to attack, again possibly an enumerate value - ATTACK_RANDOM, ATTACK_INTERVAL
A variable to tell when it last attacked
A variable to tell when to fire, similar to the attack variable
Each time through your update loop you would check the attack and last attack variables, make a decision whether it''s time to attack again based on their values and set the attack variable appropriately. The next time through the update loop if an enemy is now set to attack it would begin it''s attack. It would then begin to evaluate the time it should fire.
This is a VERY simple explanation and it''s probably missing a lot of stuff, but it''s off the top of my head and might help you in starting to build this.
Breakaway Games
* An enemy can attack at a regular interval or randomly, your choice. Neither is particularly hard to implement.
* An enemy would probably fire similarly, again your choice.
* To implement this you could do something like:
An enemy could the following variables to handle this:
An action variable that would be an enumerated value - ACTION_IDLE, ACTION_ATTACKING, ACTION_REGROUP, etc.
A variable to determine when to attack, again possibly an enumerate value - ATTACK_RANDOM, ATTACK_INTERVAL
A variable to tell when it last attacked
A variable to tell when to fire, similar to the attack variable
Each time through your update loop you would check the attack and last attack variables, make a decision whether it''s time to attack again based on their values and set the attack variable appropriately. The next time through the update loop if an enemy is now set to attack it would begin it''s attack. It would then begin to evaluate the time it should fire.
This is a VERY simple explanation and it''s probably missing a lot of stuff, but it''s off the top of my head and might help you in starting to build this.
Breakaway Games
Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development
in the games like galaxian, and galaga, all of the AI was pattern based.
Get off my lawn!
How about this:
if distance (playerX,playerY,enemyX,enemyY)>400 chase
if distance (playerX,playerY,enemyX,enemyY)<40 evade
if hit by bullet evade
calculate where player would be after a bullet reached the distance(playerX,playerY,enemyX,enemyY) and turn in that direction , direction reached OPEN FIRE !!!
I use this in my RTS game but it would also work in arcade
Programming is an art
if distance (playerX,playerY,enemyX,enemyY)>400 chase
if distance (playerX,playerY,enemyX,enemyY)<40 evade
if hit by bullet evade
calculate where player would be after a bullet reached the distance(playerX,playerY,enemyX,enemyY) and turn in that direction , direction reached OPEN FIRE !!!
I use this in my RTS game but it would also work in arcade
Programming is an art
Programming is an art
AI is not such complicated as it sounds. However, it is essential that you can seperate your thoughts in pieces.
First you need to know what you would do.
Ie. It is you and 5 other players. Player 3 is the stronger, and you have assigned him a score of 1000
Others are not much strong.
1 (you) score 600
2 score 100
4 score 500
5 score 300
What would you do?
1. You would try to get the stronger one (3) to attack the others but you, so that he weakens. So, the AI character (1), will try to make some aliance with the player 1, and he will try to forge a war between the aliance and the others.
This is a very basic thing. All this can be extended greatly, and finally end up with Personalities. But above all, you must try to analize your thoughts. Remember that the best AI is always hidden within your brain
tips:
Use scores that are generated based on some stuff.
Multiple scores for a character is the best choice.
To generate a score, take in account the user''s army, facilities, technology, resources production rate (if avaliable), player''s personality, etc...
Hope these will give you a start-up boost.
c''ya
First you need to know what you would do.
Ie. It is you and 5 other players. Player 3 is the stronger, and you have assigned him a score of 1000
Others are not much strong.
1 (you) score 600
2 score 100
4 score 500
5 score 300
What would you do?
1. You would try to get the stronger one (3) to attack the others but you, so that he weakens. So, the AI character (1), will try to make some aliance with the player 1, and he will try to forge a war between the aliance and the others.
This is a very basic thing. All this can be extended greatly, and finally end up with Personalities. But above all, you must try to analize your thoughts. Remember that the best AI is always hidden within your brain
tips:
Use scores that are generated based on some stuff.
Multiple scores for a character is the best choice.
To generate a score, take in account the user''s army, facilities, technology, resources production rate (if avaliable), player''s personality, etc...
Hope these will give you a start-up boost.
c''ya
... LEMMINGS ... LEMMINGS ... LEMMINGS ... LEM..... SpLaSh!...Could this be what we stand like before the mighty One?Are we LeMmIngS or WhAt!? ;)
February 08, 2000 09:22 AM
Dunno if this is of any use for you anymore, but
i''ll tell you how i did the ''AI'' in my (little)
vertical scrolling 2d-shooter, where the enemies
just keep on coming on the screen in random
patterns.
As stated before, the ''AI'' in this kind of game
is (usually) pattern-based. As my game is actually
a very simple example game for my soon-to-be game-
engine, i ended up with a simple control-point
solution.
The control-point structure:
typedef struct{
int iXPos;
int iYPos;
}CONTROL_POINTS;
The 2 variables (iXPos and iYPos) tell where on the
screen the particular control-point is. This structure
can be extended, so that the enemies would stop on
certain control-points etc. So for making
the patterns i just made a 2 dimensional array of
control-points, like this:
CONTROL_POINTS ctrlPoints[NUM_PATTERNS][NUM_POINTS];
All control-points are loaded from a file, which
contains all of their x and y values.
So now i had NUM_PATTERNS of different patterns which
all consist of NUM_POINTS control-points. The first
and the last control-point in a pattern are reserved
for starting and ending points, which must be outside
of the screen. Why? Well it would look pretty silly
if the enemies would pop on the screen from nowhere
or disappear in the middle of the screen.
So how did i use this then?
In my game every enemy has a variable which shows
which pattern it is following and another variable
which tells which control-point is the enemys next
''target''.
In every AI-cycle i would just check if the enemy has
reached a control-point, and if it has, increment the
the target-variable by one. If the target-variable
is NUM_POINTS, then the enemy must be destroyed, as
it has reached the last control-point. If the enemy
hasn''t reached the target control-point, i just moved
the enemy towards it until the enemy is on top of it.
Some pseudocode to show how i did it (the enemies
are stored in an array of Enemy[NUMBER_OF_ENEMIES] ):
for( int i = 0; i < NUMBER_OF_ENEMIES; i++ ){
//Move the enemy:
if( ctrlPoint[ Enemy.Pattern ][ Enemy.Target ].iXPos < Enemy.X )<br> Enemy.X -= Enemy.Speed;<br><br> if( ctrlPoint[ Enemy.Pattern ][ Enemy.Target ].iXPos > Enemy.X )<br> Enemy.X += Enemy.Speed;<br><br> //the exact same for y-points<br><br> if( Enemy is on top of the controlpoint ){<br> Enemy.Target++;<br> if( Enemy.Target == NUM_POINTS ) //The last controlpoint was reached<br> Enemy.Alive = FALSE; //Destroy the enemy<br> }//End if<br><br>}//End for<br><br><br>When i created an enemy, i would randomly give it a pattern,<br>then put its x and y position as ctrlPoint[Enemy.pattern][0].x<br>and CtrlPoint[Enemy.pattern][0].y and finally set the enemys<br>target control-point as 1 (0 is the starting-point).<br><br>Very basic, and extremely easy.<br><br><br>What about shooting? Well i used a random variable on <br>that. When ever a random variable hit a certain value,<br>the enemy would shoot.<br><br><br>This isn''t probably the best and the fastest way of doing<br>all this, but it works just fine as an example. Hope that <br>atleast someone understands what i''m trying to say here,<br>and that this post would be helpful.<br><br><br>–BerLan<br> </i>
i''ll tell you how i did the ''AI'' in my (little)
vertical scrolling 2d-shooter, where the enemies
just keep on coming on the screen in random
patterns.
As stated before, the ''AI'' in this kind of game
is (usually) pattern-based. As my game is actually
a very simple example game for my soon-to-be game-
engine, i ended up with a simple control-point
solution.
The control-point structure:
typedef struct{
int iXPos;
int iYPos;
}CONTROL_POINTS;
The 2 variables (iXPos and iYPos) tell where on the
screen the particular control-point is. This structure
can be extended, so that the enemies would stop on
certain control-points etc. So for making
the patterns i just made a 2 dimensional array of
control-points, like this:
CONTROL_POINTS ctrlPoints[NUM_PATTERNS][NUM_POINTS];
All control-points are loaded from a file, which
contains all of their x and y values.
So now i had NUM_PATTERNS of different patterns which
all consist of NUM_POINTS control-points. The first
and the last control-point in a pattern are reserved
for starting and ending points, which must be outside
of the screen. Why? Well it would look pretty silly
if the enemies would pop on the screen from nowhere
or disappear in the middle of the screen.
So how did i use this then?
In my game every enemy has a variable which shows
which pattern it is following and another variable
which tells which control-point is the enemys next
''target''.
In every AI-cycle i would just check if the enemy has
reached a control-point, and if it has, increment the
the target-variable by one. If the target-variable
is NUM_POINTS, then the enemy must be destroyed, as
it has reached the last control-point. If the enemy
hasn''t reached the target control-point, i just moved
the enemy towards it until the enemy is on top of it.
Some pseudocode to show how i did it (the enemies
are stored in an array of Enemy[NUMBER_OF_ENEMIES] ):
for( int i = 0; i < NUMBER_OF_ENEMIES; i++ ){
//Move the enemy:
if( ctrlPoint[ Enemy.Pattern ][ Enemy.Target ].iXPos < Enemy.X )<br> Enemy.X -= Enemy.Speed;<br><br> if( ctrlPoint[ Enemy.Pattern ][ Enemy.Target ].iXPos > Enemy.X )<br> Enemy.X += Enemy.Speed;<br><br> //the exact same for y-points<br><br> if( Enemy is on top of the controlpoint ){<br> Enemy.Target++;<br> if( Enemy.Target == NUM_POINTS ) //The last controlpoint was reached<br> Enemy.Alive = FALSE; //Destroy the enemy<br> }//End if<br><br>}//End for<br><br><br>When i created an enemy, i would randomly give it a pattern,<br>then put its x and y position as ctrlPoint[Enemy.pattern][0].x<br>and CtrlPoint[Enemy.pattern][0].y and finally set the enemys<br>target control-point as 1 (0 is the starting-point).<br><br>Very basic, and extremely easy.<br><br><br>What about shooting? Well i used a random variable on <br>that. When ever a random variable hit a certain value,<br>the enemy would shoot.<br><br><br>This isn''t probably the best and the fastest way of doing<br>all this, but it works just fine as an example. Hope that <br>atleast someone understands what i''m trying to say here,<br>and that this post would be helpful.<br><br><br>–BerLan<br> </i>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement