   Space Game AI
  Ok, I just got done building a small, but killer sprite engine. I am testing it out on a game called SGTBM.(stands for Space Game That Bryce Made.) I have made a ship that is an enemy and will fly around in random directions. Now, I''d like to make it a bit more smart. For example, It is not going to die right away, so when it is at full hit points, it will be a little more aggressive. If it is low on hit points, it will be a little more defensive. How I go about changing states is like this: It choses a random number between 1 and the 10. if it is 10, it will change states. It will then chose a number between 1 and 8. These are the different directions it can go. If I were to add another state called Attack or whatever, It would go straight down, w/o moving left or right or anything. I don''t want this to look boring like that. Does anyone have a good way to design this AI?  
  Agressive:Check where the player is. Check your own orientation. Turn to face the enemy. Shoot.Defensive:Check where the behind of the player is. Check your own position. Make sure you stay behind the player.Coward: Try to get as far away from the enemy as possible.  ;  Suppose you have an enemy_move function.  It will likely consist of a large switch statement, with different actions to take depending on what the current state is. Every state (unless is is a final state, like exploding) should have a way to transition to another state.  This can be deterministic or random, depending on what you think is appropriate.example:switch (state){  case: AGGRESSIVE    agressive_attack();    if (shields <= 0)  state = DEFENSIVE;    if (hull <= 0)  state = explode;  break;  case: DEFENSIVE    .....  case: EXPLODE    .....}You will probably want something much more complicated than this, such as keeping track of the time spent in the current state, so you can switch based on time (like when an explosion ends), or do a proability check (say every second) to see if you should change attack patterns, or to perform special attacks, like firing missles every 5 seconds, etc.  ;quote:Original post by Muzlack  Ok, I just got done building a small, but killer sprite engine.    I am new to games and graphics.What is a sprite and what is a sprite engine?thanks for a reply!  ;  a sprite is just a 2d actor on the screenit acts on the backgroundalways a 2d picture with transparent parts  