Fixing Influence - any ideas welcome

Describe your experience with the latest version of FreeOrion to help us improve it.

Moderator: Oberlus

Forum rules
Always mention the exact version of FreeOrion you are testing.

When reporting an issue regarding the AI, if possible provide the relevant AI log file and a save game file that demonstrates the issue.
Message
Author
Daybreak
Vacuum Dragon
Posts: 641
Joined: Mon Aug 13, 2018 10:14 pm

Re: Fixing Influence - any ideas welcome

#76 Post by Daybreak »

I edited my above post, btw.

The whole idea of influence is to stop someone gaining to much territory and steamrolling over their enemies, and it works. However as I understand it, BlueAward proved the current formula means that at a certain point all planets need to be set to an influence focus, because it is a linear progression. Which you acknowledge is not a good thing.

Now the new formula is attempting to do the same thing, and the new formula you are discussing means that everything is hunky dory initially, until it reaches a soft cap, and then anyone gobbling up too much territory, will need more and more planets set to influence to continue gobbling up more territory.

I am not trying to change that premise

But In this thread viewtopic.php?f=6&t=12485 we are adjusting the influence percentages, which was proposed by you, to counter any luck

What I am trying to do is kind of incorporate that into the new formula you are working on.


You said
Thinking of balance during game, and the intended effect of making successful/lucky empires not so successful compared to the others, it seems better to have the soft cap sooner, so that alliances of two small empires have real chances of winning against a single big empire with twice their planets. <-- If this backfires (making alliances the only way to win) we could fall back to linear.
Oberlus wrote: Mon Aug 15, 2022 4:14 pm Forcing a fixed ratio of planets set to influence sounds dull and boring like hell. Let the players do a good or a bad job with what they get! Knowing that the upkeep will adapt to your needs, demanding less if you make bad choices of species, planets and policies, sounds just aweful.
its not fixed as all. Its a range - to give it flexibility, and to give smaller empires, possibly unlucky empires more of a chance. A smart player can play around within the range.

Isn't the current formula fixed per se?

Oberlus wrote: Mon Aug 15, 2022 4:14 pm A "lucky empire" (this comes from older threads) is one that has a nice combination of species, colonizable planets and specials around his starting world. Being lucky implies it can grow faster: get more/better planets and more population sooner -> get more PP/RP/IP sooner -> get more warships/troopers/colonizable planets -> get more PP/RP/IP sooner (etc.). This can never be bad for the empire by itself.

If a lucky empire chooses a bad strategy (like building up too much army without anything to do with it, or not building any army when there is a potential thread, or making bad choices of planets, techs and policies), that is up to the player and nothing that should be "fixed".

The motivation to hinder the growth of lucky empires is for gameplay experience: if a lucky (unlucky) start means you have already won (lost), you lose interest on the game.

A "successful empire" is one that is doing well compared to others. It can be a "lucky empire" that didn't do wrong or just an empire that is getting the most out of what the galaxy offered it at start, and doing it better than the neighbors.

The motivation to hinder the growth of a succesful empire is the same: to extend the game time that is thrilling.
You have brought game play into the conversation. None of these ideas will affect a players ability to be successful, and therefore not boring.

This is a concept - if you truly look at it, and the numbers don't work, then thats fine. I am ok with that. Don't ask me for that math though, I am incapable of giving you that.

User avatar
Oberlus
Cosmic Dragon
Posts: 5715
Joined: Mon Apr 10, 2017 4:25 pm

Re: Fixing Influence - any ideas welcome

#77 Post by Oberlus »

I'm sorry, this is exhausting.

Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Fixing Influence - any ideas welcome

#78 Post by Ophiuchus »

Oberlus wrote: Mon Aug 15, 2022 10:46 pm I'm sorry, this is exhausting.
You are aware you do not have to answer every post.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

BlueAward
Vacuum Dragon
Posts: 646
Joined: Mon Aug 08, 2022 3:15 am

Re: Fixing Influence - any ideas welcome

#79 Post by BlueAward »

