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

Offline LaughingThesaurus

  • Master Member Mark II
  • *****
  • Posts: 1,723
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #30 on: November 29, 2012, 11:46:09 pm »
Wait
Does AI War actually have 18 billion lines of code?

Offline Hearteater

  • Core Member
  • *****
  • Posts: 2,334
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #31 on: November 30, 2012, 10:22:53 am »
Nope, just one line.  One very long line.

Offline Mephology

  • Newbie Mark II
  • *
  • Posts: 12
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #32 on: November 30, 2012, 10:55:03 am »
Nope, just one line.  One very long line.

 :D  Question about CPAs.  When the AI is pulling troops from a barracks, does a message display in the log that the barracks have been destroyed if it empties?  I could not for the life of me figure out how I managed to destroy a barracks on a random world far from where I was currently operating in a recent game.

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 #33 on: November 30, 2012, 01:36:17 pm »
Nope, just one line.  One very long line.

 :D  Question about CPAs.  When the AI is pulling troops from a barracks, does a message display in the log that the barracks have been destroyed if it empties?  I could not for the life of me figure out how I managed to destroy a barracks on a random world far from where I was currently operating in a recent game.

Nope, it'll just deflate the barracks without a warning.
... 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 #34 on: November 30, 2012, 01:39:50 pm »
Nope, it'll just deflate the barracks without a warning.
Deflate?  Gives me an idea.  Maybe the barracks should let out a loud "pop" noise and fly at random angles all over the planet spraying the ships around until it shrinks to nothing ;)
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 #35 on: November 30, 2012, 01:55:20 pm »
Okay, I am CAFFEINATED!... and can finally try to make sense of this.  :)

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:
Honestly I was just pointing it out there for completeness.  When I rewrite the wiki article I intended to do the calculations in a separate section.

Quote
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;"
Okay, Googlefu has failed.  What's FInt do, that a Floating Int declaration or something?  Also, how does this affect it on higher difficulties?  I can probably figure that out once I know what FInt is doing.    Also, found the CPA listing finally in Waves_MainThread.  It looks like this number ends up static for the entire game, that'll make things easier.  I'll probably just make that into a table for sanity's sake.

Quote
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.
Interesting, so Diff affects both the minimum AIP calculation and then affects the CPA volume itself.

Quote
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.
What's Mat.One stand in for?

Quote
Code: [Select]
humanHomeworldCountMultiplier = Mat.One + ( (FInt)( humanHomeworldCount - 1 ) * FInt.FromParts( 0, 330 ) ) + ( championCount * FInt.FromParts( 0, 066 ) ) = 1Just accounting for champs and multiple HWs.
Just to dig into this far too deeply, what's .FromParts doing here?  Not being able to find the base function I can't check out the methods associated with it.

Quote
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.
Ah, that's what you mean there by cap-scale.  For some reason I thought wave ship-caps multipliers were going to come into play.  That's... brutal.  Explains why I nearly got eaten by the last CPA... (Yes, this particular game is going on the timescale of epicness... I'm at 15.5 hours in already).

Code: [Select]
11/27/2012 11:24:30 PM (6.009)
-----------------------------------
Triggering CPA (always from first AI); Game Time: 13:51:00
effectiveAIPForCPAPurposes = this.AIProgressionLevelEffective = 147
since diff > 7, numberOfSecondsPerPointOfMinimumAIPForCPAPurposes = 360 + ( (FInt)60 * ( (FInt)7 - this.AIDifficulty ) ).IntValue = 240
minimumAIPForCPAPurposes = Game.Instance.GameSecond / numberOfSecondsPerPointOfMinimumAIPForCPAPurposes = 207
effectiveAIPForCPAPurposes = Max(effectiveAIPForCPAPurposes,minimumAIPForCPAPurposes) = 207
difficultyFactor = ( this.AIDifficulty * this.GetHandicapMultiplier() ) / ( 13 - this.AIDifficulty ) : 2.25
simulateMaxTimeWaveFactor = Mat.One + ( ( this.AIDifficulty * 2 ) / ( ( 14 - this.AIDifficulty ) * 3 ) ) : 2.2
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 = 5123


Quote
Everything else looks right :)

Thanks Keith, appreciate the in-depth discussion on this.
... 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 #36 on: November 30, 2012, 02:12:09 pm »
Okay, Googlefu has failed.  What's FInt do, that a Floating Int declaration or something?
It's for fixed-point-math http://stackoverflow.com/questions/605124/fixed-point-math-in-c (scroll down a bit for the code; we've changed ours a bit since then, but probably not in any way that matters here).

Floating-point math is not deterministic across different platforms (two computers can give two slightly different results to a floating point arithmetic operation and still be considered "correct"), and thus eventually causes seemingly-random desyncs in MP if we use it in the simulation, so we use FInt instead.


Quote
Interesting, so Diff affects both the minimum AIP calculation and then affects the CPA volume itself.
Yes, and affects the volume multiple times.

Quote
What's Mat.One stand in for?
It's just FInt for 1.  Beats doing "(FInt)1" all over the place, because we would have to.

Quote
Just to dig into this far too deeply, what's .FromParts doing here?  Not being able to find the base function I can't check out the methods associated with it.
FInt.FromParts(2,500) ~= 2.5.  Incidentally, FInt.FromParts(2,5) would be about 2.005.   It's just a way to construct a non-whole-number, since casting or otherwise converting a float or double into an FInt would get back into desync territory.


