Author Topic: Request to Keith - CPA Strategic Reserve Spawns  (Read 6505 times)

Offline Kahuna

  • Core Member
  • *****
  • Posts: 2,222
  • Kahuna Matata!
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #15 on: November 28, 2012, 02:05:20 pm »
Yeah, but that's Laser Gatlings.  It's not like they'd be a threat :) .
I used to think Autocannons are a LoL.. then the AI literally sent more than 8000 Autocannons.
set /A diff=10
if %diff%==max (
   set /A me=:)
) else (
   set /A me=SadPanda
)
echo Check out my AI War strategy guide and find your inner Super Cat!
echo 2592 hours of AI War and counting!
echo Kahuna matata!

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #16 on: November 28, 2012, 02:36:26 pm »
You could do "Estimate 300-800" using the AI's lowest and highest ship cap multipliers to calculate.  That should avoid bug reports.
Hmm, yea, that might work.
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,570
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #17 on: November 28, 2012, 04:14:39 pm »
You could do "Estimate 300-800" using the AI's lowest and highest ship cap multipliers to calculate.  That should avoid bug reports.
Hmm, yea, that might work.

Only problem with that is that this is a rather terrible precision estimate. Let's assume that most of the time, the true value will be right down the middle (550).
This would give about a 45% margin of error. :o

