Tutorial :Looking for interesting formula



Question:

I'm creating a game where players can make an alloy. To make it less predictable and more interesting, I thought that the durability and hardness of an alloy should not be calculated by a simple formula, because it will be extremely easy to find extrema, where alloy have best statistics.

So the questions is, is there any formula for a function where extrema can be found only by investigating all points? Input values will be in percents: 0.0%-100.0%. I think it should look like this: half sound wave


Solution:1

A very simple way would be a couple of sin function, just vary the constants and the sign for each new player. Here is one example (sin(1.1*x) + sin(x) + sin(0.9 *x))^2 alt text http://i43.tinypic.com/k1ph80.gif
If you use this between 10pi and 20pi you have an by average increasing function with local minima.


Solution:2

Modulating a simple linear or exponential function with trigonometric functions whose frequency and amplitude are dependent on the input should get you what you want.


Solution:3

You don't need a formula, I think â€" throw a bunch of random values around your domain, and then interpolate (linear interpolation will do) between them. Then you can even change the "formula" completely each time the game is run, or once in a while, or change it slowly with time, etc, etc.


Solution:4

If you want something that is very hard to predict then I would suggest involving a random number generator with the same seed every time. You can use it as an envelope for whatever function you come up with (trig functions or what not) to make it more jagged.


Solution:5

An interesting formula to use would be that of gamma of the Black-Scholes options pricing model. It goes as follows:

alt text
alt text
alt text
alt text

You can easily replace the variables, here's a graph of how the function looks:

alt text http://www.sqbimmer.com/aalex/gamma.png


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »