Consistently sort the build order

When the returned value of the compare function is `0` the order is
preserved. Before the sort, the order between joining clients and
non-joining clients differ.
Now everything important (which is used later on) is included in the
comparison. If still `0` is returned it's not importent which element is
taken.

Another solution would be to have one array per category.
This commit is contained in:
phosit 2025-10-01 16:27:03 +02:00
parent c4dd0040ee
commit b572fed672
No known key found for this signature in database
GPG key ID: C9430B600671C268

View file

@ -642,7 +642,16 @@ AttackPlan.prototype.trainMoreUnits = function(gameState)
let vb = b[0]/b[3].targetSize - b[3].priority;
if (b[0] >= b[3].targetSize)
vb += 1000;
return va - vb;
const calcResult = va - vb;
if (calcResult !== 0)
return calcResult;
if (a[4] < b[4])
return 1;
if (a[4] > b[4])
return -1;
return 0;
});
if (this.Config.debug > 1 && gameState.ai.playedTurn%50 === 0)