How to make a function with a diminishing return per iteration?

2018-05-26 9:40 pm
I'm working on a game, but I can't figure out how to do this. I want to make it so that the curve still increases, so if x = 9999 it will be dramatically higher than if it equals 1, but at the same time, I want each +1 to x to have less and less of a return.
f(x) = y
f(1) = 1
f(2) = 1.9
f(3) = 2.7
and so forth, as an example(Probably doesn't fit a real curve.)

回答 (2)

2018-05-27 12:04 am
✔ 最佳答案
You could use a log curve.

f(x) = 1 + log(x) using natural logs gives these values:
(1, 1)
(2, 1.7)
(3, 2.1)
(4, 2.4)
2018-05-26 10:19 pm
Many functions would work. One of them is y = ln(x). That can be shifted or stretched up/down, left/right, so the full function is y = A + B ln(Cx + D). Be careful of the sharp dip (or hole) at Cx + D = 0.

Another function to think about is y = atan(x), again with shifting/stretching as needed.


收錄日期: 2021-04-24 01:07:21
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20180526134039AATzsJZ

檢視 Wayback Machine 備份