View Issue Details

IDProjectCategoryLast Update
0002538AI War 1 / ClassicBug - OtherJan 18, 2011 11:49 pm
ReporterBluePhoenix Assigned Tokeith.lamothe  
Status resolvedResolutionfixed 
Product Version4.071 
Summary0002538: Ship caps are being applied twice to AI waves.
DescriptionI was doing some digging in the MainThreadWaveComputationLog.txt and AIThreadWaveComputationLog.txt file (trying to find out why the first AI wave(s), with AP of 10 and AI diff 7, consisted of 316 ships when using high ship caps, but only 99 ships for normal ships caps. At least for the triangle ships) when I found a bug that meant the ship cap scale was being applied twice (rather than only once).

The ship cap scale was applied once in the AI thread as part of the call to 'AdjustNumberShipsFromAIType' (which includes the cap modifier) , and again in the Main thread as part of the 'ShipCapMultiplier' (which also includes, or is effected by, the cap modifier).

This results in waves being 4 times larger with high ship caps than with normal ship caps (and explains the extreme difference in ship counts for the first wave between normal and high ship caps).

I have attached my 'MainThreadWaveComputationLog.txt' and 'AIThreadWaveComputationLog.txt' files showing this bug.
TagsNo tags attached.
Internal Weight

Activities

BluePhoenix

Jan 18, 2011 4:42 pm

reporter  

MainThreadWaveComputationLog.txt (7,269 bytes)   
1/18/2011 9:25:09 PM (4.071)
-----------------------------------
Triggering Normal Wave; wave size factor: 1; Game Time: 0:11:40

1/18/2011 9:25:09 PM (4.071)
-----------------------------------
Triggering Normal Wave; wave size factor: 1; Game Time: 0:11:40

1/18/2011 9:25:10 PM (4.071)
-----------------------------------
Receiving AddInboundWave from AI Thread at Game Time: 0:11:41
WaveSize factor: 1
Raw Units Dictionary Entries: 
MissileShip => 70
LightStarship => 1


1/18/2011 9:25:10 PM (4.071)
-----------------------------------
Receiving AddInboundWave from AI Thread at Game Time: 0:11:41
WaveSize factor: 1
Raw Units Dictionary Entries: 
Fighter => 70
LightStarship => 1


1/18/2011 9:25:10 PM (4.071)
-----------------------------------
Performing first CheckWave with size factor of 1 on wave at Game Time: 0:11:41

CheckWave: populating count of MissileShip with base magnitude of 70
numberUnits = kv.Value * this.WaveSize : 70
after applying ShipCapMultiplier if any, numberUnits : 70
after applying CanUseNeinzulRegenerator if any, numberUnits : 70
after applying Mark-based multiplier if any, numberUnits : 105
after applying at-least-one rule, numberUnits : 105
after applying difficulty-based (if >= 8 then 4, if >= 7 then 3, if >= 6 then 2, else 1) multiplier if any, numberUnits : 315
numberUnitsInt = numberUnits.IntValue : 315

CheckWave: populating count of LightStarship with base magnitude of 1
numberUnits = kv.Value * this.WaveSize : 1
after applying ShipCapMultiplier if any, numberUnits : 1
after applying CanUseNeinzulRegenerator if any, numberUnits : 1
after applying Mark-based multiplier if any, numberUnits : 1.5
after applying at-least-one rule, numberUnits : 1.5
after applying difficulty-based (if >= 8 then 4, if >= 7 then 3, if >= 6 then 2, else 1) multiplier if any, numberUnits : 4.5
numberUnitsInt = numberUnits.IntValue : 4
it's a starship so only adding one rule : 1 (had you going there, didn't we)

Wave total ships: 316
TypesForDirectAdd count by type: 
MissileShip => 315
LightStarship => 1
TypesForCarrierAdd count by type: 


1/18/2011 9:25:10 PM (4.071)
-----------------------------------
Performing first CheckWave with size factor of 1 on wave at Game Time: 0:11:41

CheckWave: populating count of Fighter with base magnitude of 70
numberUnits = kv.Value * this.WaveSize : 70
after applying ShipCapMultiplier if any, numberUnits : 70
after applying CanUseNeinzulRegenerator if any, numberUnits : 70
after applying Mark-based multiplier if any, numberUnits : 105
after applying at-least-one rule, numberUnits : 105
after applying difficulty-based (if >= 8 then 4, if >= 7 then 3, if >= 6 then 2, else 1) multiplier if any, numberUnits : 315
numberUnitsInt = numberUnits.IntValue : 315

