Darwinbots Forum

Bots and Simulations => Evolution and Internet Sharing Sims => Topic started by: Elite on February 14, 2006, 05:15:57 PM

Title: Survival-of-the-fittest evobot
Post by: Elite on February 14, 2006, 05:15:57 PM
Had an idea for a new Evotbot.

The bot spends about 1000 cycles building up 20000 energy. It then fixes.
When it's fixed it spins and repros uncontrollably (and dies), producing many, many offspring.
All the offspring compete to the death and the fittest few survive. Lame bots do not survive.

I'm doing some fine tuning at the moment. Here's the prototype so far:

Code: [Select]
' Shoot
cond
*.eye5 0 !=
start
-6 .shoot store
stop

' Move
cond
*.eye5 0 !=
start
20 .up store
stop

' Spin
cond
*.eye5 0 =
start
314 rnd .aimdx store
stop

' Activate repro mode!
cond
*.nrg 20000 >
start
1 .fixpos store
stop

' Repro and spin ... get dizzy ...
cond
*.fixed 0 !=
start
314 rnd .aimdx store
10 .repro store
32000 .tielen1 store
stop

' Unfix if fixed and not at repro age
cond
*.fixed 0 !=
*.robage 1000 <
start
.fixpos dec
stop

end

Feel free to have a play around and see if you can get any good results  :D
Title: Survival-of-the-fittest evobot
Post by: Griz on February 14, 2006, 05:58:48 PM
one could create a few bots with initial different # of cycles for storing before repro ...
a shorter number of cycles giving a quicker turnover, with fewer offspring ...
have a cycles/energy of 500/10000, 750/15000, 1000/20000, 1250/25000, etc ...
and run them against one another, perhaps in a league situation to see
which species has more staying power, rather than the hightest population.
looking for the ideal balance point.
Title: Survival-of-the-fittest evobot
Post by: Ulciscor on February 14, 2006, 07:13:16 PM
Isn't this kind of going on the assumption that any of the offspring will get to the repro threshold?
Title: Survival-of-the-fittest evobot
Post by: Griz on February 14, 2006, 07:17:00 PM
found my bots gaining energy and reproducing in the normal
manner long before they reached their 'breeding age' which
then dropped them below the energy requirement and they
continued to roam about and gain seek more food.
so I commented out the energy requirement and made
repro dependant upon age only.

' Activate repro mode!
cond
'*.nrg 20000 >
*.robage 1000 >
start
1 .fixpos store
stop

also did a  *.robage 750 > and a *.robage 1250 >
[changed the 'unfix gene' as well]
called them SBD750 [StoreBreedDie], SBD1000, SBD1250
and run them off against each other.
interesting ... the 750 repros ahead of the others and more
often but of course produces fewer offspring before dying,
the 1250 taking a long time but with 60 or 70 offspring ...
and the 1000 inbetween.
did it with mutations disabled to watch the 'pure' form to see
which seems most hardy ...
but figure mutations might yeild some interesting hybreds.

fun to watch. ;)
Title: Survival-of-the-fittest evobot
Post by: Ulciscor on February 14, 2006, 07:25:39 PM
[Griz] - doesn't making repro dependant on age mean that the bots may be born with v low energy? This seems a little unfair... although I guess bots born to a parent with high energy have a greater chance of survival than those with lower.
Title: Survival-of-the-fittest evobot
Post by: Griz on February 14, 2006, 08:02:49 PM
Quote
[Griz] - doesn't making repro dependant on age mean that the bots may be born with v low energy? This seems a little unfair... although I guess bots born to a parent with high energy have a greater chance of survival than those with lower.
 
they may ...
as elite says ... survival of the fittest.
'tis an experiment after all ...
why bot let the bots determine what works or what doesn't?
if they can't hack it ... kiss 'em goodbye. ;)
anyway, these aren't regular bots ...
but elite's idea of having a punctuated reproduction.
those that survive their #of cycles get to reproduce
however many offspring they can support.

it's interesting to watch the spurts ...
a bot set to 500 cycles reproducing twice as often ...
but with half the offspring [or less anyway] than the
bot using a period of 1000.

so far, the longer period bots are winning out ...
but I imagine this might vary depending on which
others they have to compete against.
will see what mutations bring on.

it's interesting to watch ...
as one gets one reproducing at 500 cycles into the sim ...
as well as at 1000 along with a 2nd bot ....
and again at 1500 with both the 2nd and 3rd as well ...
so there are large spurts and all of that is dependant
upon the veggie population as well.

just experimenting.
run it and see for yourself

btw ... in version 2.37.6 ... I still have a lot of problem with
the population control ... NOT controlling.
the max limit seems to be ignored most of the time ...
my bot population usually ending up nearly double what I set ...
actually, as if it adds the max number and the repro level setting.
yet .. at other times, it seems to work.
iwo, I don't have much to say about it.
Title: Survival-of-the-fittest evobot
Post by: Endy on February 14, 2006, 10:44:37 PM
I tried something similar(*.robage 400 >) and they eventually evolved a method to survive better. They started using *.pleas instead of 50 as their Repro percentage. Neat little trick. B)
Title: Survival-of-the-fittest evobot
Post by: Numsgil on February 15, 2006, 12:48:17 AM
Quote
btw ... in version 2.37.6 ... I still have a lot of problem with
the population control ... NOT controlling.
the max limit seems to be ignored most of the time ...
my bot population usually ending up nearly double what I set ...
actually, as if it adds the max number and the repro level setting.
yet .. at other times, it seems to work.
iwo, I don't have much to say about it.
This is actually fairly normal.  More than double what you set means we have a real issue.  Limiting population fairly isn't as easy as you might think.

