induktio / thinker

AI improvement patch for SMACX.
https://discord.gg/XdFuwWzzku
GNU General Public License v2.0
70 stars 10 forks source link

Alien factions extra colonies #20

Closed tnevolin closed 3 years ago

tnevolin commented 3 years ago

https://github.com/induktio/thinker/blob/ac4852e37634e22c7e11bd15451d3834a3e09f47/src/patch.cpp#L132

You are fixing the wrong thing here. Alien factions DO get their extra colonies as defined in their configuration file.

The problem is that late starters (alien faction + Cult of Planet) are not getting their bonus colony due to game conditions which has nothing to do with faction preconfigured extra colony.

Test your game with three above factions and you'll see that alien factions get extra colony but Cult does not.

The correct fix is described here already. You can just import my code which is already embedded into mod_setup_player. https://github.com/induktio/thinker/issues/15

induktio commented 3 years ago

I don't quite follow you here. On vanilla binary/Transcend all factions get 2 starting colonies. The fact that all factions get assigned an extra colony there might be an oversight but not sure if people want to change it. The fix doesn't take difficulty into account, maybe it should. So how many do you think is the correct number of colonies to spawn vs difficulty/faction type?

tnevolin commented 3 years ago

There are 2 distinct mechanics here.

  1. Alien factions get extra colony. This is hardcoded into alien faction by design.
  2. Any faction gets bonus colony based on game difficulty and location. Nobody gets it on easiest. Everybody on hardest. And for all other difficulties there is a complex computation who gets it. You won't be able just rewrite it. It is a huge code.

First one is not broken. No need to fix it.

Second one is broken for all later starters computer players due to bonus colony algorithm not being execute for them.

Check this. It properly fixes it by running the actual balance algorithm. https://github.com/tnevolin/thinker-doer/blob/ba131567e1b4a9350f783a11465cf79dad40ddc1/src/patch.cpp#L170

induktio commented 3 years ago

The end result is still that alien factions don't get an extra colony compared to others on Transcend even if some other piece of code spawns a colony while another does not. Don't like using magic global variables for patches either. Honestly I think balance function code is mostly redundant for gameplay and it would not make sense to replicate it in open source. Just think about the design there for a moment. Thinker already tries to balance faction starting locations with faction_placement so then running some other piece of code to "balance" them is very redundant. I'll just remove the fix and let it run on vanilla defaults now. Maybe think later if balance() could be replaced with something else.

tnevolin commented 3 years ago

Absolutely. Do what you think is right.