CheckWave: populating count of LightStarship with base magnitude of 1
numberUnits = kv.Value * this.WaveSize : 1
after applying ShipCapMultiplier if any, numberUnits : 1
after applying CanUseNeinzulRegenerator if any, numberUnits : 1
after applying Mark-based multiplier if any, numberUnits : 1.5
after applying at-least-one rule, numberUnits : 1.5
after applying difficulty-based (if >= 8 then 4, if >= 7 then 3, if >= 6 then 2, else 1) multiplier if any, numberUnits : 4.5
numberUnitsInt = numberUnits.IntValue : 4
it's a starship so only adding one rule : 1 (had you going there, didn't we)

Wave total ships: 316
TypesForDirectAdd count by type: 
Fighter => 315
LightStarship => 1
TypesForCarrierAdd count by type: 


1/18/2011 9:32:45 PM (4.071)
-----------------------------------
Triggering Normal Wave; wave size factor: 1; Game Time: 0:11:40

1/18/2011 9:32:45 PM (4.071)
-----------------------------------
Triggering Normal Wave; wave size factor: 1; Game Time: 0:11:40

1/18/2011 9:32:45 PM (4.071)
-----------------------------------
Receiving AddInboundWave from AI Thread at Game Time: 0:11:41
WaveSize factor: 1
Raw Units Dictionary Entries: 
MissileShip => 35
Dreadnought => 1


1/18/2011 9:32:45 PM (4.071)
-----------------------------------
Receiving AddInboundWave from AI Thread at Game Time: 0:11:41
WaveSize factor: 1
Raw Units Dictionary Entries: 
BulletproofFighter => 35
LeechStarship => 1


1/18/2011 9:32:45 PM (4.071)
-----------------------------------
Performing first CheckWave with size factor of 1 on wave at Game Time: 0:11:41

CheckWave: populating count of MissileShip with base magnitude of 35
numberUnits = kv.Value * this.WaveSize : 35
after applying ShipCapMultiplier if any, numberUnits : 17.5
after applying CanUseNeinzulRegenerator if any, numberUnits : 17.5
after applying Mark-based multiplier if any, numberUnits : 26.25
after applying at-least-one rule, numberUnits : 26.25
after applying difficulty-based (if >= 8 then 4, if >= 7 then 3, if >= 6 then 2, else 1) multiplier if any, numberUnits : 78.75
numberUnitsInt = numberUnits.IntValue : 78
after at-least-effective-ship-cap-rule, numberUnitsInt : 98

CheckWave: populating count of Dreadnought with base magnitude of 1
numberUnits = kv.Value * this.WaveSize : 1
after applying ShipCapMultiplier if any, numberUnits : 1
after applying CanUseNeinzulRegenerator if any, numberUnits : 1
after applying Mark-based multiplier if any, numberUnits : 1.5
after applying at-least-one rule, numberUnits : 1.5
after applying difficulty-based (if >= 8 then 4, if >= 7 then 3, if >= 6 then 2, else 1) multiplier if any, numberUnits : 4.5
numberUnitsInt = numberUnits.IntValue : 4
it's a starship so only adding one rule : 1 (had you going there, didn't we)

Wave total ships: 99
TypesForDirectAdd count by type: 
MissileShip => 98
Dreadnought => 1
TypesForCarrierAdd count by type: 


1/18/2011 9:32:45 PM (4.071)
-----------------------------------
Performing first CheckWave with size factor of 1 on wave at Game Time: 0:11:41

CheckWave: populating count of BulletproofFighter with base magnitude of 35
numberUnits = kv.Value * this.WaveSize : 35
after applying ShipCapMultiplier if any, numberUnits : 15.75
after applying CanUseNeinzulRegenerator if any, numberUnits : 15.75
after applying Mark-based multiplier if any, numberUnits : 23.62
after applying at-least-one rule, numberUnits : 23.62
after applying difficulty-based (if >= 8 then 4, if >= 7 then 3, if >= 6 then 2, else 1) multiplier if any, numberUnits : 70.87
numberUnitsInt = numberUnits.IntValue : 70
after at-least-effective-ship-cap-rule, numberUnitsInt : 88