I know that's not really an excuse (well, I guess it sort of is actually), I'm just not sure exactly how to fix it without causing some odd biases.
Title: Survival-of-the-fittest evobot
Post by: PurpleYouko on February 15, 2006, 08:49:13 AM
The reason for this is the way in which the robots actually reproduce.

When the program comes across a repro command, it doesn't simply make that bot reproduce immediately as it would with .up or .shoot.
What happens is that a "pending" list of bots that are ready to repro is created. This list is then acted on in a completely seperate part of the program in a single loop that has no easy and fair way to prevent more births.

Basically we can disable reproduction of veggies quite easily when the veggie population exceeds a certain value. Trouble is that the program counts the actual veggie population at the beginning of each cycle to save on processor time. This means that either NONE of the veggies are allowed to reproduce on a given cycle or ALL of them can. It's really the only fair way or else reproduction enablement would be a function of arbitrary robot numbers (first born gets to breed while later ones don't). That would really suck for evolving veggies.

Just think of the maximum population as being the maximum threshold at which veggies are allowed to reproduce. If they all choose to do it on the same cycle then you can potentially get double the limit in actual population.

As Num said, If you get more than double then something is very wrong. Otherwise there ain't much we can do about it.
Title: Survival-of-the-fittest evobot
Post by: Griz on February 15, 2006, 10:10:36 AM
Quote
As Num said, If you get more than double then something is very wrong. Otherwise there ain't much we can do about it.

ah ....
ok, that makes sense.
no, I don't think it ever goes above 2x.

good to know it isn't just me. ;)

what settings then would you recommend for
max # of veggies:
threshold for repro:
number of veggies per repro event:
and the cooldown period:

if, for example, I wanted to maintain a pop around 100?
I'm looking to keep the population as steady as possiby
in some sims.
sometimes using 100, 99, 1, 1 for the above works fine.
at other times, it results in close to double that ...
so I go for 50,48,1,1 or something.

that's what throws me off ...
I don't seem to be able to have it work consistantly ...
I'm just looking for ways to have it be close to
what I would like to see. ;)

thanks
Title: Survival-of-the-fittest evobot
Post by: Griz on February 15, 2006, 10:12:00 AM
Quote
I tried something similar(*.robage 400 >) and they eventually evolved a method to survive better. They started using *.pleas instead of 50 as their Repro percentage. Neat little trick. B)
yeah.
will keep playing with them.
Title: Survival-of-the-fittest evobot
Post by: Griz on February 15, 2006, 10:19:53 AM
Quote
I tried something similar(*.robage 400 >) and they eventually evolved a method to survive better. They started using *.pleas instead of 50 as their Repro percentage. Neat little trick. B)
how do you go about seeing these changes, endy?
do you do periodic saves of all the bots?
or let it run for a period of time and then go in and look at
some of the mutated ones?
I haven't been able to find a good way to recognize and 'capture'
the bots that evlove.
what do you base your selection on?
age + offspring + energy ?????
without having to sort thru hundreds of saved bots?

I am most of all interested in 'evolved' bots so ...
just looking for hints about how to best go about finding them.

thanks
Title: Survival-of-the-fittest evobot
Post by: Elite on February 15, 2006, 11:20:38 AM
Wow, so many replies  :rolleyes:

Heres the latest version:

Code: [Select]
cond
start
.tie *.robage 1 add mult inc
.deltie inc
stop

cond
*.robage 1 =
start
628 .aimdx store
stop

cond
*.fixed 0 =
*.eye5 0 !=
start
-6 .shoot store
stop

cond
*.eye5 0 !=
start
40 .up store
stop

cond
*.eye5 0 =
start
314 rnd .aimdx store
stop

cond
*.robage 1000 >
*.body 500 >
start
1 .fixpos store
stop

cond
*.fixed 0 !=
start
314 rnd .aimdx store
100 *.nrg 500 div div 50 ceil .repro 1 rnd add store
stop

cond
*.fixed 0 !=
*.robage 1000 <
start
.fixpos dec
stop

end

Weaker bots are quickly killed by their more efficient siblings, weeding out 'bad mutations' much more effectively.
This version also randomly hyper-mutates half of its offspring for an increased flow of mutations into the sim. Most die but some do well.

This bot seems to produce lots of 'big bertha' type robots though.
Title: Survival-of-the-fittest evobot
Post by: PurpleYouko on February 15, 2006, 11:28:58 AM
Quote
what settings then would you recommend for
max # of veggies:
threshold for repro:
number of veggies per repro event:
and the cooldown period:

Try a nice in-between value of about 75 for max pop if you want a mean value of 100.

I never really mess with the others all that much. Cooldown period is largely irrelevent unless you have an exceptionally high veggie feed rate. It's going to take them a finite number of cycles to regain half of their energy anyway.

The biggest problem (IMO) is that all the veggies begin the sim at the same energy level, then they are fed at the same rate so they all want to reproduce on the same cycle. maybe we should randomize the feed amount within certain perameters.
For example, if you set feed rate per cycle to 10 then they will actually get a range from 8 to 12 instead of exactly 10.
You can also do this in the veggie DNA code by replacing the standard repro value with a custom variable that is randomly defined at birth

