Darwinbots Forum

Code center => Suggestions => Topic started by: Numsgil on February 23, 2005, 12:00:14 PM

Title: More realistic mutations
Post by: Numsgil on February 23, 2005, 12:00:14 PM
The idea behind this is simple:

A bot is more likely to have sharenrg mutate into sharebody than it is to have sharenrg change to shootval.

The machinery for sharing nrg is closer to sharing body than most other commands.  So in the mutations code, we assign probabilities for one thing to change into another thing, instead of having them more or less equal.
Title: More realistic mutations
Post by: PurpleYouko on February 23, 2005, 12:03:23 PM
Now that is a kick-ass idea.

We will probably have to subdivide all of the commands into catagories then give the highest probability of a mutation within the same catagory and a much smaller chance of crossing to a new one.

Like it

 :D  PY  :D
Title: More realistic mutations
Post by: Numsgil on February 23, 2005, 12:05:18 PM
I have a printout of the sysvars where I group similar commands as a reference.  Maybe I can use that to create a probability table or similar sysvars.
Title: More realistic mutations
Post by: Endy on February 23, 2005, 04:39:56 PM
Any way to "normalize" the numbers that mutations come up with?

I get stuff like:

cond
*.refaim 31056 !%=
start
etc.
stop

All the time. Presumably this is because these don't carry any serious penalities, but at the same time they don't exactly hit on any values even vaguely close to normal for the commands.

Endy ;)
Title: More realistic mutations
Post by: Numsgil on February 23, 2005, 04:48:27 PM
I'd love to but I have no idea how to even start.

I can use modular math for numbers stored in things like setaim.  That helps things a little.  But it still doesn't solve the problem of wierd condition comparisons.
Title: More realistic mutations
Post by: PurpleYouko on February 23, 2005, 04:52:25 PM
It can be fixed but it involves a lot of very specific conditions.
In order to stop the program from returning stupid numbers in things that can only use numbers in specific ranges, you first have to identify what memory location stuff is being put into and then apply limits to the input value.

Lots and LOTs and [span style=\'font-size:14pt;line-height:100%\']LOTS[/span] of code.

 :unsure:  PY  :unsure:
Title: More realistic mutations
Post by: Endy on February 23, 2005, 10:19:06 PM
Oh well. :unsure:

Maybe we can just think of it as junk dna, which could eventually develope into something more useable.

Endy ;)
Title: More realistic mutations
Post by: PurpleYouko on February 24, 2005, 09:26:58 AM
One thing we could easily change is to reduce the random number that will be put into the DNA on mutation.
I can't really think of any DNA command that can take a number higher than 1256. (correct me if you can think of one) So why are numbers as high as 32000 being put there?

This random number can be limited to a range of -1256 to +1256 which will give more chance of usable mutations.

 :D  PY  :D
Title: More realistic mutations
Post by: Botsareus on February 24, 2005, 10:28:17 AM
HOW ABOUT OUR HIP RANDOM NUMBER IS EQUAL TO: = Choose(Int(Rnd * 3) + 1, Int(Rnd * 10), Int(Rnd * 255), Int(Rnd * 20000)) * IIf(Int(Rnd * 2) = 0, -1, 1)

'One/Three low values
'One/Three mid values
'One/Three huge values
'One/Two Negative or Posetive

'Good Game Huge numbers problem
Title: More realistic mutations
Post by: Numsgil on February 24, 2005, 12:44:56 PM
Boyancy goes up to +/-2000.  (setboy)

I definately think it should be an option in the mutations panel.  Some masochists might decide that 32000 is a great number for mutations!



Bots, can you break down your statement into several smaller ones?  No need to optimize it yet  :rolleyes:
Title: More realistic mutations
Post by: Guest on February 24, 2005, 03:07:13 PM
Dim a as integer
Dim b as integer
Dim c as integer
Dim d as integer

a = Int(Rnd * 10)
b = Int(Rnd * 255)
c = Int(Rnd * 20000)
d = IIf(Int(Rnd * 2) = 0, -1, 1)

theoutput = Choose(Int(Rnd * 3) + 1, a, b, c) * d

'theoutput is the final output
Title: More realistic mutations
Post by: Numsgil on February 24, 2005, 03:11:06 PM
Ah, much better.  Now I can see how it works.   :D
Title: More realistic mutations
Post by: Botsareus on February 24, 2005, 03:14:31 PM
Again I forgot to logon , great

Dont forget to add Randomize unless ofcorse its already there

This way we can have better chance of having small numbers without worrying about not having big numbers, theoutput is the final output

ranges for "a" , "b" , and "c" can be tweaked by PY and NUM, make "b" match the length of sysvars for example; I don’t recommend tweaking the range for "a" , I like it like that its a good range for that .shoot command

***
Well? Did you try it Num? Does PY like it too?
Title: More realistic mutations
Post by: Numsgil on February 24, 2005, 04:13:21 PM
I started replying but then I had to look up a link and I got distracted.   <_<

This is an attempt at a gaussian distribution, right?

An interesting technique, did you come up with it yourself?

trying to do rnd * 2 to come up with a random bit has some subtle flaws (the distribution can be off).

