Closed rzulian closed 3 years ago
Screenshot of the missing federation:
My guess is that the algorithm probably sees this federation instead:
Because it uses the same number of satellites and the new algorithm doesn't avoid new planets. Then this federation is deemed invalid (as a planet + a satellite can be dropped) and so the choice disappears altogether.
This can be fixed by showing in priority federatoins which don't touch existing planets.
Another way is by using the old algorithm for federation generation (which AVOIDS touching any other building than in the chosen combination), and apply this algorithm from checkAndGetFederationInfo
:
// Check if federation can be built with less satellites
if (!flexible) {
const allHexes = [...map.grid.values()].filter(hex => !excluded.has(hex));
const workingGrid = new Grid(...allHexes.map(hex => new Hex(hex.q, hex.r)));
const allGroups = [...this.buildingGroups(hexes.filter(hx => hx.belongsToFederationOf(this.player) || this.buildingValue(hx, {federation: true}) > 0), map).values()];
const groups = uniq(allGroups);
const convertedDestGroups = groups.map(destGroup => destGroup.map(hex => workingGrid.get(hex)));
const tree = spanningTree(convertedDestGroups, workingGrid, info.satellites);
if (tree) {
const smallFederation = this.addAdjacentBuildings(tree.map(hex => map.grid.get(hex)), map);
const info2 = this.federationInfo(smallFederation);
assert(info2.satellites >= info.satellites, "The federation can be built with less satellites, for example: " + tree.join(","));
}
}
The downside is a sizable increase in computation time.
In this game the are proposed federations that are wrong, but there is one possible which is missing
nevlas federation 1x0,0x1,-1x2,-2x3,-2x4,-3x5,-2x5,-4x6 fed2.