I have been working on a simulation of a wildlife area with realistic population growth and statistics however I am getting weird values for some of my variables.
I am first trying to estimate the growth rate (r) from the amount of births (b), deaths (d) and current population (pop) using the formula
r = (b - d)/pop
Then I find out the number of individuals added from the carrying capacity (k), growth rate and current pop using this formula
New pop = (pop X r)((k - pop)/k) + pop
I have tested this out in excel with various different types of input data and it works in the spreadsheet, however when I plug it into UE4 I get a growth rate of 0 and even when I set the growth rate to a particular number ie 0.49, I still get a return of 0 added to the population ie no growth recorded.
I have my variables are set as follows in unreal
r = .49
b = pop X .49
d = 30 (deaths are added based on how many are eaten throughout the year by predators, but for now I have put as a value of 30)
pop = 500
k = 3000
I strongly suspect I have put them in wrong as I’m reasonably new to unreal, but any help would be greatly appreciated
Really hard to tell.
But here is something you’ll have to address eventually anyway (which might also be the problem now) float point precision in BP.
Meanwhile… are you dividing by 1 to get a whole and a remainder?
if you only need the integer you could Floor the result…
A bigger picture would be appriciated. offhand. Why +
3000-buffalo pop / 3000 ?
lastly. Try printing out the result of buffalo pop x .49 direct to see if buffallo pop is not 0.
0 x .49 is??? 0
ergo, if you print out 0, you forgot to initialize your default value for the buffalo pop variable.
Hi, thanks for the reply,
I’ll have a look at precision point in BP and see if this may be an issue. Also thanks for the tip on Floor, will use that in the future.
I am trying to use a logiitic population growth model which is used in ecology to estimate how quickly it will take for the current population to reach its carrying capacity or number of animals the area will sustainably hold… Here’s a really well explained youtube video on how the equation works if you have 10 minutes, though he explains how to use the formula 5 minutes in.
For this I had put my current population of buffalo at 500 and decided the carrying capacity would be 3000. I will probably change 300 (carrying capacity) to a variable as I intend to make it change based on weather patterns ie drought.
I have managed to get the Set BuffaloBirths equation to perform correctly though, which is why I’m confused