CheckWave: populating count of LeechStarship with base magnitude of 1
numberUnits = kv.Value * this.WaveSize : 1
after applying ShipCapMultiplier if any, numberUnits : 1
after applying CanUseNeinzulRegenerator if any, numberUnits : 1
after applying Mark-based multiplier if any, numberUnits : 1.5
after applying at-least-one rule, numberUnits : 1.5
after applying difficulty-based (if >= 8 then 4, if >= 7 then 3, if >= 6 then 2, else 1) multiplier if any, numberUnits : 4.5
numberUnitsInt = numberUnits.IntValue : 4
it's a starship so only adding one rule : 1 (had you going there, didn't we)

Wave total ships: 89
TypesForDirectAdd count by type: 
BulletproofFighter => 88
LeechStarship => 1
TypesForCarrierAdd count by type: 


BluePhoenix

Jan 18, 2011 4:44 pm

reporter  

AIThreadWaveComputationLog.txt (2,878 bytes)   
1/18/2011 9:25:09 PM (4.071)
-----------------------------------
Starting CreateHomogenousWaveToPlanet at Game Time: 0:11:39 ; Player.AIType: Entrenched_Homeworlder ; Player.AIDifficulty: 7 ; AIProgressionLevel: 10 ; AITechLevel: 1 ; WaveSize: 1
aiTypeBasedAIPIncrement : 0
workingShips = ( ( AIProgressionLevel * Player.AIDifficulty ) / ( 11 - Player.AIDifficulty ) ) : 17.5
workingShips *= FInt.FromParts( 0, AILoop.Instance.AIRandom.Next( 800, 1100 ) ) : 15.31
workingShips = Min(workingShips,Player.AIDifficulty * 10) :70
numberShips = workingShips.IntValue :70
after AdjustNumberShipsFromAIType call (includes cap modifier), numberShips :70
numberTech123 = numberShips - numberExplosive - numberCore :70


1/18/2011 9:25:10 PM (4.071)
-----------------------------------
Starting CreateHomogenousWaveToPlanet at Game Time: 0:11:39 ; Player.AIType: Mine_Enthusiast ; Player.AIDifficulty: 7 ; AIProgressionLevel: 10 ; AITechLevel: 1 ; WaveSize: 1
aiTypeBasedAIPIncrement : 0
workingShips = ( ( AIProgressionLevel * Player.AIDifficulty ) / ( 11 - Player.AIDifficulty ) ) : 17.5
workingShips *= FInt.FromParts( 0, AILoop.Instance.AIRandom.Next( 800, 1100 ) ) : 18.56
workingShips = Min(workingShips,Player.AIDifficulty * 10) :70
numberShips = workingShips.IntValue :70
after AdjustNumberShipsFromAIType call (includes cap modifier), numberShips :70
numberTech123 = numberShips - numberExplosive - numberCore :70


1/18/2011 9:32:45 PM (4.071)
-----------------------------------
Starting CreateHomogenousWaveToPlanet at Game Time: 0:11:39 ; Player.AIType: Entrenched_Homeworlder ; Player.AIDifficulty: 7 ; AIProgressionLevel: 10 ; AITechLevel: 1 ; WaveSize: 1
aiTypeBasedAIPIncrement : 0
workingShips = ( ( AIProgressionLevel * Player.AIDifficulty ) / ( 11 - Player.AIDifficulty ) ) : 17.5
workingShips *= FInt.FromParts( 0, AILoop.Instance.AIRandom.Next( 800, 1100 ) ) : 17.09
workingShips = Min(workingShips,Player.AIDifficulty * 10) :70
numberShips = workingShips.IntValue :70
after AdjustNumberShipsFromAIType call (includes cap modifier), numberShips :35
numberTech123 = numberShips - numberExplosive - numberCore :35


1/18/2011 9:32:45 PM (4.071)
-----------------------------------
Starting CreateHomogenousWaveToPlanet at Game Time: 0:11:39 ; Player.AIType: Mine_Enthusiast ; Player.AIDifficulty: 7 ; AIProgressionLevel: 10 ; AITechLevel: 1 ; WaveSize: 1
aiTypeBasedAIPIncrement : 0
workingShips = ( ( AIProgressionLevel * Player.AIDifficulty ) / ( 11 - Player.AIDifficulty ) ) : 17.5
workingShips *= FInt.FromParts( 0, AILoop.Instance.AIRandom.Next( 800, 1100 ) ) : 18.23
workingShips = Min(workingShips,Player.AIDifficulty * 10) :70
numberShips = workingShips.IntValue :70
after AdjustNumberShipsFromAIType call (includes cap modifier), numberShips :35
numberTech123 = numberShips - numberExplosive - numberCore :35