Try this little veggie out. It is a version of Alga minimalis fitted with a randomized reproduction level.
Title: Survival-of-the-fittest evobot
Post by: Elite on February 15, 2006, 11:43:14 AM
Here's another evobot I'm experimenting with. Good results so far.

Code: [Select]
cond
*.eye5 0 !=
start
-1 .shoot store
stop

cond
*.eye5 0 !=
start
20 .up store
*.eye6 *.eye4 sub .aimdx store
stop

cond
*.eye5 0 =
start
314 rnd .aimdx store
stop

cond
*.nrg 10000 >
start
10 .repro store
stop

cond
*.numties 0 >
start
32000 .tielen1 store
stop

end

Nice Alga, looks more natural  :)
Title: Survival-of-the-fittest evobot
Post by: Griz on February 15, 2006, 03:18:15 PM
re: veggie pop control

Quote
Try this little veggie out. It is a version of Alga minimalis fitted with a randomized reproduction level.
will do ... sounds like a good idea
Title: Survival-of-the-fittest evobot
Post by: Endy on February 22, 2006, 09:57:11 PM
Quote
how do you go about seeing these changes, endy?
do you do periodic saves of all the bots?
or let it run for a period of time and then go in and look at
some of the mutated ones?
I haven't been able to find a good way to recognize and 'capture'
the bots that evlove.
what do you base your selection on?
age + offspring + energy ?????
without having to sort thru hundreds of saved bots?

Sorry took so long. The night before the boat pulled out our free internet died :sad2:

Anyhow, normally I'll look closest at any mutant KingBots after the sim has been running awhile, any large groups of mutant bots with the same coloration, and any just plain weird/interesting bots.

If they're the king and it's been some massive number of cycles, chances are that they're a superior species; well adapted to their local enviroment.

If I see a new offshoot group start growing in numbers I try to see if they have a particularly useful mutation that makes it likely they'll continue to grow in numbers.

Anything that's just plain weird I'll either wait and see how the bot does on its own, or save it's dna and restart with it instead. You can sort of artificially select for the more interesting traits(if you artificially select artificial dna, exactly what are you doing? :D )

You can sort of track general family lines with the first two. A very brief snapshot of the whole species but well worth the look.

Anything oddball I see the bots doing I'll try and recreate it in a more stable manner. Works out pretty well adapting what evolution has found and trimming out the negative mutations.
Title: Survival-of-the-fittest evobot
Post by: Griz on February 24, 2006, 08:21:00 PM
I see Endy has added some info on Evolution Bots/Sims and how to go
about selecting or finding bots that have evolved to the Wiki:
http://www.darwinbots.com/WikiManual/index...=Evolution_Sims (http://www.darwinbots.com/WikiManual/index.php?title=Evolution_Sims)

question about the "king bot" ...

where might one find the code in DB that selects the "King Bot"?
I am wondering what criteria it uses to do so ...
age, number of offspring, energy ... ???
and how one might go about altering that ...
how to set up a 'custom' selection from within
the program.

and ... might something like this also be possible with scripts?

iow, if I want to find the bot that has the most offspring, or most kills,
or mutations or has reached the greatest age, or energy, or any
combination ... the various 'data point' perhaps somehow weighted ...
how might this be done?

thanks
Title: Survival-of-the-fittest evobot
Post by: Numsgil on February 24, 2006, 08:40:47 PM
The program uses most offspring as the criteria.  I agree that it would be nice to be able to set up different criteria, however this isn't quite as trivial as you might think.
Title: Survival-of-the-fittest evobot
Post by: Griz on February 25, 2006, 08:25:01 AM
Quote
The program uses most offspring as the criteria.  I agree that it would be nice to be able to set up different criteria, however this isn't quite as trivial as you might think.
ok
but I don't know what to think one way or the other as
I don't know where the code is and so haven't been able
to take a look at it.
so ...
let me ask again:
where in the DB code might this be found?
what form/modual?
or what variable is being used for #of offspring?
perhaps I can search for it using that.

and ...
PY mentioned using scripts ...
like having the program pause when a bot developed
some trait he was looking for.
I wonder if he, or anyone, can offer/share some of these
scripts and how one might go about utilizing them in DB.

thanks
Title: Survival-of-the-fittest evobot
Post by: Numsgil on February 25, 2006, 01:37:47 PM
You might look in Form1.  I know it's not in any of the modules I pulled out of form1 (Robots.bas, etc.), beyond that I'm not really sure.  It took me a long time to find myself.

Scripts should be accessible from the scripts tab in the settings.  I haven't played with the much myself beyond killing bots if they lose .repro.
Title: Survival-of-the-fittest evobot
Post by: Old Henk on February 25, 2006, 01:46:14 PM
The script system is actually still in very basic and early in it's development. The scripts that are now possible are quite limited in their ability. PY is planning on expanding this system, I believe.