In other words, the floating-point portion of the ALU is a Dirty Stinking Liar so we had to make a lot of stuff up ;)
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 #37 on: November 30, 2012, 02:26:51 pm »
Ah, thanks for the explanation on FInt.  If I read that article a few hundred times I'll probably understand all the underlying pieces, but that's my own problem. :)

Google-Fu is really failing today, I can't find the image I want for 'this pool is too damned deep!'.  >:(

Alright, I'll see what I can do to turn that into newbie consumable information for the wiki.  Appreciated!
... and then we'll have cake.

Offline Hearteater

  • Core Member
  • *****
  • Posts: 2,334
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #38 on: November 30, 2012, 02:29:13 pm »
In other words, the floating-point portion of the ALU is a Dirty Stinking Liar so we had to make a lot of stuff up ;)
That's not entirely true.  It is just trying to be as accurate as possible.  But so is every other system.  And as a result, two different systems aren't consistent.  Heck, even one system may not be consistent!  IEEE floating point is all about maximizing accuracy.  Anyone interested should check out this general ariticle on IEEE floating point accuracy vs consistency and this more game-related article.

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 #39 on: November 30, 2012, 02:37:52 pm »
That's not entirely true.
That's what I told the ALU!
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 #40 on: November 30, 2012, 02:46:42 pm »
And today I learn two new acronyms I didn't care about until an hour ago.  Thank you gents.
... and then we'll have cake.

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 #41 on: November 30, 2012, 07:43:28 pm »
I've completely rewritten the wiki page for CPAs to bring it inline with the new rules.  Can a few of you proofread it for me and make sure I didn't leave any bias in there and that it reads intelligently?

Also, the code component looks... horrendous.  However, my ability to format a wiki is equivalently bad.  If you know of a way to make that prettier, by all means, please do.

Link: http://www.arcengames.com/mediawiki/index.php?title=AI_War_-_Cross_Planet_Attacks
... and then we'll have cake.

Offline Minotaar

  • Sr. Member
  • ****
  • Posts: 272
Re: Request to Keith - CPA Strategic Reserve Spawns
« Reply #42 on: December 01, 2012, 01:16:12 am »

I've completely rewritten the wiki page for CPAs to bring it inline with the new rules.  Can a few of you proofread it for me and make sure I didn't leave any bias in there and that it reads intelligently?

Also, the code component looks... horrendous.  However, my ability to format a wiki is equivalently bad.  If you know of a way to make that prettier, by all means, please do.

Link: http://www.arcengames.com/mediawiki/index.php?title=AI_War_-_Cross_Planet_Attacks

Looks reasonable, except the first paragraph had "threat fleet" instead of "threat" in a couple places. Fixed that.
The whole calculation breakdown still looks very difficult to understand, but I'm not sure if anything can really be done to improve it  :)
Oh, also, the code segment increases its font size if I log into the wiki. Don't know Wiki-Fu, so can't help with that either I'm afraid  :)

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 #43 on: December 01, 2012, 09:24:04 am »
Looks good overall; I made a couple small corrections to some numbers (champions add 0.066 multiplier, not 0.66, which would be twice what an extra HW adds), but this is certainly a vast improvement :)

By the way, on the multiple impacts of difficulty on the formula result, I did some quick calculations to find  "all else being equal, what multiplier does each difficulty give?".  I think I did this when working out the formula but I must have paged that memory out to disk ;)  Anyway:

DifficultyEffectiveMultiplier
10.09
20.20
30.35
40.84
51.50
62.57
74.38
7.35.53
7.66.30
87.56
8.38.70
8.610.07
912.38
9.316.03
9.620.79
9.829.74
1040.00

So Diff 8 has CPAs a bit less than 2x as strong as diff 7.  Diff 9 has CPAs a bit less than 3x as strong as diff 7, but 9.3 jumps to roughly 4x, 9.6 to roughly 5x, 9.8 to roughly 7x, and 10 to roughly 10x.

Ouch ;)  But that's what I wanted it to do, more or less.  No one step is a total cliff, but the end result is you hit the bottom and splat.
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 #44 on: December 01, 2012, 12:51:22 pm »
Thank you both for the proofread.

Looks reasonable, except the first paragraph had "threat fleet" instead of "threat" in a couple places. Fixed that.
Ah, yeah, you're right, I hadn't really thought about that.
Quote
The whole calculation breakdown still looks very difficult to understand, but I'm not sure if anything can really be done to improve it  :)
I'll try to rework it in my head a bit and see if I can simplify it further somehow.

Looks good overall; I made a couple small corrections to some numbers (champions add 0.066 multiplier, not 0.66, which would be twice what an extra HW adds), but this is certainly a vast improvement :)
Heh, thank you.  I'd thought it said .066 but my knee-jerk reaction was "That's it?!  Can't be..."  Whoops.

Quote
By the way, on the multiple impacts of difficulty on the formula result, I did some quick calculations to find  "all else being equal, what multiplier does each difficulty give?".  I think I did this when working out the formula but I must have paged that memory out to disk ;) 

<snip>

So Diff 8 has CPAs a bit less than 2x as strong as diff 7.  Diff 9 has CPAs a bit less than 3x as strong as diff 7, but 9.3 jumps to roughly 4x, 9.6 to roughly 5x, 9.8 to roughly 7x, and 10 to roughly 10x.

Neat, nice evaluation.  If I start feeling ambitious I may transfer this to the wiki.  That little table I did took a rediculous amount of time for me to format.  This one couldn't have been any better, here in the forum, though.

I'm hoping Dazio comes by and decides the code section looks horrible and he gets a chance to work some magic on it.  :)
... and then we'll have cake.