AI ship management/ship design simulation

For what's not in 'Top Priority Game Design'. Post your ideas, visions, suggestions for the game, rules, modifications, etc.

Moderator: Oberlus

Post Reply
Message
Author
unjashfan
Creative Contributor
Posts: 175
Joined: Fri Dec 30, 2011 8:08 am

AI ship management/ship design simulation

#1 Post by unjashfan »

While spying the AI when playing, I noticed that the AI tends to send ships to attack targets one ship at a time which, quite frankly, is retarded beyond belief. I've been thinking about possible logic implements which might improve this aspect of the AIs. Here's what I came up with, hope it helps:

I don't know how exactly the combat system works (mainly with combat speed), but from what I noticed during combat, I am assuming that shields work as extra health that regens completely between combats. So for example: Ship with 15 health/3 shields gets hit by a 6 damage attack, it will come out with 12 health/0 shields. To give the AI some method of estimating the chance of winning a battle, we may be able to use these equations:
  • Example: Mark I vs Larval Kraken
  • Total fleet structure / Enemy fleet total attack = # of rounds until fleet gets killed (all numbers round up to nearest integer).

    Mark I has 15 health and 1 shield = 16 total structure / Larval Kraken has 5 attack
    16/5 = 3.2 rounds up to 4. It will take 4 rounds from the Larval Kraken to destroy the Mark I.
  • Enemy fleet total structure / Total fleet attack = # of rounds to destroy enemy fleet (all numbers round up to nearest integer).

    Larval Kraken has 18 health and no shields / Mark I has 2 attack
    18/2 = 9. It will take 9 rounds from the Mark I to destroy the Larval Kraken.
Finally, a logical check is executed to estimate the chance of winning a battle:
If # of rounds to destroy enemy fleet is greater than the # of rounds until fleet gets killed, this means the battle will likely be lost. If it's the other way around, then the battle will likely be won. If both numbers are equal, then the odds are about 50/50 - I guess here is where the combat speed comes in (whoever shoots first will win). So if the AI finds itself in a situation where it might lose a battle, it will be able to send more ships to increase firepower and go through the algorithm again until it thinks it can win.

Designing and building ships is probably the most important (and attractive) part of this game. To help simulate AI ship design, a list of hidden designs reserved for the AI could be created (or possibly more than one to simulate different playstyles). It would be something like the predesigned ships file I guess. The difference would be that these lists aren't shared with every other player like the predesigns, and if there is more than one list, it would be impossible for the human player to figure out which set of ships the AI would use.

I think the Mark I should be removed from the predesigns because it's completely outclassed by the Mark II in terms of production time, cost, damage output, and raw stats (essentially a Mark II is a Mark I with 4 extra attack). The only reason that I can see to leave the Mark I in is to punish players who don't upgrade the mass driver at the beginning of the game. The AI should at least be able to recognize this and stop producing Mark I's once the Mark II is available.

Here's a quick rundown that shows how badly outclassed the Mark I is:

(without using mining focus nor industry focus for the following turns)
Turn 1: Learn mass driver 2 immediately. Completes in 5 turns. Stop production and grind minerals.
Turn 2-5: Scout, grind minerals, etc.
Turn 6: Mass driver 2 is unlocked. Mineral stockpile is 37.5. Produce Mark II immediately. Completes in 5 turns.
Turn 7-10: Mineral stockpile drops by 7.5 per turn until Mark II is complete.
Turn 11: Mark II is ready for service. Throw the Mark I blueprint out the window; it's useless now.

As shown, the Mark I is only useful for the first 10 turns. What are the odds of getting overwhelmed during the first 10 turns? The only use the Mark I has is to clean out monsters wandering too close, but it loses to the Larval Kraken and Small Juggernauts 100% of the time, and can barely win against a Small Snowflake (it has to be lucky).

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: AI ship management/ship design simulation

#2 Post by Geoff the Medio »