A while ago I suggested some additions to the script-system here (http://forum.darwinbots.com/index.php?showtopic=316)
Title: Survival-of-the-fittest evobot
Post by: Griz on February 25, 2006, 06:00:00 PM
Quote
A while ago I suggested some additions to the script-system here
yes. those would be nice.

anyone know where in the DB code these might be found/modified?
Title: Survival-of-the-fittest evobot
Post by: Numsgil on February 25, 2006, 06:00:56 PM
Most of the script code is in scripts.bas
Title: Survival-of-the-fittest evobot
Post by: Griz on February 25, 2006, 06:07:57 PM
Quote
You might look in Form1.  I know it's not in any of the modules I pulled out of form1 (Robots.bas, etc.), beyond that I'm not really sure.  It took me a long time to find myself.

Scripts should be accessible from the scripts tab in the settings.  I haven't played with the much myself beyond killing bots if they lose .repro.
did a search of all moduals using * .SonNumber *
with not much luck and somehow stumbled upon a 'fittest bot' function ...
which talks about scoring ...
might this have something to do with it?
or the score function that follows?


Code: [Select]
' returns the fittest robot (selected through the score function)
' altered from the bot with the most generations
' to the bot with the most invested energy in itself and children
Function fittest() As Integer
  Dim t As Integer
  Dim s As Double
  Dim Mx As Double
  Mx = 0
  For t = 1 To MaxRobs
    If rob(t).Exist And Not rob(t).Veg Then
      s = score(t, 1, 2, 0)
      If s >= Mx Then
        Mx = s
        fittest = t
      End If
    End If
  Next t
End Function
and this score function:
Code: [Select]
' does various things: with
' tipo=0 returns the number of descendants for maxrec generations
' tipo=1 highlights the descendants
' tipo=2 searches up the tree for eldest ancestor, then down again
' tipo=3 draws the lines showing kinship relations
Function score(ByVal r As Integer, ByVal reclev As Integer, maxrec As Integer, tipo As Integer) As Double
  Dim al As Integer
  Dim dx As Single
  Dim dy As Single
  Dim cr As Long
  Dim ct As Long
  Dim t As Integer
  If tipo = 2 Then plines (r)
  score = 0
  For t = 1 To MaxRobs
    If rob(t).Exist Then
      If rob(t).parent = rob(r).AbsNum Then
        If reclev < maxrec Then score = score + score(t, reclev + 1, maxrec, tipo)
        score = score + InvestedEnergy(t)
        If tipo = 1 Then rob(t).highlight = True
        If tipo = 3 Then
          dx = (rob(r).pos.x - rob(t).pos.x) / 2
          dy = (rob(r).pos.y - rob(t).pos.y) / 2
          cr = RGB(128, 128, 128)
          ct = vbWhite
          If rob(r).AbsNum > rob(t).AbsNum Then
            cr = vbWhite
            ct = RGB(128, 128, 128)
          End If
          Line (rob(t).pos.x, rob(t).pos.y)-Step(dx, dy), ct
          Line -(rob(r).pos.x, rob(r).pos.y), cr
        End If
      End If
    End If
  Next t
  If tipo = 1 Then
    Form1.Cls
    DrawAllRobs
  End If
End Function
Title: Survival-of-the-fittest evobot
Post by: Numsgil on February 25, 2006, 06:35:45 PM
Yes, that's the fittest bot function.
Title: Survival-of-the-fittest evobot
Post by: Griz on February 25, 2006, 06:44:26 PM
Quote
Yes, that's the fittest bot function.
yeah great.
so how's it work? ;)
if score is based on # or offspring ...
what's this InvestedEnergy(t) about?

and I don't see where score enters into the fittest Function ...
all I see there is score(t, 1, 2, 0) ...
so how does the 'score' from the score Function get to that?

you saw the page on the wiki ...
http://www.darwinbots.com/WikiManual/index...e=Talk:King_Bot (http://www.darwinbots.com/WikiManual/index.php?title=Talk:King_Bot)
can someone give some hints or clues there as to how this code works ..
and what one might do to alter how the score it calculated?
how to possibly add weighted values for say, kills, age, energy, or some
other criteria?

tnx
Title: Survival-of-the-fittest evobot
Post by: Numsgil on February 25, 2006, 08:00:32 PM
I've written something in the wiki.

To reiterate:

Quote
When I found this code several months ago (probably closer to 10 or 11) I wanted to modify it so that the king bot was the bot with the most "invested energy", by which I meant the total energy reserves, body reserves, shell, slime, etc. of it and all its descendants. That is where the InvestedEnergy(t) function came in.

However, for a reason I could never figure out the code didn't work. No bot was ever found to be the king for some reason (no bot was ever highlighted), so I changed InvestedEnergy(t) to return always 1 (and thus go back to the previous behavior of most offspring being King (each offspring is given a score of 1)).

To be honest the function is a mess, one of the few areas of the code (this and ties pretty much) that I have hardly touched to clean up. You can see the chaotic way in which Carlo (I assume it was him) coded much of the code.

The score function itself is recursive (it calls itself), which isn't a bad way to search through a tree (in this case, a phylogenic tree) mind you. However he threw 4 different ideas into a single recursive function. It searches for offspring, highlights offspring, draws family lines, and searches for the oldest ancestor. Granted they're somewhat closely related functions, but recursive functions are a headache enough in and of themselves without 4 different ideas thrown in there.

--Numsgil 17:58, 25 Feb 2006 (MST)
Title: Survival-of-the-fittest evobot
Post by: PurpleYouko on February 25, 2006, 08:31:26 PM
Quote
anyone know where in the DB code these might be found/modified?

Scripts are kind of interesting to set up.

The biggest problem I always come up against is that every robot has to parse every script in the active script list every time that they need to test the conditions against them.

This was relatively easy to set up for mutations because you only need to parse the scripts when a baby is born but for scripts in the main code, eaxh bot would have to check them all on every cycle and this could possibly cause a bit of a slowdown.

Then again maybe it ouldn't be all that bad.

Right now scripts are only parsed in the mutations module but expansions to the system will have to be called from the main code loop.
Title: Survival-of-the-fittest evobot
Post by: Griz on February 26, 2006, 11:58:58 AM
Quote
I've written something in the wiki.

To reiterate:

Quote
When I found this code several months ago (probably closer to 10 or 11) I wanted to modify it so that the king bot was the bot with the most "invested energy", by which I meant the total energy reserves, body reserves, shell, slime, etc. of it and all its descendants. That is where the InvestedEnergy(t) function came in.

However, for a reason I could never figure out the code didn't work. No bot was ever found to be the king for some reason (no bot was ever highlighted), so I changed InvestedEnergy(t) to return always 1 (and thus go back to the previous behavior of most offspring being King (each offspring is given a score of 1)).

To be honest the function is a mess, one of the few areas of the code (this and ties pretty much) that I have hardly touched to clean up. You can see the chaotic way in which Carlo (I assume it was him) coded much of the code.

The score function itself is recursive (it calls itself), which isn't a bad way to search through a tree (in this case, a phylogenic tree) mind you. However he threw 4 different ideas into a single recursive function. It searches for offspring, highlights offspring, draws family lines, and searches for the oldest ancestor. Granted they're somewhat closely related functions, but recursive functions are a headache enough in and of themselves without 4 different ideas thrown in there.

--Numsgil 17:58, 25 Feb 2006 (MST)
yeah man.

 
so I'm wondering then why one couldn't simply add additional
weighted data in the Fittest function:

Code: [Select]
For t = 1 To MaxRobs
   If rob(t).Exist And Not rob(t).Veg Then
     s = score(t, 1, 2, 0)
     If s >= Mx Then
       Mx = s
       fittest = t
     End If
   End If
 Next t

iow ...
right after s = score(t,1,2,0) ...
is there any reason one couldn't add
s=s+ (that bot's energy or kills or slime; age; mutations)
or whatever one wished to look at, weighted accordingly?
ie ... #of offspring being more/less valuable than mutations
or kills or whatever?

if so ...
can you point me to what variables to call on for those ...
iow ...  
would  rob(t).age , rob(t).Mutations, rob(t).SonNumber, rob(t).Kills ... etc
be what I would look at?

or what you were looking at to add with you Invested Energy?

such ideas as number of offspring/age ... or kills/age might
give one a better idea of fittnes than simply # of offspring ...
or whatever one might wish to look at.

tnx
Title: Survival-of-the-fittest evobot
Post by: Griz on February 26, 2006, 12:01:54 PM
Quote
Quote
anyone know where in the DB code these might be found/modified?

Scripts are kind of interesting to set up.

The biggest problem I always come up against is that every robot has to parse every script in the active script list every time that they need to test the conditions against them.

This was relatively easy to set up for mutations because you only need to parse the scripts when a baby is born but for scripts in the main code, eaxh bot would have to check them all on every cycle and this could possibly cause a bit of a slowdown.

Then again maybe it ouldn't be all that bad.

Right now scripts are only parsed in the mutations module but expansions to the system will have to be called from the main code loop.
ok.

can you give me an example or two of some of the ones you
are using to pause the sim when some mutation you have
flagged is detected?
and how one would go about adding new scripts?

this seems a very powerful tool to me.

thanks
Title: Survival-of-the-fittest evobot
Post by: Griz on February 26, 2006, 12:33:28 PM
question:
how does this determining the Fittest used to hightlight the King Bot?
where does that happen?

Code: [Select]
For t = 1 To MaxRobs
  If rob(t).Exist And Not rob(t).Veg Then
    s = score(t, 1, 2, 0)
    If s >= Mx Then
      Mx = s
      fittest = t
    End If
  End If
Next t

'fittest' is now set to 't' ...
so now 'fittest' must be used somewhere to hightlight the bot, eh?
wouldn't rob(t).highlight = True have to also be set here ...
and not in the ScoreFunction?
what is being highlighted in ScoreFunction when tipo=1?
is that something different?

this is all very confusing. ;(
Title: Survival-of-the-fittest evobot
Post by: Numsgil on February 26, 2006, 01:07:18 PM
Quote
this is all very confusing. ;(
Welcome to the club :D

If you can tinker around and get something more interesting than simply the most number of offspring, be my guest.
Title: Survival-of-the-fittest evobot
Post by: Griz on February 26, 2006, 04:12:42 PM
it works. :D

I commented out the s=score(t,1,2,0) and just went with
s = rob(t).SonNumber and it seemed to workthe same
as before.
then used s=rob(t).SonNumber / rob(t).age ...
which I think would select a bot with a higher 'rate of reproduction'
which may be useful, who can say.  
so it looks like this will work, and you can put in whatever
criteria you want for sellecting what you might consider to be a
more fit bot.

found your Invested Energy routine and put part of it in here.
of course this only calculates that invested in the bot itself, not that
invested in it's offspring ...
and I guess that was what you were really looking for.
I will think on that a bit now that this is beginning to make some sense.
but it can at least be a factor for the bot itself.
I did scale it way down tho ...
knocking energy down by a factor of 1000 and body by 100
so I could still add in number of offspring, multiplied by 10 ...
and have all of these be factors of a similar magnitude.
the scaling of course can be altered any way one wishes.

so the line
s = rob(t).SonNumber * 10 + rob(t).nrg / 1000 + rob(t).body / 100

works pretty good, as energy can easily get up to 32000 and body
pretty high as well, not sure what the max is, I saw values of 1200 ...
so right there s = 44. but as soon as some begin reproducing ...
then # of offspring begins to come into play.
so this is what I was looking for ... a way to scale various inputs.

of course ... it should be possible to enable/disable and scale
many different inputs from an input window ...
but at this point I haven't any idea how to do so. ;)
any info to steer me towards how one might do that will be appreciated.

anyway Nums ...
looks you can put your Invested Energy into the equation here
in this limited way ... and add a nominal value for each offspring.
 
I will play with it the way you had it set up, before defaulting it to one ...
and see what I can sus out.

Code: [Select]
' returns the fittest robot (selected through the score function)  'not any more - griz
' altered from the bot with the most generations
' to the bot with the most invested energy in itself and children
Function fittest() As Integer
  Dim t As Integer
  Dim s As Double
  Dim s1 As Double
  Dim Mx As Double
  Mx = 0
  For t = 1 To MaxRobs
    If rob(t).Exist And Not rob(t).Veg Then
      's = score(t, 1, 2, 0) ' old scoring

      's = rob(t).SonNumber / rob(t).age      '# of offspring/age

      s = rob(t).SonNumber * 10 + rob(t).nrg / 1000 + rob(t).body / 100  'Num's Invested Energy plus #offspring ... all scaled

        If s >= Mx Then 'NOTE when higher = fittest
        'If s <=Mx Then 'when lower values = fittest    
        Mx = s
        fittest = t
                  'just for debugging info
                   's1 = rob(fittest).nrg  s1 = rob(fittest).body s1 = rob(fittest).SonNumber
                   's1 = rob(fittest).age s1 = rob(fittest).AbsNum
        
      End If
    End If
  Next t
End Function
Title: Survival-of-the-fittest evobot
Post by: Numsgil on February 26, 2006, 04:16:58 PM
The only thing to watch out for:

The original function added the total number of descendants.  That means it searched through the bots' children's children, on and on...

Unless I'm mistaken your function would only take the immediate children into consideration.

Still, nice work.  I appreciate the effort.
Title: Survival-of-the-fittest evobot
Post by: Griz on February 26, 2006, 04:33:40 PM
Quote
The only thing to watch out for:

The original function added the total number of descendants.  That means it searched through the bots' children's children, on and on...

Unless I'm mistaken your function would only take the immediate children into consideration.

Still, nice work.  I appreciate the effort.
yes ... I see what you were intending to bring into it.

mostly, I just want to have a way to customize how the fittest bot
is selected for whatever reason one might want to select one.

a general VB question:
once I have the program break at a certain point ...
in this case, I had it break in that fittest routine after the bot
had been selected, how would one go about finding the values
of other variables? I can see those in the routine where it break
takes place by hovering over them ...
but what if I wanted to know something else ...
for example, I could determine which bot (t) got selected ...
but wanted to then know it's absolute number so I could verify
the right one was highlighted ...
but had to resort to adding that to the routine so I could hover.
I don't have the help files for VB so ...
is there a way, perhaps another window ...
where I can type in variable names and have the value returned?

I have no idea what those watch, immediate or locals windows
are supposed to do.  well ... I couldn't make them to anything. ;)
Title: Survival-of-the-fittest evobot
Post by: Numsgil on February 26, 2006, 05:13:55 PM
One of those watch/immediate etc. windows allows you to type in a variable.  It will then display the variable's contents at each point in the program flow.  I don't remember which window it is specifically.  Feel free to experiment, you can't hurt anything after all.
Title: Survival-of-the-fittest evobot
Post by: Griz on February 26, 2006, 05:32:26 PM
Quote
One of those watch/immediate etc. windows allows you to type in a variable.  It will then display the variable's contents at each point in the program flow.  I don't remember which window it is specifically.  Feel free to experiment, you can't hurt anything after all.
at each point in the program flow?
what does that mean?
each time the variable is changed?

in the immediate window, I can type only if I break the prog.
and the only thing that does anything is if I type rob( ....
I get it telling me 0-5000 which I guess it the range of the variable.
that's it, nothing else. any variable I type in there doesn't do anything
when I continue to run the program.
surely there must be some what to do this?

I wonder why the one is called a 'watch' window?
and 'locals' I thought might be local variables.
got me.
sure would be nice to have some docs.

I don't suppose one could download only the docs portion of the
VB5 free download Endy told us about.
I was gonna get it but we're talking 400MB!!!!
Title: Survival-of-the-fittest evobot
Post by: Numsgil on February 26, 2006, 07:31:36 PM
My won VB version doesn't have docs, I've had to figure out most of it myself.  THere is an online MSDN that can offer assistanc, but I don't remember exactly where that is.

Anyway, here's what I do:

Once the program breaks, go to debug->add watch.  Type in the variable you're intersted in.

A "watch" window appears.  If there's a + sign to the left of a variable, it means there's more stuff inside it.  Click that + arrow to see what's inside that variable.
Title: Survival-of-the-fittest evobot
Post by: PurpleYouko on February 26, 2006, 08:19:46 PM
Quote
can you give me an example or two of some of the ones you
are using to pause the sim when some mutation you have
flagged is detected?
and how one would go about adding new scripts?

Sorry. I guess I assumed that you knew about the basic scripts that are already set up in the program.

In the "Mutations" page of the options panel, you will see a few boxes at the bottom of the window and a larger one beneath them.

Click in the leftmost of the 3 smaller boxes and a pulldown menu will appear.
As an example, select "Robot gains" from the list.

Next go to the econd box and select a specific sysvar from the pull down list there. I selected "aimsx" as I was trying to mutate a turning bot from one that travels in straight lines.

Next go to the third box and select one of the few available options. The one I used was "Pause sim and highlight bot"

Once all three boxes have values, click the button labeled "Add script" and the script will appear in the large box at the bottom of the screen.

Finally, check the box marked "DNA Scripts Enabled" and start the sim. As soon as any robot is born that has the text "aimsx" anywhere in its DNA, the program will pause and highlight the bot that has it.
If you are running with graphics disabled for greater speed, you will now need to click on the "cycle" button to update the graphical display. You will now see your bot with a yellow circle around it.

Click the normal "play" button to resume the sim.

The program can handle up to 9 of these scripts simultaineously so just keep adding them to the list.

More complex scripts that watch for specific conditions in the game will require quite a chunk of programming to make them work. There is no framework at all for them right now.
Title: Survival-of-the-fittest evobot
Post by: Griz on February 26, 2006, 09:20:05 PM
hey ... that's pretty cool.
too bad the data only shows up with the program breaks tho ...
I was hoping to be able to watch as it runs but when running
the watch window is blanked.

isn't there a way to step thru the program from inside VB?
cycle by cycle or something along those lines?

and if not, why not? ;)

ok ... now hoping this watch window retains it's info from one session to
the next so I don't have to type them in each time but not going to hold
my breath.

by mistake I fired up version 2.4 but I see the fittest and score routines
are the same.

I reinstated your Investment Energy and it seems to work fine.

watching these values in the fittestFunction:

rob(fittest).nrg : 4624.108
rob(fittest).body * 10 : 3556.851

sure adds up to:
InvestedEnergy(fittest)  : 8180.958984375
for that bot.

and with 2 offspring:
rob(fittest).SonNumber : 2  

the score relfects more energy than just the above bot
so looks as if additional score from the offspring, eh?
score(fittest, 1, 2, 0) : 17583.1732788086

however, the numbers don't add up.
I get one of it's offspring having zero nrg and zero body ...
[the one still tied] and the other only 59 nrg and 7.5 body ...
so not sure how that translates to 17583 for the score.

and ... the bot is highlighted.
this is in version 2.4

will do the same in 2.37.6 and see what's up.

so? it looks like it sorta works to me.  ??????????
Title: Survival-of-the-fittest evobot
Post by: Griz on February 26, 2006, 09:29:46 PM
Quote
Sorry. I guess I assumed that you knew about the basic scripts that are already set up in the program.
I recall looking at them long ago and not having a clue what they were.
now at least I know something about them.

well great ... I had no idea one could do all that with them.
excellent.
thanks

Quote
More complex scripts that watch for specific conditions in the game will require quite a chunk of programming to make them work. There is no framework at all for them right now.
right.

my head hurts already from playing with this scoring and fittest bot thing ...
but I learned a bit about VB in the process.
who knows, by the end of the decade I may be a whizz. ;)
Title: Survival-of-the-fittest evobot
Post by: Griz on February 26, 2006, 09:43:18 PM
Quote
however, the numbers don't add up.
I get one of it's offspring having zero nrg and zero body ...
[the one still tied] and the other only 59 nrg and 7.5 body ...
my bad. I see why.
the robot ID's were 162 and 192, but that doesn't tell me what
robot number they are.  
unless I were to go thru all 128 bots looking for rob(t).AbsNum = 162 or 192 ...
and then using that bot number to read their body and energy ...
nah ... I think it works. ;)
Title: Survival-of-the-fittest evobot
Post by: Numsgil on February 26, 2006, 09:49:58 PM
Be double sure to test it, that functions slippery.

I can help you create a pop up window to help set weights for various attributes.

Ideally I'd prefer to add it to the new C++ port, but I don't know that it's that far yet.  Maybe...
Title: Survival-of-the-fittest evobot
Post by: Griz on February 26, 2006, 10:04:43 PM
Quote
Be double sure to test it, that functions slippery.

I can help you create a pop up window to help set weights for various attributes.

Ideally I'd prefer to add it to the new C++ port, but I don't know that it's that far yet.  Maybe...
well, I'll continue to play with it as I find time ...
this is how I learn, try something and see what happens. ;)
I first have to learn enough about something to be able to ask questions
so that's all I'm doing, playing until I run up against a block ...
and then asking about it.
so I will certainly have many questions and could use some pointers.
just give me some basics in starting a pop-up window for starters.
I figured I would go look at how your physics or costs setting get entered
into a window and maybe figure it out.

I figure the fittest calcs can use score(t,1,2,0) + a number of other variables
and weights that can be added to the score, a weight of zero effectively
taking that variable out of play.

but I have no clue as far as how to get such a window started.
so ... guess that's the place to begin. ;)

whatever we come up with in the process might then be of use to
you when you are ready to port it over. might as well work out the
bugs here, eh?  
so if you can point me in some direction, I'll do that grunt work ...
and bug you with questions and who knows, maybe be of some help.
and in the process, I discover something I didn't know before ...
which is the real reason I do anything I do. ;)