AIThreadWaveComputationLog.txt (2,878 bytes)   

keith.lamothe

Jan 18, 2011 4:48 pm

administrator   ~0009108

Chris, looking at the calculation logs I think BluePhoenix is exactly right. I don't think it's been like this the entire time since I last touched the wave logic but maybe it has been.

Anyway, my inclination is to comment out the application of the cap-multiplier in the main-thread segment. Any objections?

TechSY730

Jan 18, 2011 4:52 pm

reporter   ~0009110

Will the forumlas and/or multipliers be adjusted such that wave sizes are still balanced under the correct calculations?

keith.lamothe

Jan 18, 2011 5:12 pm

administrator   ~0009113

Define 'Balanced' ;D

Chris_McElligottPark

Jan 18, 2011 6:21 pm

administrator   ~0009118

Keith, I think that sounds okay, applying the ship caps as late as possible does make the most sense and is likely to give the best result.

This may result in some overlarge waves for a while, though, for sure. I guess we'll see how it feels.

keith.lamothe

Jan 18, 2011 6:25 pm

administrator   ~0009119

Well, actually the main-thread one that I was going to comment out is the later of the two applications. I figured I would leave the AI-thread one since it is (iirc) also used for some non-wave reinforcement-type spawns. At least on schizo.

keith.lamothe

Jan 18, 2011 6:26 pm

administrator   ~0009120

Which brings up the importance of making sure this is happening for both schizo and normal waves. My guess is that it's already not doing the ai-thread multiplier for one of those (schizo), but still doing it for the other.

Chris_McElligottPark

Jan 18, 2011 6:27 pm

administrator   ~0009121

Oh, right, duh, sorry -- I read it backwards. I'd actually leave the main-thread one in place, and make the one on the AI thread turn into a reinforcement-only application on the MixedWave branch, and just taken out completely on the homogeneous one.

keith.lamothe

Jan 18, 2011 11:49 pm

administrator   ~0009214

Ok, yea, this was a problem ;) For 4.072:

* Fixed a relatively longstanding error (since unit cap scale was introduced) in wave size computation: previously the wave size would be multiplied by the unit-cap-scale-multiplier (high = 1, normal = 0.5, low = 0.25) and then later by the ship-type-specific ship cap multiplier (e.g. on high fighter = 1, sentinel-frigate = 0.1, zenith-bombard = 0.25); the problem is that thte ship-type-specific cap was _already_ multiplied by the overall unit-cap-scale multiplier. So waves on high had the correct size, normal waves were 1/2 the correct size, and low waves were 1/4 the correct size.
** Since the balance of wave sizes has been generally acceptable lately, we don't want to just totally shatter that to fix this math mistake on our part. Instead we are fixing that but also dividing the base size of waves by 2. So waves on normal will continue to be the same size as before, waves on high will actually be half the previous size, and waves on low will be double the previous size.
** Thanks to BluePhoenix for bringing this to our attention.

Issue History

Date Modified Username Field Change
Jan 18, 2011 4:42 pm BluePhoenix New Issue
Jan 18, 2011 4:42 pm BluePhoenix File Added: MainThreadWaveComputationLog.txt
Jan 18, 2011 4:44 pm BluePhoenix File Added: AIThreadWaveComputationLog.txt
Jan 18, 2011 4:48 pm keith.lamothe Note Added: 0009108
Jan 18, 2011 4:48 pm keith.lamothe Assigned To => keith.lamothe
Jan 18, 2011 4:48 pm keith.lamothe Status new => acknowledged
Jan 18, 2011 4:52 pm TechSY730 Note Added: 0009110
Jan 18, 2011 5:12 pm keith.lamothe Note Added: 0009113
Jan 18, 2011 6:21 pm Chris_McElligottPark Note Added: 0009118
Jan 18, 2011 6:25 pm keith.lamothe Note Added: 0009119
Jan 18, 2011 6:26 pm keith.lamothe Note Added: 0009120
Jan 18, 2011 6:27 pm Chris_McElligottPark Note Added: 0009121
Jan 18, 2011 11:49 pm keith.lamothe Note Added: 0009214
Jan 18, 2011 11:49 pm keith.lamothe Status acknowledged => resolved
Jan 18, 2011 11:49 pm keith.lamothe Resolution open => fixed