• Advertisement


This topic is now archived and is closed to further replies.

AI for Galaxian Game

This topic is 6556 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
I don''t know the answer. All I can tell you is that Galaxian always kicked my butt. Man, I sucked at that game.

Share this post

Link to post
Share on other sites
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

Share this post

Link to post
Share on other sites
in the games like galaxian, and galaga, all of the AI was pattern based.

Share this post

Link to post
Share on other sites
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

Share this post

Link to post
Share on other sites
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

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.


Share this post

Link to post
Share on other sites
Guest Anonymous Poster
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

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

The control-point structure:

typedef struct{
int iXPos;
int iYPos;

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:


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

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[i].Target ].iXPos < Enemy[i].X )
Enemy[i].X -= Enemy[i].Speed;

if( ctrlPoint[ Enemy[i].Pattern ][ Enemy[i].Target ].iXPos > Enemy[i].X )
Enemy[i].X += Enemy[i].Speed;

//the exact same for y-points

if( Enemy is on top of the controlpoint ){
if( Enemy[i].Target == NUM_POINTS ) //The last controlpoint was reached
Enemy[i].Alive = FALSE; //Destroy the enemy
}//End if

}//End for

When i created an enemy, i would randomly give it a pattern,
then put its x and y position as ctrlPoint[Enemy.pattern][0].x
and CtrlPoint[Enemy.pattern][0].y and finally set the enemys
target control-point as 1 (0 is the starting-point).

Very basic, and extremely easy.

What about shooting? Well i used a random variable on
that. When ever a random variable hit a certain value,
the enemy would shoot.

This isn''t probably the best and the fastest way of doing
all this, but it works just fine as an example. Hope that
atleast someone understands what i''m trying to say here,
and that this post would be helpful.


Share this post

Link to post
Share on other sites

  • Advertisement