When you look at all my calculations, a lot hinges on average influence per influence generating planet. You can see the difference when I assume it to be sqrt(30) vs sqrt(36) or just 8.

Also, the more of your IP earnings comes from population, not flat bonuses, the worse you are in terms of colonizing new planets (another thing that makes flat bonus like from artisan workshops very nice). It is likely an intended feature, however it puts relatively more pressure on early game, making it look worse than idealized from some end state as shown in my charts.

Putting sqrt(x) actually makes the early game even harder than just "x" - partly an intended feature, to bring soft cap sooner, but it also means comparatively lower percentage of productive planets at the beginning compared to linear decline in case of just "x"

The harder the game is at the start, the bigger part starting luck plays. At the same time it puts even higher emphasis on knowing what you are doing.

However, the part about knowing what you are doing kind of stays with you all the time, while the part about better starting luck is by definition only at the start. So generally I support sentiment of easing out on the early game. Something like not paying influence for your capital, and having a flat influence bonus for it instead, is one thing to ease out the very start, for example.

Looking in terms of influence. The formula for cost per colony being at the center of considerations, you may put like this:

P * f(x) * g(y)

where P is some scaling factor, f(x) is some function on number of planets you have x, g(y) is some function of your influence y. Oberlus proposal adjusts f(x) to galaxy size. The function being actually a function on percentage of galaxy owned, rather than on number of planets, makes a perfect sense to me. The other function, g(y), is put in terms of average influence per average planet, which also makes sense to me. Although, the proposal makes it to be a function on "how much an end game civilization is expected to produce on average planet", "Max", and that's like 8 or 9, apparently.

Now P is something left to gameplay settings. Oberlus understands the parameter as percentage of galaxy an end game civ should be able to grab at hard cap (hard cap is when all planets need influence focus) - assuming by definition it is able to do the 8 or 9 average influence per planet. So if you set it to like 75% then it would leave 25% planets left on "productive" duty when colonizing entire galaxy, while something like 200% means that hard cap is on 50% of the galaxy so you can't really colonize everything.

But the equation can also be viewed as putting that percentage on g(y). So a 75% setting is what allows an empire that does 75% of "Max" to colonize 100% of the galaxy.

Lower P makes early game easier, it actually makes entire game easier.

Daybreak, I understand that you are proposing playing with the g(y) part. However, what you are proposing seems dangerously close to g(y) meaning "average influence per planet you are able to muster at the given time". So yes, it is possible to factor into the equation, but it actually factors out of the equation entirely the "average influence per planet" part. Not only if your start was good or not, but also if you bother in any way to have your influence game improved or not. This is concern expressed by Oberlus

Now, we are not 100% sure what "Max" is, so while g(y) remains a constant, it is left to players to decide (though if it is a constant, then changing P appropriately can have the same effect as adjusting "Max").

I am not sure if there is a way to make g(y) dynamic. If you tie it to influence output, then it would seem like a punishment on people who actually improve their influence game. On the other hand, f(x), it being a punishment on number of colonies you have, is actually the intended feature.

Now, the aim is to improve early game, right? So why not introduce a time component in the cost function? Well, maybe. But then you'd get an effect where empire that does not expand, or does not improve their influence game in other way, eventually crumbles. Well, maybe that would be an interesting feature, but don't know. Of course this could be something adjusted to some max number of turns, now that sounds better. This would need to tie generally to some "game pace" setting in general. But I don't have any concrete proposals at this time, just an idea.

But playing with actual time component seems too tricky to me. There are already implicit things about it - research takes time, colonization takes time... Population growth takes time... Function on number of owned planets f(x) has this baked in a bit, with the assumption that number of planets relates to time, but then if you lose planets... you don't actually go back in time, do you? So would the time component still make sense anyway? To distinguish between small empires and early empires directly?

Influence part has some baked in time component, too, but in terms of research, unlocking polices, finding interesting planets etc. Maybe we should have some relatively late game but cheap research option to improve influence/lower cost per planet, flat, to better distninguish between early empires and late but small empires? But then you'd adjust your Max accordingly, making early game even harder, then you'd need to perhaps still improve early game in other way. And such boost would boost large empires as well... So need to figure out how to boost smaller empires comparatively better (flat boost? some nonlinear function actually better for smaller empires?)

