Author Topic: More realistic mutations  (Read 15015 times)

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
More realistic mutations
« Reply #15 on: February 24, 2005, 05:27:45 PM »
Yes that the correct formula, notice how the uncertainty in the following example becomes less and less. Btw you have to wait a good minute to see good results every 10 seconds:
Quote
Dim a As Long
Dim b As Long

Private Sub Form_Load()
On Error Resume Next
Randomize
Show
Do
If Int(Rnd * 2) = 0 Then a = a + 1 Else b = b + 1
If Int(Timer) / 10 = Int(Timer) \ 10 Then Caption = a / b ' should be one
DoEvents
Loop
End Sub

'Bling Bling Nothing wrong with this test , All GOOD
« Last Edit: February 24, 2005, 05:28:08 PM by Botsareus »

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
More realistic mutations
« Reply #16 on: February 24, 2005, 05:35:48 PM »
If you still dont like it try

negativeorpositive = (Int(Rnd * 2) * 2) - 1

this does not solve your issue but at least it does not use iif
« Last Edit: February 24, 2005, 05:36:53 PM by Botsareus »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
More realistic mutations
« Reply #17 on: February 24, 2005, 05:49:16 PM »
The problem with inventing things yourself is that it may not be random.  I'm not sure how to test if something is truly random, but the function must satisfy a stats test of some sort (chi-squared maybe?)  and have a large period (how long it takes to repeat itself).

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
More realistic mutations
« Reply #18 on: February 24, 2005, 05:52:26 PM »
whats wrong with the test I just posted?

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
More realistic mutations
« Reply #19 on: February 24, 2005, 05:53:30 PM »
Here's how values are currently changed in the program.  Notice that it uses a looping method of gaussian generation:

Public Function PiuMeno() As Integer
  PiuMeno = Random(0, 1)
  If PiuMeno = 0 Then PiuMeno = -1
End Function

Public Function Gauss(low, up) As Long
  For t = 1 To 10
    Gauss = Gauss + Random(low, up)
  Next t
  Gauss = Gauss / 10
End Function

k = DNA(t).value + PiuMeno * Gauss(1, DNA(t).value + PiuMeno * 10)
If k < -32000 Then k = 32000
If k > 32000 Then k = 32000
DNA(t).value = Int(k)


Bots, the problem I'm talking about needs a double or single to isolate.  Try your test code with a and b as singles, and you'll see your caption probably isn't exactly 1.000000000000000000.  Run it for ever, and it still won't be 1.00000000000000000000 even though it should be.  No randomizer is perfect.  That is what I'm talking about.  Some randomizers are much better at eliminating bias than others are, though.

Finding good methods to generate random numbers with no bias is Computer Science doctoral dissertation stuff.  It's big business.  It takes alot of math (more math than I know and I'm a math major).
« Last Edit: February 24, 2005, 05:55:22 PM by Numsgil »

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
More realistic mutations
« Reply #20 on: February 24, 2005, 05:56:40 PM »
ok true random is not un-random in any way ;;

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
More realistic mutations
« Reply #21 on: February 24, 2005, 06:03:29 PM »
If this method you showed me uses an old number to generate a new one , why does it still produce crazy huge numbers?

I say lets use my method and then apply Averaging rules to it

ex:

new.value = (old.value + random.value) / 2
« Last Edit: February 24, 2005, 06:05:24 PM by Botsareus »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
More realistic mutations
« Reply #22 on: February 24, 2005, 06:06:05 PM »
For most purposes, rnd * 2 is fine to generate random bits.  But if it is called alot, bias can accumulate.  Most programmers don't know this (or care).

I do because I was working on a game that allowed you to explore 200 billion stars, all their planets, and be able to land on those planets and explore, and all those planets had to be more or less unique.  (But that's a topic in and of itself.)

Check out the chapter on generating random bits in the link I gave you.  Chapter 7 also has some good sections on the kinds of test they run random generators through to detect period length.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
More realistic mutations
« Reply #23 on: February 24, 2005, 06:07:29 PM »
The gauss function in DB is a bit rigged, to be honest.

The game I talked about above ran into a similar problem (the shape of the galaxy seen on edge is a gaussian curve) so I have a few solutions I can try.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
More realistic mutations
« Reply #24 on: February 24, 2005, 06:11:52 PM »
Num did you know that I was planning to make the same game in the futcher and sell it, It would be Random only for Bounce stuff like new waird weapon systems you can steal from randomly generated Aliens...

The idea was the stuff is generated Randomly based on the location in the galaxy unless its stuff I put in manually for the main missions...

---
Thats a topic for the off topic board http://s9.invisionfree.com/DarwinBots_Foru...hp?showtopic=96

---
So we are going to use my method or not? , its not too bad...
« Last Edit: February 24, 2005, 06:20:48 PM by Botsareus »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
More realistic mutations
« Reply #25 on: February 24, 2005, 06:20:43 PM »
Like the old Elite series, right?

Psuedorandom games never took off like they should have.  Most games now are hand done.

Check out Noctis.  It's a game made in dos that has something like 100 Billion stars, each with planets, and you can LAND AND WALK ANYWHERE ON ANY PLANET.

Now, if you trawl through the forums you'll see people complain that some planets look alike (ie: identical) even though they are in different parts of the galaxy.  This is entirely due to a bias in the random number generator it uses.



If you thought your idea was original, I'm sorry to disabuse you.  It is as old as space games themselves.  Most space games don't go that route anymore, sadly.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
More realistic mutations
« Reply #26 on: February 24, 2005, 06:21:22 PM »
I'm running statistical tests on your bit generation method now, Bots.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
More realistic mutations
« Reply #27 on: February 24, 2005, 06:28:58 PM »
There is a post HERE  :rolleyes:  of a test that I alredy did, but if you wish to code your own go ahead.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
More realistic mutations
« Reply #28 on: February 24, 2005, 06:36:59 PM »
And what were your results?

Right now I have 8 million iterations and it's value is at 1.0004.

Which actually is pretty good (I think).

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
More realistic mutations
« Reply #29 on: February 24, 2005, 06:55:53 PM »
My little forms caption in my test after a minute went down to 1.00002 , not bad at all

but Num thats just a little part of my original equation , look at the big picture here  :D