all grist for the mill.
Title: Survival-of-the-fittest evobot
Post by: Griz on February 26, 2006, 10:18:35 PM
I don't suppose there's a reverse function for:
rob(t).AbsNum is there?
like the arctan of tangent.

iow, knowing the robot ID number, how might I find the bot number (t)
that the prog uses?  the 't' of t=1 to MaxRobs for that bot ID.
the intial generation is easy, as they are the same. ;)
that faked me out when I went looking for the offspring numbers.

I wonder if one could have the prog write a file ...
for t = 1 to MaxRobs
write t, rob(t).AbsNum
next t

how might I go about doing that?
what's the correct syntax?

I know, I know, RTFM ...
too bad I don't have one. ;)
I can go look at how the 'save all bots' routine works I guess ...
it's just that I do have a limited amount of time to play at it ...
so any hints/tips/pointers would be apprecieated.

tanks
Title: Survival-of-the-fittest evobot
Post by: Griz on February 26, 2006, 11:21:23 PM
Nums ...
here be the breakdown on Invested Energy

the score, which determines the fittest bot ...
turns out to be the addition of the nrg and
body*10 of the offspring, but does not include
the  nrg and body of the parent.

however, for those without offspring ...
the score seems to be that of the bot's
own nrg and body *10.

is this how you intended it to work?

