LoneGazebo / Community-Patch-DLL

Community Patch for Civilization V - Brave New World
Other
293 stars 160 forks source link

[Feature Request] Improvements to Great Work Theming #9805

Open azum4roll opened 1 year ago

azum4roll commented 1 year ago

I think it belongs here since it's not a balance change, only QoL and AI optimization.

Add the followings to the theming screen:

  1. Ability to lock certain slots to prevent the GW in them from being swapped out by the Optimize function, or to other civs. Right click should work for both lock and unlock.
  2. Checkbox or dropdown to enable auto-optimize every turn, preferably with both Optimize/Swap and Optimize choices.

Turn flow (if it doesn't already work this way): At turn start, the player should auto optimize based on the option selected (AI should always swap&optimize). At turn end, the player should place a randomly-picked GW of each type (unthemed, unlocked) to each swap slot.

Optimizing the Optimize algorithm: This is the current order of theming slots: (1) Buildings in not endangered non-puppet cities, don't consider swapping (2) Buildings in not endangered puppet cities, don't consider swapping (3) Non-music buildings in not endangered cities, consider swapping (music can't be swapped) (4) Buildings in endangered cities, don't consider swapping Don't put any GW in cities that are about to fall (CvCity::isInDangerOfFalling(true))

Endangered = lower than half HP or under 3 population in a city being razed for the AI; any damaged city for human. Capital is never endangered (which is how we can grab so many GWs off capitals I guess). Priority (from Building_ThemingBonuses) is followed within each bracket.

Assuming the priority is perfectly designed (it isn't and will never be, but I tried), this should have no problem other than below:

  1. Classic greedy problem. A higher priority 3-slot building will be themed before 2 lower priority 2-slot buildings, even if theming the latter is better, assuming you can only theme either one set.
  2. 10440 Oxford University is never themed because Amphitheaters will almost always be themed by (1) and (2), and GW of Writing swaps will never be performed as a result. Similar with 4-slot buildings being hard to theme in general despite being high priority.

Maybe we should just always consider swapping for AI, and for the human if Swap&Optimize is used? Change the order to: (1) Buildings in not endangered non-puppet cities, consider swapping (2) Buildings in not endangered puppet cities, consider swapping (3) Buildings in endangered cities, don't consider swapping

This will resolve problem 2 above.

ilteroi commented 1 year ago

there was also the information that GW swapping leads to desyncs in multiplayer ... so of anyone is going to touch this, please also fix multiplayer.

personally i think auto-optimize should be active always. nobody needs a manual mode. then we could drop the UI part completely and maybe solve the multiplayer issue en passant. simple.

LoneGazebo commented 1 year ago

I redid the swaptimize code years ago…that whole class is a nightmare of boondoggle code. The problem is that is so many of the variables are stored in special containers that aren’t easy to reference without a ton of lookups. I welcome optimization but good luck.

LoneGazebo commented 1 year ago

The desyncs may be a consequence of my hijacking of the swap functions in the network class to make the event system MP compatible. Might be worth a check.

azum4roll commented 11 months ago

An update: Priority has been updated across the theming buildings in the merge. OP has been updated to reflect my knowledge of the code.