Check this link on random numbers. (http://lib-www.lanl.gov/numerical/bookcpdf.html)

Chapter 7.
Title: More realistic mutations
Post by: Botsareus on February 24, 2005, 05:03:46 PM
Yes I did. So can we apply it to the problem for more realistic mutations ?

lest time I checked "IF int(rnd*2)=0" worked fine , checking now to be sure...

Nice link but I think I will Invent stuff myself before I find what I am looking for in there....
Title: More realistic mutations
Post by: Botsareus 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
Title: More realistic mutations
Post by: Botsareus 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
Title: More realistic mutations
Post by: Numsgil 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).
Title: More realistic mutations
Post by: Botsareus on February 24, 2005, 05:52:26 PM
whats wrong with the test I just posted?
Title: More realistic mutations
Post by: Numsgil 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).
Title: More realistic mutations
Post by: Botsareus on February 24, 2005, 05:56:40 PM
ok true random is not un-random in any way ;;
Title: More realistic mutations
Post by: Botsareus 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
Title: More realistic mutations
Post by: Numsgil 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.
Title: More realistic mutations
Post by: Numsgil 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.
Title: More realistic mutations
Post by: Botsareus 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 (http://s9.invisionfree.com/DarwinBots_Forum/index.php?showtopic=96)

---
So we are going to use my method or not? , its not too bad...
Title: More realistic mutations
Post by: Numsgil 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 (http://anywherebb.com/noctis.html).  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.
Title: More realistic mutations
Post by: Numsgil on February 24, 2005, 06:21:22 PM
I'm running statistical tests on your bit generation method now, Bots.
Title: More realistic mutations
Post by: Botsareus 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.
Title: More realistic mutations
Post by: Numsgil 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).
Title: More realistic mutations
Post by: Botsareus 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
Title: More realistic mutations
Post by: Numsgil on February 24, 2005, 07:10:58 PM
It's a little too piecemeal for my tastes.  We want a continuous function that takes a single input.

Here's an article on using calculus to get more realistic distribution patterns. (http://www.gamedev.net/reference/articles/article1337.asp)

That's the kind of techniques I'd use to find a good gaussian curve generator.
Title: More realistic mutations
Post by: Botsareus on February 24, 2005, 07:43:23 PM
ok , if you can give me better [you]vb[/you] code then I already posted , go ahead:


---
But (I think) you do agree that applying more advanced number generation Techniques is the solution to the following problem:

Endy:
Quote
Any way to "normalize" the numbers that mutations come up with?

---
I will try to make some heads-or-tails(figure out) of that Calculus generating galaxies link
Title: More realistic mutations
Post by: Numsgil on February 24, 2005, 08:03:08 PM
It's pretty heavy math when it explains it, so if you don't know basic integral calculus it won't make any sense.

Give me the night.  I'll come up with a gaussian curve in the morning.
Title: More realistic mutations
Post by: Botsareus on February 25, 2005, 11:40:53 AM
We dont really need a perfict curve here , I think my:

Choose(Int(Rnd * 3) + 1, Int(Rnd * 10), Int(Rnd * 255), Int(Rnd * 20000)) * _
((Int(Rnd * 2) * 2) - 1)

gets the job done. If we plot it , will look more like a step latter though.
Title: More realistic mutations
Post by: PurpleYouko on February 25, 2005, 11:55:14 AM
I hate calculating gausian curves   :angry:

 :unsure:  PY  :unsure:
Title: More realistic mutations
Post by: Botsareus on February 25, 2005, 12:14:33 PM
The more good on using my equation , I already "calculated" it
Title: More realistic mutations
Post by: Anonomous Guest Person on March 14, 2005, 10:34:41 AM
Er, not to sound simple or dumb, but you could a random number between one and one million, take it's square root, and subtract 1000 by it, then add or subtract the total value.
Or in mathematical/programming form:
1000-(sqrt(rand()*1000000))
That'd certainly make it be in favor of smaller values. In fact, the chances of it changing by a mere one is  1/500, while as increasing/decreasing by 1000 is a full 1/1000000.
(And of course there'd be a safety system to make sure it doesn't get higher then 1000.) (And also, of course, it'd be rounded too.)
Title: More realistic mutations
Post by: Botsareus on March 16, 2005, 01:02:45 PM
A.G.P. as Num will say :"There is a problem with your logic"

1) At high ranges there are "gaps" in the numbers beings generated

2) It does not generate any negative numbers
(There must be a 50/50 chance of a negative or a postitve number being generated)

Quote:
"And of course there'd be a safety system to make sure it doesn't get higher then 1000.) "

The whole point of the system we are brain storming about is that it has no range limit because there is a high chance that the number will be low range anyway.
Title: More realistic mutations
Post by: Anonomous Guest Person on March 16, 2005, 04:56:11 PM
1. ?
2. Read it better. That's how much it'll add or subtract, not how much it'll add. That's just the basic theory, and it's rather stupid to ignore an idea simply because it's not detailed enough. I just suggested it because no one seemed to have brought it up.

And also, I more or less meant a safety system with store, and inc, and etc. so that if the targeted memory location is greater then 1000, then it'll divide it by 1000 and use the remainder. Though now that I think about it, that'd reduce all the junk DNA, and possibility of genetic diseases, so it might not be as good as I previously thought it was to implement.
Title: More realistic mutations
Post by: Botsareus on March 16, 2005, 05:14:00 PM
"That's how much it'll add or subtract, not how much it'll add." you are saying we have an exsisting number and we change it.

My idea is totaly different: The number itself is replaced with a completly new number.

I can see how your idea will work now, Its not a bad idea, still a high range number in your idea will remain a high range number if it changes by a small value.
Title: More realistic mutations
Post by: Anonomous Guest Person on March 16, 2005, 05:18:50 PM
Hm. Then on the account of that, I say we have two types of changing a value.
Relative changes, and relative-to-0 changes.
The former would be limited to small changes with an improbability of having a very very large change.
I dunno how the other one'd work though. :P
Title: More realistic mutations
Post by: Botsareus on March 16, 2005, 05:43:32 PM
Choose(Int(Rnd * 3) + 1, Int(Rnd * 10), Int(Rnd * 255), Int(Rnd * 20000)) * _
((Int(Rnd * 2) * 2) - 1)

"not relative to 0" , just a new value every time.