loleris
|
  |
| Joined: 23 Feb 2009 |
| Total Posts: 1610 |
|
|
| 28 May 2013 07:07 AM |
So... I'm need of some sort random or not so random function for generating binary chaos from 3 variables: x and y coordinates and the seed.
...And I have no knowledge about random theories at all...
This is something I've tried to make right now:
function BinaryChaos(x, y, seed) return math.floor(math.abs(math.sin(((x * (0.5486 + seed)) - (y * (0.7872 + seed))))) + 0.5) end
Output: 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1
Basically, it only has to return 1 or 0 from those three variables. The main rule is that the same variables have to return the same binary value all the time.
Help?
|
|
|
| Report Abuse |
|
|
loleris
|
  |
| Joined: 23 Feb 2009 |
| Total Posts: 1610 |
|
|
| 28 May 2013 07:11 AM |
Last time I made something working:
function chaos(x,y,seed) x = x+10 y = y+10 seed = seed+10 while pos(x) >= 10 do x = x*0.43786 end while pos(y) >= 10 do y = y*0.57348 end while pos(seed) >= 10 do seed = seed*0.47569 end gen = math.sqrt(pos(x+y+seed)*33) return round(gen-math.floor(gen)) end
But it's REALLY slow. |
|
|
| Report Abuse |
|
|
loleris
|
  |
| Joined: 23 Feb 2009 |
| Total Posts: 1610 |
|
|
| 28 May 2013 07:13 AM |
I cleaned up the old version to work normally
function chaos(x,y,seed) x = x+10 y = y+10 seed = seed+10 while math.abs(x) >= 10 do x = x*0.43786 end while math.abs(y) >= 10 do y = y*0.57348 end while math.abs(seed) >= 10 do seed = seed*0.47569 end gen = math.sqrt(math.abs(x+y+seed)*33) return math.floor((gen-math.floor(gen))+0.5) end |
|
|
| Report Abuse |
|
|
loleris
|
  |
| Joined: 23 Feb 2009 |
| Total Posts: 1610 |
|
|
| 28 May 2013 07:14 AM |
The output of the older chaos function:
1 1 0 1 1 0 1 0 0 1 0 1 0 0 0 1 0 0 1 0 0 1 0 |
|
|
| Report Abuse |
|
|
loleris
|
  |
| Joined: 23 Feb 2009 |
| Total Posts: 1610 |
|
|
| 28 May 2013 07:29 AM |
| ...Just created a 2D image of my old chaos function... It's not chaotic at all ._. |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 28 May 2013 07:34 AM |
> "Not so random" > Perlin Noise?
Also, try looking up this kind of thing on WIkipedia. |
|
|
| Report Abuse |
|
|
loleris
|
  |
| Joined: 23 Feb 2009 |
| Total Posts: 1610 |
|
|
| 28 May 2013 07:36 AM |
| I asked only for a binary noise. |
|
|
| Report Abuse |
|
|
loleris
|
  |
| Joined: 23 Feb 2009 |
| Total Posts: 1610 |
|
|
| 28 May 2013 07:46 AM |
| ...Maybe it's impossible to make that function ._. |
|
|
| Report Abuse |
|
|