unjashfan wrote:I don't know how exactly the combat system works (mainly with combat speed)
There is no "combat speed" at present. Each combat round, every ship or planet in the battle has an equal change to have an action. If chosen, a random target for the action is chosen. If the target is valid, the actor attacks the target, and can damage or destroy it. This is repeated about 10 * number_of_objects times, and then the battle ends. This is not particularly good, and will likely be replaced, but it was fairly quick and simple to set up.
...I am assuming that shields work as extra health that regens completely between combats.
In the latest version, ship shields should only regen if the ship wasn't in a battle in the previous turn.
To give the AI some method of estimating the chance of winning a battle, we may be able to use these equations:
If it would be useful, the AI could be given a means to run battle simulations using the real battle engine. A fleet strength and battle odds estimator would probably still be useful, though.
So if the AI finds itself in a situation where it might lose a battle, it will be able to send more ships to increase firepower and go through the algorithm again until it thinks it can win.
I think the main issue is that it's presently sending one ship at a time, rather than bunching up a fleet. It doesn't need a battle simulator to be told not to do that; it just needs more AI scripting to be done. This is very much a work in progress...
I think the Mark I should be removed from the predesigns because it's completely outclassed by the Mark II ...
Perhaps instead of removing the Mark I, the cost of the Mark II's weapon, the SR_WEAPON_2 should be increased? Presently it's the same as the SR_WEAPON_1 that the Mark I uses, which makes the Mark I completely pointless once Mark II is available as noted. If you suggest appropriate costs to balance the weapons (or other parts), I'll commit it. The ship_parts.txt is fairly straightforward, with

Code: Select all

    buildcost = 5
    buildtime = 1
listed for all parts up to SR_WEAPON_4.

User avatar
eleazar
Design & Graphics Lead Emeritus
Posts: 3858
Joined: Sat Sep 23, 2006 7:09 pm
Location: USA — midwest

Re: AI ship management/ship design simulation

#3 Post by eleazar »

Feedback and analysis of current balance is very welcome since much of what's in the game has just been thrown together, or is residue from when things worked differently.

Maybe mass driver 2 is too easy to get or too large a jump in power. But some of your criticism seem to be based on the assumption that i/we had different balance goals.
unjashfan wrote:The AI should at least be able to recognize this and stop producing Mark I's once the Mark II is available.
Agreed.
unjashfan wrote:Mark II is ready for service. Throw the Mark I blueprint out the window; it's useless now.
Yeah, but why do you say that like it is a bad thing. As soon as you research Mass Driver 3 your Mark ii should be thrown away too. And so on.
Mass Driver 2 through 4 are "refinements", which mean they are superior to the previous tech in every way. All Mass Drivers have the same build cost. There's no reason to prefer the old version. Possibly we can have eventually a system that will automatically upgrade weapons to the latest refinement when in a shipyard or something.
unjashfan wrote:As shown, the Mark I is only useful for the first 10 turns.
... If you make weaponry your top priority.
unjashfan wrote:The only use the Mark I has is to clean out monsters wandering too close, but it loses to the Larval Kraken and Small Juggernauts 100% of the time, and can barely win against a Small Snowflake (it has to be lucky).
That feels right to me, it is what i'm aiming for. The regular monsters are a real challenge at the beginning. You survive by running away, outnumbering them, or raising your tech. Especially since the AI Empires aren't very challenging, the monsters for now at least pick up that slack.


Last night (revision 4614) i tried to add some new premade designs to better reflect what people would be able to build, but for unknown reasons only some of them are showing up.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: AI ship management/ship design simulation

#4 Post by Geoff the Medio »

eleazar wrote:Mass Driver 2 through 4 are "refinements", which mean they are superior to the previous tech in every way. All Mass Drivers have the same build cost. There's no reason to prefer the old version. Possibly we can have eventually a system that will automatically upgrade weapons to the latest refinement when in a shipyard or something.
We (should) already have that sort of system using effects; instead of making a new part for a refinement, the refinement tech could / should add an additional effect that increases the damage of the part. I don't have an example of how to write such an effect, but I think it should be doable with the current parser.
Last night (revision 4614) i tried to add some new premade designs to better reflect what people would be able to build, but for unknown reasons only some of them are showing up.
I'll have to look into that...

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: AI ship management/ship design simulation

#5 Post by Geoff the Medio »

Geoff the Medio wrote:
Last night (revision 4614) i tried to add some new premade designs ... but ...only some of them are showing up.
I'll have to look into that...
You need to add those designs' names to starting_ship_designs.txt as well. premade_ship_designs.txt can include designs that player empires aren't given at the start of the game, like the Dragon Tooth. Only those in starting_ship_designs.txt show up in the design and production screens.

User avatar
eleazar
Design & Graphics Lead Emeritus
Posts: 3858
Joined: Sat Sep 23, 2006 7:09 pm
Location: USA — midwest

Re: AI ship management/ship design simulation

#6 Post by eleazar »