In the end, I would first go thinking in terms of shape of the curve of usable planets. That's why I was showing the graphs earlier etc. sqrt(%planets) seems actually punishing for the early game to me, because smaller empires have comparatively lower percent of usable planets, not only because soft cap is hit sooner. So initial expansion is actually punished relatively more, up to the sweet spot, the soft cap, where any expansion is punished just in general in terms of usable planets. Maybe that's the graph I should be showing. Conversely, squaring the % of galaxy owned makes you have comparatively more usable planets in the early game than late game, but it also moves the soft cap. But we could be using a curve that rewards initial expansion more/gives relative boost for smaller empire in % of usable planets (I appreciate such curve could also be some kind of policy that shifts "wide" towards "tall", giving even better % to small empires).

I could give a think about a better curve, if there is interest? I may have a think even if there is no interest :P Something with inflection point... So while percent of usable planets drops as you acquire new planets, it drops slower at start.

I gave some initial think at least to show what I am talking about, below is number of usable planets for galaxy size 200 with sqrt of percentage of galaxy owned, just percentage of galaxy owned, and my "secret function" that is along what I'm thinking. Like the "secret function" on this example soft caps even faster, but at higher number of planets than sqrt (lower than "just x"), and at first it has better ratio of productive planets to owned planets than sqrt or "plain x"
Attachments
curves.png
curves.png (23.01 KiB) Viewed 733 times

User avatar
Oberlus
Cosmic Dragon
Posts: 5715
Joined: Mon Apr 10, 2017 4:25 pm

Re: Fixing Influence - any ideas welcome

#80 Post by Oberlus »

BlueAward wrote: Tue Aug 16, 2022 12:11 pm my "secret function"
The curves for that equation are great.
Please! What is it? Logistic? Sigmoid?

BlueAward
Vacuum Dragon
Posts: 646
Joined: Mon Aug 08, 2022 3:15 am

Re: Fixing Influence - any ideas welcome

#81 Post by BlueAward »

Oberlus wrote: Tue Aug 16, 2022 12:19 pm
BlueAward wrote: Tue Aug 16, 2022 12:11 pm my "secret function"
The curves for that equation are great.
Please! What is it? Logistic? Sigmoid?
Well yeah I wanted the ratio of usable planets to be sigmoid, and I shifted it a bit to the left. I toyed with logistic function though the one at the chart is tanh (very related)... Was bit easier to work with. But it was bit hard to translate into cost per colony, perhaps something more like 1/sqrt(1+x^2) or what is there for population growth 1/(1+x) would be easier. Dunno. Need more time to think on this, particularly if it could be a nicely parametrized version translated to cost per colony

User avatar
Oberlus
Cosmic Dragon
Posts: 5715
Joined: Mon Apr 10, 2017 4:25 pm

Re: Fixing Influence - any ideas welcome

#82 Post by Oberlus »

BlueAward wrote: Tue Aug 16, 2022 12:50 pm Need more time to think on this
Granted.
Once you find the function you like the most, I'll enjoy implementing and playtesting it. I already made a PR for another function, sqrt(x/size). You could make your own if you like, or I can update mine.

Daybreak
Vacuum Dragon
Posts: 641
Joined: Mon Aug 13, 2018 10:14 pm

Re: Fixing Influence - any ideas welcome

#83 Post by Daybreak »

BlueAward wrote: Tue Aug 16, 2022 12:11 pm Daybreak, I understand that you are proposing playing with the g(y) part. However, what you are proposing seems dangerously close to g(y) meaning "average influence per planet you are able to muster at the given time". So yes, it is possible to factor into the equation, but it actually factors out of the equation entirely the "average influence per planet" part. Not only if your start was good or not, but also if you bother in any way to have your influence game improved or not. This is concern expressed by Oberlus

Now, we are not 100% sure what "Max" is, so while g(y) remains a constant, it is left to players to decide (though if it is a constant, then changing P appropriately can have the same effect as adjusting "Max").

