[SOLVED] Looking for a (mathematical) growth function

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
ObscureScience
Prole
Posts: 2
Joined: Mon Dec 21, 2015 11:57 pm

[SOLVED] Looking for a (mathematical) growth function

Post by ObscureScience »

Hello

I'm currently trying to prototype a RTS/Civ-like game based on statistical simulation of populations. To make it a RTS I indend to have part of the population be manifested as controllable units. So what I'm trying to achive is to have a good function to calculate the number of representatives available at a certain population size.

I'm not "good" at math but I think I want something similar to a logarithmic function, so the number of them grows slower the bigger the population.

What I currently have is just that,

Code: Select all

math.floor(math.log(popSize))
but I'm not satisfied with the results. I guess I want some modifiying factor (that is also a function) so that the growth isn't as fast in the beginning but pans out slower, but I haven't been able to express it. I'm leaning to having the "popSize" be shapingFunc(popSize), however it would be defined.
An estimation of how I want it to look
  • popSize: representants
  • <10 : 1-2
  • <100 : 5-10
  • <1000 : 10-20
  • <1000000 : 100-200
I'm also sure this is quite trivial with someone math training, which I would think a lot of you have. Thank you for any pointers!
Last edited by ObscureScience on Wed Dec 23, 2015 9:37 am, edited 1 time in total.
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Looking for a (mathematical) growth function

Post by davisdude »

Here's what I got:

Code: Select all

math.floor( math.log10( popSize ) ^ 2.75 )
Mostly keep in mind the parent graphs. If you want you could try getting really technical and solving for some equation, but I just interpolated values until I got it close enough.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: Looking for a (mathematical) growth function

Post by pgimeno »

Here's my attempt:

x^0.33333333

That returns:
100 for x = 1,000,000
10 for x = 1,000
4.64 for x = 100
2.15 for x = 10
User avatar
deströyer
Prole
Posts: 32
Joined: Thu Jun 27, 2013 7:59 pm
Contact:

Re: Looking for a (mathematical) growth function

Post by deströyer »

I would recommend using a table of breakpoints rather than a formula. This is way more readable and gives you better control for balancing.

Few people have the math chops to look at a formula like math.floor( math.log10( popSize ) ^ 2.75 ) and intuit what a population of 7,000 would give you - I certainly don't! How would you for example fix this formula if it works fine for the first 10,000 inhabitants and then becomes broken?
ObscureScience
Prole
Posts: 2
Joined: Mon Dec 21, 2015 11:57 pm

Re: Looking for a (mathematical) growth function

Post by ObscureScience »

Thanks a lot for the help. I'll try these ideas out for a bit before I tag this as solved.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 34 guests