so we have:

fittest bot #19
rob(fittest).body * 10.....3709.250  
rob(fittest).nrg...............4965.802  
........................................________
fittest bot points.............8675.052

offspring 1 (#35)
rob(35).body * 10...........6252.351
rob(35).nrg.....................4239.496
........................................________
InvestedEnergy(35).........10491.847

offspring 2 (#63)
rob(63).body * 10............3799.280  
rob(63).nrg......................5194.024 :
......................................... _______
InvestedEnergy(63).........8993.304

the score from the fittestFunction:
score(fittest, 1, 2, 0)........19485.151

so it seems to work assuming you want
Invested Energy to be that stored by it's
offspring and not the bot itself.

we can always add weighted points for
other things such as kills, age, slime or
whatever.
Title: Survival-of-the-fittest evobot
Post by: Numsgil on February 27, 2006, 01:27:33 AM
Alright, here goes.  Point out if I missed anything.

To find a bot with a certain absnum you'd need to search all the bots in the bot array.  You're not even guarenteed that the bot exists, however, so watch out for that.

Something like this:

for t = 1 to MaxRobs
if rob(t).absnum = Number then return t, or do a jig, or whatever
next t

Your last post, about Invested energy.  That was not my original intention.  I was hoping to have the bot itself and its descenddants equally weighted.  In the end I don't know that it matters.  Feel free to take whatever I had and run with it.  It's not like it's a critical part of the program, it allows a great deal of consequence free experimentation.

As to creating a new form, the best way is to play with the controls yourself.  To create a new form, go to the main menu: project->new form.

Play around with creating and moving around various text fields, labels, etc.  Looking at other forms, especially the options form, will get you an idea as to how the different things all work together.  Double click on a control to go to the code that controls what happens when you change the value in a field.

When you have a form more or less up and running, I'll help you incorporate it into the main code.

When it comes to actual VB syntax, it's just been too long.  I haven't really done any VB coding since October.  This is a good resource (http://windowssdk.msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbalr/html/5c6bd31a-9542-4f3e-bfd5-e951af58f0f2.asp), if you're a good searcher you should find an article on just about anything you could ask a question about.  It'll be far more helpful than I ever could.
Title: Survival-of-the-fittest evobot
Post by: Griz on February 27, 2006, 10:38:15 AM
Quote
When it comes to actual VB syntax, it's just been too long. I haven't really done any VB coding since October. This is a good resource, if you're a good searcher you should find an article on just about anything you could ask a question about. It'll be far more helpful than I ever could.
great.  thanks.
will see what I can finger out ...
then when it comes to utilizing it within DB, will pick your/PY's brains. ;)

I'll put what I learn [if anything] ;) in some form on the wiki ...
as an aid to others who might wish to get into the VB and DB codes.

Quote
Your last post, about Invested energy. That was not my original intention. I was hoping to have the bot itself and its descenddants equally weighted. In the end I don't know that it matters.
I don't think it does, other than when it comes to scaling or assigning the weights
to other factors one may wish to consider so they are of the same magnitude.
so ... just trying to get a sense of what range of numbers might be returned.
obviously, if a bot has many decendants which are thriving ... it's score is going
to be high and it is a good candidate and one which we want to capture.
Quote
Feel free to take whatever I had and run with it. It's not like it's a critical part of the program, it allows a great deal of consequence free experimentation.
exactly. and making it as 'open' as possible for the user ...
is a good thing, ime.
one may wish to have the bot that is saved as 'fittest' to be one
that has not only survived and prospered, but one that has some
useful mutations. iow, it doesn't do a lot of good to auto-save the
fittest bot if it is going to turn out to have the exact same DNA with
no mutations as the 20 it has saved before, so giving the number of
mutations some weight in the selection process might be of some use.
and who knows what else the user might desire to look for?
greatest slime producers, most kills, etc.  whatever.
so, finding a way to make it more versatile for the user is, imo
a good thing.
the more user friendly, the better.  
within reason.
when possible. ;)
Title: Survival-of-the-fittest evobot
Post by: Numsgil on February 27, 2006, 12:44:21 PM
Keep me posted on your progress ;)
Title: Survival-of-the-fittest evobot
Post by: Griz on February 27, 2006, 05:20:27 PM
Quote
Keep me posted on your progress ;)
ah ... I see.
well I won't bother you with it ...
you probably have important things to do.