I am not sure if there is a way to make g(y) dynamic. If you tie it to influence output, then it would seem like a punishment on people who actually improve their influence game. On the other hand, f(x), it being a punishment on number of colonies you have, is actually the intended feature.
At a certain ratio of IP planets to other planets, you could assume that it is based on the player obtaining or being a better influence species, however not punishment but a brake early on, and a lenient brake, being harder on the player the more the ratio dropped. Vica versa if the ratio of IP planets was high to other planets then it would be a little lenient.
However I get that is counter intuitive to the whole purpose of influence, but felt if it was tied in with galaxy size, so the more planets you colonised then the less, both these factors came into play. which would mean that smaller players continued to get these benefits or brake.
The brake part is then a problem later on for smaller empires, with good influence, which over time improves due to policies, and buildings, which is less than desirable.

I also liked your thoughts on time, and wondered if applied above, that as time increased, these factors reduced in severity (benefits or brake), which would fix the problem of smaller empires if they had better influence in the later game.

I then had the thought that time does not have to be actual time, but a ratio of settled planets against total planets. ie as the galaxy is settled, then we know more time has passed, the more settled the more time has passed, and we could apply it, against all empires, based on the settled galaxy. In other words, removing any benefit or brake in a linear progression based on the ratio of settled planets to available planets. That would also mean that an empire gobbling up to much territory, would suffer tougher requirements for influence, while improving other empires influence.

Anyway I will bow out of the rest of this conversation as it appears you have a solution, but thank you BA for looking at it.

User avatar
Oberlus
Cosmic Dragon
Posts: 5715
Joined: Mon Apr 10, 2017 4:25 pm

Re: Fixing Influence - any ideas welcome

#84 Post by Oberlus »

BlueAward wrote: Tue Aug 16, 2022 12:50 pm
Oberlus wrote: Tue Aug 16, 2022 12:19 pm
BlueAward wrote: Tue Aug 16, 2022 12:11 pm my "secret function"
The curves for that equation are great.
Please! What is it? Logistic? Sigmoid?
Well yeah I wanted the ratio of usable planets to be sigmoid, and I shifted it a bit to the left. I toyed with logistic function though the one at the chart is tanh (very related)... Was bit easier to work with. But it was bit hard to translate into cost per colony, perhaps something more like 1/sqrt(1+x^2) or what is there for population growth 1/(1+x) would be easier. Dunno. Need more time to think on this, particularly if it could be a nicely parametrized version translated to cost per colony
What about pure logistic formula for the f(x), the function on number of planets x you have, with the logistic growth factor around four 3?
https://www.wolframalpha.com/input?i=y% ... B0%2C+1%5D
I was able to skew it to the right increasing the factor of the exponent, e.g. (4x-3) insteaf of (2x-1), but I couldn't find how to skew it to the left without making the right part too close to 1 too early.
There must be another version that allows to control the skew and stepness of each side independently?

Edit: growth factor 4 is too much, makes unnecessary to set any planet to influence until too late IMO. A value of 3 seems better balanced.

BlueAward
Vacuum Dragon
Posts: 646
Joined: Mon Aug 08, 2022 3:15 am

Re: Fixing Influence - any ideas welcome

#85 Post by BlueAward »

Oberlus wrote: Tue Aug 16, 2022 3:51 pm
What about pure logistic formula for the f(x), the function on number of planets x you have, with the logistic growth factor around four 3?
https://www.wolframalpha.com/input?i=y% ... B0%2C+1%5D
I was able to skew it to the right increasing the factor of the exponent, e.g. (4x-3) insteaf of (2x-1), but I couldn't find how to skew it to the left without making the right part too close to 1 too early.
OK you made me realize I was overcomplicating things. I had some trouble figuring out cost per colony. I was thinking in terms of ratio of "productive" i.e. non-influence-focused planets. But if I think in terms of ratio of planets requiring to be set to influence, then such f(x) plugs in directly into the formula of cost per colony! Because it scales cost-per-colony defined by "P*g(y)" (where g(y)=Max=8 or 9) - if it is 1.0 then all colonies will need to be on influence, if it is 0.5 then half colonies etc.