Thanks, forgot about that.

Do they have to be in "starting_ship_designs.txt" for the AI to use them? These new plans were largely intended to allow the AIs to use better weapons.

unjashfan
Creative Contributor
Posts: 175
Joined: Fri Dec 30, 2011 8:08 am

Re: AI ship management/ship design simulation

#7 Post by unjashfan »

OK this is irrelevant but I just typed a lot of stuff, but the forum auto logged me out and I'm not into doing all that again. Anything I can do to prevent that from happening?
Yeah, but why do you say that like it is a bad thing. As soon as you research Mass Driver 3 your Mark ii should be thrown away too. And so on.
Mass Driver 2 through 4 are "refinements", which mean they are superior to the previous tech in every way. All Mass Drivers have the same build cost. There's no reason to prefer the old version. Possibly we can have eventually a system that will automatically upgrade weapons to the latest refinement when in a shipyard or something
Sorry, it wasn't meant to be a bad thing (forgot to add a :wink: ). For mass drivers yes, the refinements are definitely superior, but with lasers and plasma cannons, it's not quite the case because the production time increases somewhere in the middle of refinement (laser 2 costs 2 turns and laser 3 costs 3). This can affect the effectiveness of ship hulls with low production cost (say robotic hulls). Extra production time can mean the difference of saving or losing control of a system/planet. I don't know if this was intentional but I think it's a great idea.
Perhaps instead of removing the Mark I, the cost of the Mark II's weapon, the SR_WEAPON_2 should be increased? Presently it's the same as the SR_WEAPON_1 that the Mark I uses, which makes the Mark I completely pointless once Mark II is available as noted. If you suggest appropriate costs to balance the weapons (or other parts), I'll commit it.
I'll play around with the numbers.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: AI ship management/ship design simulation

#8 Post by Geoff the Medio »

eleazar wrote:Do they have to be in "starting_ship_designs.txt" for the AI to use them? These new plans were largely intended to allow the AIs to use better weapons.
Yes, unless the AI learns to design its own ships, in which case no.
unjashfan wrote:...the forum auto logged me out and I'm not into doing all that again. Anything I can do to prevent that from happening?
Tick automatically log me in on every visit when logging in? I've not had that problem. I'd expect that if I did, you could hit back to get back to your typed-in text, though.

User avatar
eleazar
Design & Graphics Lead Emeritus
Posts: 3858
Joined: Sat Sep 23, 2006 7:09 pm
Location: USA — midwest

Re: AI ship management/ship design simulation

#9 Post by eleazar »

unjashfan wrote:..For mass drivers yes, the refinements are definitely superior, but with lasers and plasma cannons, it's not quite the case because the production time increases somewhere in the middle of refinement (laser 2 costs 2 turns and laser 3 costs 3).
Good observation. That was a mistake.
fixed in revision 4618

unjashfan
Creative Contributor
Posts: 175
Joined: Fri Dec 30, 2011 8:08 am

Re: AI ship management/ship design simulation

#10 Post by unjashfan »

Here's a weapon tech chart that looks more balanced for the current version. Damage ratio %'s are there for comparison purposes, and may help with refining the system further later on. I don't think this will be the final version (see below), but the damage output has been changed to soften the extreme power creep at the beginning.
Damage Chart.zip
(9.05 KiB) Downloaded 44 times
Changes were made with the ship hulls and their respective tech tree locations in mind. There seems to be an extreme imbalance between the number of weapon techs and shielding/armour/bulkier hull techs (perhaps the quality as well). While the weapons will continue to deal more damage, shielding techs stop at deflector shield, lead armour plating is essentially a defense grid, rock and zortrium armour plating take too long to unlock and they provide barely enough additional defense. Ships-wise, aside from the standard hull, the following hulls that are plausible to obtain early (~55-65 turns)- organic, static multicellular, robotic, endomorphic - have a max structure of 15 or less; according to their descriptions, that is "a bit low" or "below average". To help mitigate this and provide more modularity for ships, additional shield techs could be implemented, perhaps with additional special effects such as returning a fraction of the damage taken back to the attacker. Armour techs are in a similar scenario.

I think armour plating strength can be increased significantly because since they need an external slot, they compete with weapon parts for slots. More armour means less firepower and vice versa. This can help balance out the weapon system more.
There is no "combat speed" at present. Each combat round, every ship or planet in the battle has an equal change to have an action...
I think a stable combat system should be implemented as soon as possible, because smaller hulls with low structure and high combat speed theoretically depend on that speed to survive. The current randomness of the system means that a Mark I could (though highly unlikely) rambo a group of trans-spatial hulls (that would be hilarious).