Now of course, the estimate would only be crazy off if the AI got both a low cap ship and a high cap ships, which would throw off the upper and lower bounds of this estimate by a rather large margin. (If a good heuristic was used considering the count of each ship type in addition to the cap of that type, then a reasonably accurate "expected value" could be computed, but that doesn't help the upper and lower bounds)

This is not just theoretical. In my game, one of the AIs has both Z elec bombers AND infiltrators.

Offline KDR_11k

  • Hero Member Mark II
  • *****
  • Posts: 904
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #18 on: November 28, 2012, 04:37:24 pm »
I think that would just get silly with the cap 5 units. Maybe just stick a modifier on there that slightly increases or decreases CPA sizes if the AI has many high/low cap units, that should heuristically come out to be roughly the same.

Offline Winge

  • Hero Member
  • *****
  • Posts: 601
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #19 on: November 28, 2012, 06:04:43 pm »
Maybe I'm missing something, but is there any reason that it cannot be a firepower number instead?
My other bonus ship is a TARDIS.

Offline Hearteater

  • Core Member
  • *****
  • Posts: 2,334
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #20 on: November 28, 2012, 07:09:37 pm »
Because firepower is evil, misleading, and unclear.

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,570
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #21 on: November 29, 2012, 12:45:14 am »
Because firepower is evil, misleading, and unclear.

I take issue with the evil and misleading part, but I agree it is unclear. That alone is enough to make me not support announcing the size (possibly estimated) of CPA in terms of firepower.

Offline Wanderer

  • Master Member Mark II
  • *****
  • Posts: 1,579
  • If you're not drunk you're doing it wrong.
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #22 on: November 29, 2012, 01:36:10 am »
Alrighty, finally got home today.

So, I just want to reiterate what you said earlier Keith and make sure I've got it square.  Thanks for the detailed post.

CPAs (Cross Planet Attacks) are timer based assaults launched by the AIs.  Their strength is determined by either AIP or by time since start of game, whichever gives the CPA the greatest strength.  Note: Core CPA Guardposts are determined solely by AIP.  (Formula: 100 * Difficulty * AIP/50 (or 1, if 1 is greater) * (0.67 + (0.33 * # of Human Homeworlds)) )  Once released, they act similarly to Cross Planet Waves, in that they are simply released threat.

CPA strength determines the number of ships to be released as threat.  This number is not cap modified, so if your AIs are running Laser Gatlings expect an easier time of it than if they're running Blade Spawners.  This is highly unlikely to change barring some drastic events being documented.

The CPA will attempt to fill out the # of ships according to a series of rules:

The first rule is tech limitations for the wave.
At under Difficulty 7 the tech limit is maxxed at 2.
At 7 -> 7.8 the max tech limit is either 2, or the AIP tech level if it is larger.
At 8+, the max tech limit is 5.  AIP doesn't matter.

Within these limits, it will now try to pull half the CPA population from the Strategic Reserve, as long as it doesn't drop the strategic reserve below 50%.

After getting these troops from the strategic reserve, it will then attempt to pull the rest of the CPA population from existing planets.  The following process will be cycled through from Current AIP Tech level (or AI tech level, should they have an enforced level, such as a technologist) down through to 1, and then from +1 current level through to 5 if you're at 8+.  Planets will only be considered if the humans are not in force on the planet (less than 1/3 the AI's military ships).

Examples:
Diff 6 and lower:   If AIP is at tech level 3, it is maxxed at 2.  So it will perform the planet search cycle for Tech II ships, then Tech I ships, then stop.

Diff 7 -> 7.8: If AIP is at tech level 3, it is maxxed at 3.  So it will perform the planet search cycle for Tech III ships, then Tech II ships, then Tech I ships, then stop.

Diff 8+: If AIP is at tech level 3, it is uncapped.  So it will perform the planet search cycle for Tech III ships, then Tech II ships, then Tech I ships, then Tech IV ships, then Tech V ships.  Then stop.

Planet Search Cycle
Loop over all planets (until CPA is full or out of available units, see below).  In all cases it is assumed that the AI is only releasing ships for the current tech level of the loop.  Guardians, Starships, and Carriers are not considered available, nor are ships under permanent forcefields (Spire Shield Guardpost, Forcefield III, etc.)

- Free Barracks troops.
- Free Military ships that are either: Guarding something (Guardpost, Command Center, etc), Special Forces, or are using PlanetaryRoamer behavior (not used much).
- Repeat on next planet.

Should the CPA not fill out yet it will then pull the remaining units it needs (at the AI's tech level) from the strategic reserve to attempt to fill out the CPA.  Should the Strategic Reserve 'bottom out' at 0%, then the CPA attacks shorthanded.

Strategic Reserve Ship Placement:
The 'warped in' strategic reserve ships do not require a warp gate to arrive on location, nor even a command center if you neutered a planet and left the barracks behind.  For each planet/location that ships were released from, their percentage of the non-reserve ships (example below) that were released gets a corresponding percentage of the reserve ships.

For example, the AI has pulled it's 50% of ships from the reserve, and then found 5 planets with ships it can release to fill the CPA.  Doing so, these planets each contribute 100% of the non-reserve ships, but only 50% of the full CPA when including the reserve.  If we assume these planets contribute the following percentages of the non-reserve ships: 15%, 20%, 10%, 25%, 30%, then the reserve will insta-warp a corresponding portion of its ships to those planets in equal values.  Any rounding errors or 'leftovers' from the reserve are simply dumped on the last planet.

After 30 minutes of acting like simple threat, these ships will join up with the threatfleet.
... and then we'll have cake.

Offline Histidine

  • Hero Member
  • *****
  • Posts: 581
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #23 on: November 29, 2012, 04:50:26 am »
Because firepower is evil, misleading, and unclear.

I take issue with the evil and misleading part, but I agree it is unclear. That alone is enough to make me not support announcing the size (possibly estimated) of CPA in terms of firepower.
I wonder if energy usage or M+C cost could work for estimating unit strength. The former is already used by IREs, so it's something.

Offline Bognor

  • Hero Member
  • *****
  • Posts: 570
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #24 on: November 29, 2012, 10:42:36 am »
Did I miss anything? :)

Well, since we're being thorough:

Quote from: 5.035 patch notes
CPAs now don't get queued up if the result based on difficulty, AIP, etc would be way too small (under 200 ships, for high caps, adjusted appropriately) (once a CPA is announced, however, it will happen).
Your computer can help defeat malaria!
Please visit the World Community Grid to find out how.

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #25 on: November 29, 2012, 11:20:30 am »
So, I just want to reiterate what you said earlier Keith and make sure I've got it square.
We're getting closer :)

Quote
CPAs (Cross Planet Attacks) are timer based assaults launched by the AIs.  Their strength is determined by either AIP or by time since start of game, whichever gives the CPA the greatest strength.  Note: Core CPA Guardposts are determined solely by AIP.  (Formula: 100 * Difficulty * AIP/50 (or 1, if 1 is greater) * (0.67 + (0.33 * # of Human Homeworlds)) )  Once released, they act similarly to Cross Planet Waves, in that they are simply released threat.
If you're going to include the Core CPA formula may as well include the normal one (that's why I pointed to the logs, though obviously getting a natural CPA to be announced for observation purposes is nontrivial unless you have a handy save), so here's an example log entry from a fairly vanilla diff 7 game:

Code: [Select]
effectiveAIPForCPAPurposes = this.AIProgressionLevelEffective = 99
since diff > 7, numberOfSecondsPerPointOfMinimumAIPForCPAPurposes = 360 + ( (FInt)60 * ( (FInt)7 - this.AIDifficulty ) ).IntValue = 342
minimumAIPForCPAPurposes = Game.Instance.GameSecond / numberOfSecondsPerPointOfMinimumAIPForCPAPurposes = 43
effectiveAIPForCPAPurposes = Max(effectiveAIPForCPAPurposes,minimumAIPForCPAPurposes) = 99
difficultyFactor = ( this.AIDifficulty * this.GetHandicapMultiplier() ) / ( 13 - this.AIDifficulty ) : 1.28
simulateMaxTimeWaveFactor = Mat.One + ( ( this.AIDifficulty * 2 ) / ( ( 14 - this.AIDifficulty ) * 3 ) ) : 1.73
simulateDoubleWaveFactor = 2
simulateDifficultySpecificWaveSizeMultiplier = 2.5
humanHomeworldCountMultiplier = Mat.One + ( (FInt)( humanHomeworldCount - 1 ) * FInt.FromParts( 0, 330 ) ) + ( championCount * FInt.FromParts( 0, 066 ) ) = 1
numberOfShips (before applying cap-scale) = ( (FInt)effectiveAIPForCPAPurposes * difficultyFactor * simulateMaxTimeWaveFactor * simulateDoubleWaveFactor * simulateDifficultySpecificWaveSizeMultiplier * humanHomeworldCountMultiplier ).IntValue = 1094

And to break it down:

Code: [Select]
effectiveAIPForCPAPurposes = this.AIProgressionLevelEffective = 99This is just the AIP.

Code: [Select]
since diff > 7, numberOfSecondsPerPointOfMinimumAIPForCPAPurposes = 360 + ( (FInt)60 * ( (FInt)7 - this.AIDifficulty ) ).IntValue = 342This is what determines the scale of the "alternative minimum AIP".  At diff 7 it's just 360, and below diff 7 it's "360 + ( (FInt)51 * ( (FInt)7 - this.AIDifficulty ) ).IntValue;"

Code: [Select]
minimumAIPForCPAPurposes = Game.Instance.GameSecond / numberOfSecondsPerPointOfMinimumAIPForCPAPurposes = 43Here it's just computing the actual "alternative minimum AIP"

Code: [Select]
effectiveAIPForCPAPurposes = Max(effectiveAIPForCPAPurposes,minimumAIPForCPAPurposes) = 99And here it picks either AIP or the time-based minimum.  Here the real AIP is (substantially) higher, so the time-based minimum has no effect at all.

Code: [Select]
difficultyFactor = ( this.AIDifficulty * this.GetHandicapMultiplier() ) / ( 13 - this.AIDifficulty ) : 1.28This is the diff/handicap multiplier adapted from wave-calc logic.

The "difficultyFactor" variable name is a bit imprecise, in that difficulty is factored in many times throughout this whole tour-de-pain.  Its overall impact is quite explodential.

Code: [Select]
simulateMaxTimeWaveFactor = Mat.One + ( ( this.AIDifficulty * 2 ) / ( ( 14 - this.AIDifficulty ) * 3 ) ) : 1.73This is simulating the max size increase a wave can get from simply having been a long time since the last wave.  Iirc waves can have a higher multiplier than this now due to the ingress-point calculation thing (which does not apply here) but that's where this is originally from.

Code: [Select]
simulateDoubleWaveFactor = 2This just simulates what it's like when both AIs wave you simultaneously.

Code: [Select]
simulateDifficultySpecificWaveSizeMultiplier = 2.5This is also used by waves and is just a lookup really:
if diff <= 3, then 1
else if diff <= 4, then 1.5
else if diff <= 5, then 1.75
else if diff <= 6, then 2
else if diff <= 7, then 2.25
else if diff <= 9, then 2.5
else if diff <= 9.3, then 2.75
else if diff <= 9.6, then 3
else if diff <= 9.8, then 3.8
else (that is, diff 10), then 4.5

Code: [Select]
humanHomeworldCountMultiplier = Mat.One + ( (FInt)( humanHomeworldCount - 1 ) * FInt.FromParts( 0, 330 ) ) + ( championCount * FInt.FromParts( 0, 066 ) ) = 1Just accounting for champs and multiple HWs.

Code: [Select]
numberOfShips (before applying cap-scale) = ( (FInt)effectiveAIPForCPAPurposes * difficultyFactor * simulateMaxTimeWaveFactor * simulateDoubleWaveFactor * simulateDifficultySpecificWaveSizeMultiplier * humanHomeworldCountMultiplier ).IntValue = 1094Putting it all together.  As Bognor pointed out, if the result would be less than 200 here it just doesn't bother and skips the CPA. 

The next and final step in computing the actual number of ship is: on normal caps divide this by 2; on low it divides by 4, and on ultra low it divides by 8.

Quote
The first rule is tech limitations for the wave.
At under Difficulty 7 the tech limit is maxxed at 2.
At 7 -> 7.8 the max tech limit is either 2, or the AIP tech level if it is larger.
At 8+, the max tech limit is 5.  AIP doesn't matter.
The numbers are right, but this is not a maximum tech level; it is the tech level at which it starts looking, nothing more.  Long ago it was a max, but CPAs kept coming up short, etc, and they're just more fun when they can dump a load of mkIV on you if things are strange ;)

Quote
The following process will be cycled through from Current AIP Tech level (or AI tech level, should they have an enforced level, such as a technologist) down through to 1, and then from +1 current level through to 5 if you're at 8+.  Planets will only be considered if the humans are not in force on the planet (less than 1/3 the AI's military ships).
Just remove the "if you're at 8+" and that's correct.  I'm not sure what's meant by the "(or AI tech level, should they have an enforced level, such as a technologist)" bit, though.

Quote
Examples:
Diff 6 and lower:   If AIP is at tech level 3, it is maxxed at 2.  So it will perform the planet search cycle for Tech II ships, then Tech I ships, then stop.

Diff 7 -> 7.8: If AIP is at tech level 3, it is maxxed at 3.  So it will perform the planet search cycle for Tech III ships, then Tech II ships, then Tech I ships, then stop.

Diff 8+: If AIP is at tech level 3, it is uncapped.  So it will perform the planet search cycle for Tech III ships, then Tech II ships, then Tech I ships, then Tech IV ships, then Tech V ships.  Then stop.
The last example is correct, for the first two: instead of stopping they would go back to (target tech level + 1) and count up to 5, then stop.


One thing I'm not sure I mentioned: homeworlds are skipped in the planet loop

Quote
Guardians, Starships, and Carriers are not considered available, nor are ships under permanent forcefields (Spire Shield Guardpost, Forcefield III, etc.)
Just a quibble: it's not "permanent forcefields", it's "immobile forcefields".  For that matter, it probably counts module forcefields since they have a move speed of zero.


Everything else looks right :)
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline Mánagarmr

  • Core Member Mark V
  • *****
  • Posts: 4,272
  • if (isInRange(target)) { kill(target); }
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #26 on: November 29, 2012, 11:36:49 am »
Combat: Wall of Maths hit you for 76 349 damage.

Notify: You die.
Click here to get started with Mantis for Suggestions and Bug Reports.

Thank you for contributing to making the game better!

Offline Wanderer

  • Master Member Mark II
  • *****
  • Posts: 1,579
  • If you're not drunk you're doing it wrong.
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #27 on: November 29, 2012, 11:54:22 am »
We're getting closer :)
I was afraid of that... :)

I'll address the math later when I've had more caffeine, but I'm not sure I understand this part at all then...

Quote
Quote
The first rule is tech limitations for the wave.
At under Difficulty 7 the tech limit is maxxed at 2.
At 7 -> 7.8 the max tech limit is either 2, or the AIP tech level if it is larger.
At 8+, the max tech limit is 5.  AIP doesn't matter.
The numbers are right, but this is not a maximum tech level; it is the tech level at which it starts looking, nothing more.  Long ago it was a max, but CPAs kept coming up short, etc, and they're just more fun when they can dump a load of mkIV on you if things are strange ;)
Okay, what do these actually do?  My CPAs at 9.0 don't start at Tech V, they start at Tech I/II, depending on what the AI is at, so I'm not sure I understand what the difference than between 7+ and 8+ is, because I don't see, mechanically, what you're describing.  I believe that's why I made the assumption I did... that and I haven't played a game under 8 in a long time.

Quote
I'm not sure what's meant by the "(or AI tech level, should they have an enforced level, such as a technologist)" bit, though.
Well, I assumed a CPA fired off by a Technologist would start at AI Tech IV.  It apparently desperately needs to be rephrased.

Quote
Quote
Diff 8+: If AIP is at tech level 3, it is uncapped.  So it will perform the planet search cycle for Tech III ships, then Tech II ships, then Tech I ships, then Tech IV ships, then Tech V ships.  Then stop.
The last example is correct, for the first two: instead of stopping they would go back to (target tech level + 1) and count up to 5, then stop.
If 8+ is supposed to start at 5... *scratches head*
... and then we'll have cake.

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #28 on: November 29, 2012, 12:54:17 pm »
Quote
Quote
The first rule is tech limitations for the wave.
At under Difficulty 7 the tech limit is maxxed at 2.
At 7 -> 7.8 the max tech limit is either 2, or the AIP tech level if it is larger.
At 8+, the max tech limit is 5.  AIP doesn't matter.
The numbers are right, but this is not a maximum tech level; it is the tech level at which it starts looking, nothing more.  Long ago it was a max, but CPAs kept coming up short, etc, and they're just more fun when they can dump a load of mkIV on you if things are strange ;)
Okay, what do these actually do?  My CPAs at 9.0 don't start at Tech V, they start at Tech I/II, depending on what the AI is at, so I'm not sure I understand what the difference than between 7+ and 8+ is, because I don't see, mechanically, what you're describing.  I believe that's why I made the assumption I did... that and I haven't played a game under 8 in a long time.
Sorry, I missed the other problem in there, and I think in general I goofed in how I said it before:

Below 7, the CPA's initial target tech level is 1 if the AI tech level is 1, and otherwise is 2.
>= 7, the CPA's initial target tech level is the AI tech level.

There's some math in the code that no longer applies, and it had confused the issue for me ;)
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline Wanderer

  • Master Member Mark II
  • *****
  • Posts: 1,579
  • If you're not drunk you're doing it wrong.
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #29 on: November 29, 2012, 11:12:19 pm »
Quote
Quote
The first rule is tech limitations for the wave.
At under Difficulty 7 the tech limit is maxxed at 2.
At 7 -> 7.8 the max tech limit is either 2, or the AIP tech level if it is larger.
At 8+, the max tech limit is 5.  AIP doesn't matter.
The numbers are right, but this is not a maximum tech level; it is the tech level at which it starts looking, nothing more.  Long ago it was a max, but CPAs kept coming up short, etc, and they're just more fun when they can dump a load of mkIV on you if things are strange ;)
Okay, what do these actually do?  My CPAs at 9.0 don't start at Tech V, they start at Tech I/II, depending on what the AI is at, so I'm not sure I understand what the difference than between 7+ and 8+ is, because I don't see, mechanically, what you're describing.  I believe that's why I made the assumption I did... that and I haven't played a game under 8 in a long time.
Sorry, I missed the other problem in there, and I think in general I goofed in how I said it before:

Below 7, the CPA's initial target tech level is 1 if the AI tech level is 1, and otherwise is 2.
>= 7, the CPA's initial target tech level is the AI tech level.

There's some math in the code that no longer applies, and it had confused the issue for me ;)

Damn thee man!  What the hell is wrong with you!  How dare you quickly read through 18 billion lines of code and misstate something to the layman!  You're a horrible evil person trying to make business the culprit of your failures and the CEO on the golf course will hear about...

... errr....

... wait.

Um.  Sorry, the problem was on my side.  Bit of Pebkac.  Whoops.  I used Ctrl-U instead of Ctrl-C for my copy/paste.

How do I retract a request to HR to have you beaten in public again?  Oh, crap, they've already erected the whipping post.

Sorry.  You want a bottle of moisturizer?

Ow.... that looks like it hurt.  12 more?  Oh my, I can't watch.
... and then we'll have cake.