Moreover, if I'm thinking about the f(x) in the domain [0;1] , then it is a function on a ratio of owned universe! So in your original proposal of scaling things to universe size, the function is simply f(x) = x, and you actually plug in x = owned_planets/total_planets. And subsequently we were thinking of f(x) = sqrt(x), but you again plug in x = owned_planets/total_planets

Now that is a much simpler look at things! Maybe you did have this look to begin with, but I did not realize it

So, were you testing your sigmoid literally as I described? Treating it as colony cost, and plugging in x=owned_planets/total_planets?

Anyway, one thought - the function can be specified on the domain [0;1] whatever way. You can use max of multiple functions, you can specify one function on the domain [0; 0.5] and another on the domain (0.5; 1], just making sure they have same value at 0.5 (but don't have to be smooth in differential sense).

Also, a function over [0; 1] that does not return 0 for 0 and 1 for 1 may be scaled to do so

For logistic function, it has three parameters like on wiki https://en.wikipedia.org/wiki/Logistic_function

f(x) = L/(1+e^(-k(x-x_0))

If you want it to return values (0; 1) then L = 1.0

x_0 is the midpoint so this is what controls the "skew". If it is 0.5, then midpoint is at 50%

k is what controls steepness

In your example you're conflating both x_0 and k into one value, so it's like you have x_0 = 0.5 (the midpoint) and steepness is 6. You may want to try those independently, but indeed moving the midpoint without scaling the ends closer to points (0;0) and (1;1) at both ends may leave too many planets initially required on influence, or too many planets at the end left free not to.

The example I plotted would be this:

https://www.wolframalpha.com/input?i=pl ... B0%2C+1%5D

so it's the logistic function with some made up parameters where steepnes is for some reason 4 π and mid point at 0.375 (which was 75 planets out of 200)

https://www.wolframalpha.com/input?i=y% ... B0%2C+1%5D

BlueAward
Vacuum Dragon
Posts: 646
Joined: Mon Aug 08, 2022 3:15 am

Re: Fixing Influence - any ideas welcome

#86 Post by BlueAward »

something just slightly better than f(x)=x would be a variation on f(x) = x/(1+abs(x)) which when rescaled is this:

https://www.wolframalpha.com/input?i=pl ... B0%2C+1%5D

It should have a soft cap at x≈44% owned universe, which would be roughly 25.7% (of total universe) productive planets

https://www.wolframalpha.com/input?i=ma ... B0%2C+1%5D

Another based on rescaled f(x) = x/sqrt(1+x^2):

https://www.wolframalpha.com/input?i=pl ... 5B0%3B1%5D

This one has soft cap at 47% owned universe, ≈25% of total universe productive planets

https://www.wolframalpha.com/input?i=ma ... 5B0%3B1%5D

If you have a feeling what should be the soft cap then some curve could be fitted to these 3 points (0,0), (1,1) and (soft_cap_ratio_universe_owned,soft_cap_ratio_of_influence_planets).. ideally some curve that makes sense (and would allow some customization)

But I still like more the logistic one, and that one without much thought just based on plot of count of productive, soft caps at 29.6% of owned total planets, where 21.6% would be productive (but you may say that's too many productive compared to owned at soft cap)

https://www.wolframalpha.com/input?i=ma ... B0%2C+1%5D

wobbly
Cosmic Dragon
Posts: 1880
Joined: Thu Oct 10, 2013 6:48 pm

Re: Fixing Influence - any ideas welcome

#87 Post by wobbly »

A bit of a side note, what I dislike most as a player, is the jolting nature of the current system. It goes from no problem to a problem very quickly. Sometimes it's gaining multiple colonies in 1 turn. Suddenly you shift from a healthy plus to a big drop as every colony you own increases in cost.

I'm not sure there is much that can be done about it in an exponential system.

Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Fixing Influence - any ideas welcome

#88 Post by Ophiuchus »

wobbly wrote: Wed Aug 17, 2022 7:40 am A bit of a side note, what I dislike most as a player, is the jolting nature of the current system. It goes from no problem to a problem very quickly. Sometimes it's gaining multiple colonies in 1 turn. Suddenly you shift from a healthy plus to a big drop as every colony you own increases in cost.
I guess that could be handled partly by better GUI? Like a sitrep every turn or every turn before a colony building is built. Telling expected how much influence upkeep will be and how much it changes taking into consideration
  • all colony buildings which will be finished next turn and existing colony buildings (which will establish a colony next turn) and colony ships set to colonize - this is what you certainly get if you do not change anything right NOW
  • all colony ships set to colonize + all currently queued or built colony buildings - this is what you get later if you do not change anything
  • all currently queued or built colony ships and colony buildings + all your colony ships and colony buildings - this is what you get if you also use all your colony ships for colonisation
also this info should go to the galaxy window influence tab.

on using different formulas for influence upkeep - the more complicated the formula is the better the GUI has to be (and it might still not be worth it). E.g. influence upkeep per colony constant 1 does not need much explanation; I think logistic formula in general is still intuitive for humans - although it might be hard to know where you are in the curve currently. For an arbitrary formula, one (that means you guys) would need to e.g. add a curve plot to the GUI.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Oberlus
Cosmic Dragon
Posts: 5715
Joined: Mon Apr 10, 2017 4:25 pm

Re: Fixing Influence - any ideas welcome

#89 Post by Oberlus »

BlueAward wrote: Tue Aug 16, 2022 7:27 pm So, were you testing your sigmoid literally as I described? Treating it as colony cost, and plugging in x=owned_planets/total_planets?
Yes (I think...)

Now I'm plotting ratio of total planets that are productive, with x - x*logistic(owned/total).
It is misleading that I didn't factor in the suboptimal influence output of younger planets or underdeveloped empires, so when you see that for small x% of the galaxy you get almost 100% of those planets free for production, that's not true.


My interest is on finding a good balance between available planets for the winning empire vs the losing empire.
Scenarios:
- A: One empire with 75% vs one empire with 25%.
- B: One empire with 66% vs one empire with 33%
- C: One empire with 80% vs two empires with 10%
- D: One empire with 50% vs two empires with 25%
- E: One empire with 50% vs five empires with 10%
- F: Two empires with 25% vs four empires with 12.5%

Using steepness 10 and skewness 2/3:

https://www.wolframalpha.com/input?i=ma ... B0%2C+1%5D

A: 24% vs 24%, but tech lead advantage for winner.
B: 32% vs 32%, but tech lead advantage for winner.
C: 18% vs 20% (2*10), but tech lead advantage for winner.
D: 42% vs 48% (2*24), but tech lead advantage for winner.
E: 42% vs 50% (5*10), but tech lead advantage for winner.
F: 48% (2x24) vs 48% (4x12), but tech lead advantage for winner alliance.

What I extract from those ad hoc comparisons:
Being the empire that has more planets is always good, both when fighting a single enemy or an alliance of smaller enemies.
For most of the early game, most of the planets w

With skewness to the left, the number of available planets is too low IMO, and I prefer to playtest something that allows faster game pace.
With higher steepness the number of available planets at end game is too small (I prefer faster end-game).
With smaller steepness the number of available planets at end game is too big (making resistance futile from too soon).

I think I'm going to commit this version...

User avatar
Oberlus
Cosmic Dragon
Posts: 5715
Joined: Mon Apr 10, 2017 4:25 pm

Re: Fixing Influence - any ideas welcome

#90 Post by Oberlus »

Ophiuchus wrote: Wed Aug 17, 2022 8:06 am
wobbly wrote: Wed Aug 17, 2022 7:40 am A bit of a side note, what I dislike most as a player, is the jolting nature of the current system. It goes from no problem to a problem very quickly. Sometimes it's gaining multiple colonies in 1 turn. Suddenly you shift from a healthy plus to a big drop as every colony you own increases in cost.
...
Let's see how it goes with the newer upkeep function.

Post Reply