Advertisement

Ideas for AI for my game

Started by March 26, 2005 01:40 AM
4 comments, last by WeirdoFu 19 years, 8 months ago
I want to try an interesting game... don't factor in the number of games that might have to be played to get it working well... , I'm making a game where you command a fleet of ships. Its an RTS, but you start with a fleet and are assigned to destroy the enemy fleet, and you don't build ships. You just command the overall battle, and the AI of the pilots of each ship, and the AI of your tacticle officers handle the overall scope of battle. I thought, (if you read my earlier post) about ways to to genetic algorithms in ships/troops. So I came up with statistics of individual ships that would pertain to different actions a pilot might take. Each pilot uses a different AI. So I said that each has certain hardcoded 'states', such as attack run, retreat, call for aid, etc. They also have a target selection state. What state is active depends on factors of their ship and the battle around them. For example, when selecting a target, they check the following: percentage of their health remaining vs. potential targets' size of their max health vs. size of enemy's max health their firepower vs. potential enemy's firepower how close help is their speed vs. enemy speed It also has minimum or maximum values for each modifier for each state. As long as none of the values fall below the minimum (in which case it will not take that action), it will average them and if that beats a minimum total advantage over the enemy, it will attack that enemy. This is for each individual ship. You don't control individual ships; just where to attack, some formations, etc. I also plan on letting another AI system control these last to an extent, if you choose (I want to have the player be able to micromanage as much or as little as they desire, except for with individual ships). Anyways, when the battle is won by one side, it takes the top 1/4 scoring ship's AIs and turns those into the next generation. its score is dependent on things like #enemy ships killed, amount of health remaining, etc. Then, when the next battle's ships are created, they load and modify the AI values from the last battle. Tell me what you think... these are just my thoughs right now. I guess what Im looking for is ideas on how well this will work and how much better/worse in terms of adding to gameplay or making gameplay more unique this would be. Also, please let me know if i just proposed the impossible (although I'll probably still go about it anyways, till I get totally stymied). Thanks for reading the long post!
my siteGenius is 1% inspiration and 99% perspiration
A very interesting idea!

Perhaps you could use them all. Just rank them all depending on the function of the factors that you choose. (for eg. You could have the greatest bot, on the loosing side).

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
Advertisement
Quote: Original post by silverphyre673
Also, please let me know if i just proposed the impossible (although I'll probably still go about it anyways, till I get totally stymied).


Nope, it's just a Genetic Algorithm. It should be very do-able!

Quote: I'm making a game where you command a fleet of ships. Its an RTS, but you start with a fleet and are assigned to destroy the enemy fleet, and you don't build ships. You just command the overall battle, and the AI of the pilots of each ship, and the AI of your tacticle officers handle the overall scope of battle.

I thought, (if you read my earlier post) about ways to to genetic algorithms in ships/troops. So I came up with statistics of individual ships that would pertain to different actions a pilot might take. Each pilot uses a different AI. So I said that each has certain hardcoded 'states', such as attack run, retreat, call for aid, etc. They also have a target selection state. What state is active depends on factors of their ship and the battle around them.


It sounds as if you are making a Real-Time Tactical game. RTT just means that there is no resource managment, just the combat aspect. An example of this would be this game. What you are saying seems very logical and plausible.

Quote: For example, when selecting a target, they check the following:
percentage of their health remaining vs. potential targets'
size of their max health vs. size of enemy's max health
their firepower vs. potential enemy's firepower
how close help is
their speed vs. enemy speed


Sounds good, but also considering having this customizable with different selectable 'modes'. What I am talking about is like the AI of each unit is also changeable. Now you might ask why would you want to do this? Well think about this scenario:

You have 3 Light Ships vs 1 Heavy Ship. There are other units around them on each side, but I am focusing on this specifically. The Heavy ship can destroy each ship in one shot, but not before each ship can get off one shot. Now the damage would not be as so much as bringing down the H. Ship to less tha 75% health. In your combat system, these light ships might try for other targets first. However, if that H. Ship is the last 'big ship' the enemt has, and those 3 light ships can take it's health down to 75%, then the sacrifice for engaging it is worth it - assuming you have your H. Ship and others to now combat it, to which you will win.

So basically each unit can be given orders, such as, taken from some RTS games: Do or Die! (Fight to the death), Suicide (scouting enemy unit locations), then whatever else, you get the point. Since you said you don't want to micromanage individual ships, perhaps you could make 'squads' and use that concept with.

Quote: Anyways, when the battle is won by one side, it takes the top 1/4 scoring ship's AIs and turns those into the next generation. its score is dependent on things like #enemy ships killed, amount of health remaining, etc.

Then, when the next battle's ships are created, they load and modify the AI values from the last battle.


What exactly are you trying to accompish with this though? I mean nothing will be the same, so what would be the use for this? I mean if you had one sqaud composed of X units and they faced ships that were 'easy', this will do no good for the next battle to which different ships ai would be used.

With that said how about something like this, something that I've been htinking about.

Before a battle starts, you choose your ships. However, you have only a certain allocated number that you can use. This system would be weighted along 'value'. For example:
H. Ship = 5 unitsM. Ship = 3 unitsL. Ship = 1 unit

However, the key thing is that there will be different type of ships. Think about the Paper-Rock-Scissors concept, something like that. So the strategy would be choosing the best combination of ships rather than trying to get the most powerful - an example:

If you had 5 Fast Firing Light Ships vs 5 Slow Firing Mortar Ships, who do you think would win? In this case the speed of the L. Ships would allow them to avoid most of the fire from the Mortar Ships.

Just a few opinions. I think your idea is really good and I would love to see it implemented! Something like that would be very neat. What I always loved was the concept of WarZone 2100. You could 'build' your own units by customizing the model plans from gained research. Of course if you made more powerful units, they took longer to produce as well as cost.

Anyways I will do some more thinking on this. Feel free to ask if you need any clarifications on what I've said.

- Drew
you could also generate several AI "players", have them play against each other a million times, and then pick out some interesting ones to keep. the player can pick which to face, or it can be random.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
hey, thats encouraging! i was thinking along the same lines as you guys.

Quote:
Sounds good, but also considering having this customizable with different selectable 'modes'. What I am talking about is like the AI of each unit is also changeable. Now you might ask why would you want to do this? Well think about this scenario:

You have 3 Light Ships vs 1 Heavy Ship. There are other units around them on each side, but I am focusing on this specifically. The Heavy ship can destroy each ship in one shot, but not before each ship can get off one shot. Now the damage would not be as so much as bringing down the H. Ship to less tha 75% health. In your combat system, these light ships might try for other targets first. However, if that H. Ship is the last 'big ship' the enemt has, and those 3 light ships can take it's health down to 75%, then the sacrifice for engaging it is worth it - assuming you have your H. Ship and others to now combat it, to which you will win.

So basically each unit can be given orders, such as, taken from some RTS games: Do or Die! (Fight to the death), Suicide (scouting enemy unit locations), then whatever else, you get the point. Since you said you don't want to micromanage individual ships, perhaps you could make 'squads' and use that concept with.


I think thats a really good idea. I haven't implemented ANYTHING about the ships yet, I'm just working out how they are going to move. I think what I'm going to do is: each area where ships are will have a sort of "known enemy field" and any enemy ships in this area will be included into the calculations for what actions should be taken by your ships. I guess the ships would determine what to do based on that... like, if a "swarm" is ALL the ships on your team in the area, and a "group" is like a bunch of ships acting together against one foe (I think that the ships should group up on their own), then maybe calculations on what to do should be made based on the total firepower of the swarm vs. the total firepower ofthe enemy swarm. And maybe their health, also.

I think that ships should kind of have a "sensor" object, which would have some sort of reference to each other ship the ship doing the "sensing" :) can detect.
Then, based on those ship's stats, it would choose its target. I think if it was attacking, it would lock the target, until it left that state. However, if it wasn't attacking, every "update" phase, which would be like every few milliseconds or something, it would loop through the targets and see if there is a new best target. And if it couldn't find a target weak enough to attack, and if the battle was going well enough, instead of just running, it would either call for assistance or find another group, or just patrol around the battle shooting at things that it was close to. Then, once it found a target to attack, it would do attack runs on it.

Oh, and

Quote:
What exactly are you trying to accompish with this though? I mean nothing will be the same, so what would be the use for this? I mean if you had one sqaud composed of X units and they faced ships that were 'easy', this will do no good for the next battle to which different ships ai would be used.

With that said how about something like this, something that I've been htinking about.


I mean that this is the way that the "genes" of the pilots and tactical officers would be modified. The weights for each action wouldn't be completely randomized, just modified +- a little bit. Eventually, they would converge on something really good.

Thanks!
my siteGenius is 1% inspiration and 99% perspiration
You might want to throw in other consideration factors as well. For example, starting formation of the ships, like having faster scouts up front or heavier armor ships up front for better defense against surprise attacks, etc. A different formation may sometimes determine whether a a ship will survive or not.

Also, since you already have various states, then you might as well, as mentioned earlier, just go ahead and evolve behaviors as well. I've worked on a similar idea and just basically set up possible reactions to situations that may occur. Like, what to do when an enemy is sighted, what to do when being fired upon, but not sure by whom, etc. Then, within the ship motion, you can drop in some swarming as well, where the captains can decide whether to go to the aid of another ship or leave it and move on.

This topic is closed to new replies.

Advertisement