Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for interesting formula

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

like image 589
Thinker Avatar asked Mar 12 '10 18:03

Thinker


4 Answers

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
If you use this between 10pi and 20pi you have an by average increasing function with local minima.

like image 148
Nifle Avatar answered Oct 21 '22 02:10

Nifle


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.

like image 40
Ignacio Vazquez-Abrams Avatar answered Oct 21 '22 02:10

Ignacio Vazquez-Abrams


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.

like image 26
AVB Avatar answered Oct 21 '22 02:10

AVB


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.

like image 1
Justin Peel Avatar answered Oct 21 '22 02:10

Justin Peel