User avatar
eleazar
Design & Graphics Lead Emeritus
Posts: 3858
Joined: Sat Sep 23, 2006 7:09 pm
Location: USA — midwest

Re: AI ship management/ship design simulation

#11 Post by eleazar »

unjashfan wrote:Here's a weapon tech chart that looks more balanced for the current version. Damage ratio %'s are there for comparison purposes, and may help with refining the system further later on. I don't think this will be the final version (see below), but the damage output has been changed to soften the extreme power creep at the beginning.
Damage Chart.zip
Since you are doing this in excel, you should graph your numbers. I was trying to go for a smooth curve in power increase, with a small bias towards memorable whole numbers (i.e. 30 instead of 32). Your progression gets pretty choppy in the middle.

Still your point about the beginning was valid. For now i've made mass-driver strength progress: 1, 2, 4, 7 (and upped the 3rd plasma to 46) Revision 4624
unjashfan wrote:Changes were made with the ship hulls and their respective tech tree locations in mind.
That will probably change somewhat after 0.4. When the existing hulls were added, the emphasis (i think) was on varied concepts and stretching the effects scripting to the limits. I find the progression confusing, and the stats probably aren't balanced.

unjashfan wrote:There seems to be an extreme imbalance between the number of weapon techs and shielding/armour/bulkier hull techs (perhaps the quality as well). While the weapons will continue to deal more damage, shielding techs stop at deflector shield, lead armour plating is essentially a defense grid, rock and zortrium armour plating take too long to unlock and they provide barely enough additional defense. Ships-wise, aside from the standard hull, the following hulls that are plausible to obtain early (~55-65 turns)- organic, static multicellular, robotic, endomorphic - have a max structure of 15 or less; according to their descriptions, that is "a bit low" or "below average". To help mitigate this and provide more modularity for ships, additional shield techs could be implemented, perhaps with additional special effects such as returning a fraction of the damage taken back to the attacker. Armour techs are in a similar scenario.
Such special effects IIRC aren't currently possible
unjashfan wrote:I think armour plating strength can be increased significantly because since they need an external slot, they compete with weapon parts for slots. More armour means less firepower and vice versa. This can help balance out the weapon system more.
Good point. Looking at the numbers most of the armor plating doesn't seem worth it.

Shields and armor should be enhanced to be useful and/or weapon power should be decreased overall. There's no particular reason the ultimate weapon needs to have a damage power of 100.

unjashfan
Creative Contributor
Posts: 175
Joined: Fri Dec 30, 2011 8:08 am

Re: AI ship management/ship design simulation

#12 Post by unjashfan »

Since you are doing this in excel, you should graph your numbers. I was trying to go for a smooth curve in power increase, with a small bias towards memorable whole numbers (i.e. 30 instead of 32). Your progression gets pretty choppy in the middle
If I ever make another chart like this, I'll add in graph curves. I didn't really put too much focus to the higher level weapons because 1) I was using the %'s for comparison. 2) As of the current versions, the plasma cannon and death ray damage levels are so high it doesn't make a huge difference.

More memorable numbers are convenient to work with and there's no problem with that, but keep in mind that since hulls can be freely designed, every increase in weapon damage is potentially multiplied by the number of external slots for any given hull - this effect can be abused with smaller hulls with 2 or 3 external slots that are easy to mass produce, resulting in an insane jump in firepower, which can potentially knock the damage levels out of balance. Of course, this is just a speculation; we'll have to find out by further testing.
When the existing hulls were added, the emphasis (i think) was on varied concepts and stretching the effects scripting to the limits. I find the progression confusing, and the stats probably aren't balanced.
If the stats of ship hulls get changed, you might want to do something about the protoplasmic hull because it's currently outclassed by the endomorphic hull (this hull is actually pretty broken. I love abusing its versatility :) ) in every visible aspect except production cost (by 10 PP I think and even that is offset by its extra production time). It's also further down the tech tree which takes it out of the game completely.
Such special effects IIRC aren't currently possible
OK.
There's no particular reason the ultimate weapon needs to have a damage power of 100.
I'd say a damage level of 70-80% of the highest initial hull structure (currently 100) is a fair amount, since the advanced hulls have many external slots and the armour plating system will be improved.

Post Reply