Difference between revisions of "Talk:King Bot"

From WikiManual
Jump to: navigation, search
m (will this work?)
 
(5 intermediate revisions by 3 users not shown)
Line 28: Line 28:
 
:one should be able to 'weight' these in any way one wishes ...
 
:one should be able to 'weight' these in any way one wishes ...
 
:s=s+ rob(t).age * some K or constants + rob(t).kills * a constant, etc.
 
:s=s+ rob(t).age * some K or constants + rob(t).kills * a constant, etc.
:should work, eh?  
+
   
:
 
:are these valid variables to explore?:
 
:rob(t).age, rob(t).kills, rob(t).SonNumber [for offspring?], rob(t).Mutations ...
 
:where would one find the slime and other things you were wanting to examine in your InvestedEnergy?
 
:thanks Griz
 
  
 +
: this
 +
seems to work.
 
<pre>
 
<pre>
' returns the fittest robot (selected through the score function)
+
' returns the fittest robot (selected through the score function) 'not any more - griz
 
' altered from the bot with the most generations
 
' altered from the bot with the most generations
 
' to the bot with the most invested energy in itself and children
 
' to the bot with the most invested energy in itself and children
 
Function fittest() As Integer
 
Function fittest() As Integer
  Dim t As Integer
+
Dim t As Integer
  Dim s As Double
+
Dim s As Double
  Dim Mx As Double
+
Dim s1 As Double
  Mx = 0
+
Dim Mx As Double
  For t = 1 To MaxRobs
+
Mx = 0
    If rob(t).Exist And Not rob(t).Veg Then
+
For t = 1 To MaxRobs
      s = score(t, 1, 2, 0)
+
  If rob(t).Exist And Not rob(t).Veg Then
      If s >= Mx Then
+
    's = score(t, 1, 2, 0) ' old scoring
        Mx = s
+
 
        fittest = t
+
    's = rob(t).SonNumber / rob(t).age      '# of offspring/age
      End If
+
 
    End If
+
    s = rob(t).SonNumber * 10 + rob(t).nrg / 1000 + rob(t).body / 100 
  Next t
+
    '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
 
End Function
 
</pre>
 
</pre>
  
<pre>
+
''''' s = rob(t).SonNumber * 10 + rob(t).nrg / 1000 + rob(t).body / 100  '''''<br>
' does various things: with
+
:works, a value of 5 offspring adds 50, and energy of 30000 = 30, body of 1200 = 12.<br>
' tipo=0 returns the number of descendants for maxrec generations
+
so all these values contribute ... but of course the Invested Energy is only that of<br>
' tipo=1 highlights the descendants
+
the bot itself, and not the energy of it's offspring and their offspring.
' tipo=2 searches up the tree for eldest ancestor, then down again
+
but ... this at least works ... and will provide a way to customize fittest bot selection.
' tipo=3 draws the lines showing kinship relations
+
 
Function score(ByVal r As Integer, ByVal reclev As Integer, maxrec As Integer,  
+
:now i just need to figure out how to determine what variables one wants to use and
 +
to scale them from some input window.
 +
and hints would be appreciated. {{User:Griz/sig}} 14:42, 26 Feb 2006 (MST)
 +
 
 +
:: Try doing s = score(t,1,2,0) + rob(t).nrg... and add your weights in that way.  That should work I think, while still preserving the original intent.  --[[User:Numsgil|Numsgil]] 15:17, 26 Feb 2006 (MST)
 +
 
 +
 
 +
:sure, i could do that ...
 +
:but all '''score(t,1,2,0)''' gives is #of offspring.<br>
 +
:nothing different than i am doing that with '''rob(t).SonNumber'''
 +
:now if your Invested Energy was being successfully picked up by that ...
 +
:so all the decendants were being brought into play ...
 +
:then i can see where it might be of use.
 +
:that would be the ideal ... although one would have to do some testing
 +
:to see what kind of values would be returned, to get them scaled correctly.
 +
:i haven't had time to play with it yet though.
 +
 
 +
:sure, i could do that ...
 +
:but all '''score(t,1,2,0)''' gives is #of offspring.<br>
 +
 
 +
::Not Quite.  score(t,1,2,0) gives the total number of descendants.  That means the number of sons, grandsons, great grandsons, etc.  -Numsgil
 +
 
  
tipo As Integer) As Double
+
ah yes.<br>
  Dim al As Integer
+
am 'reconstituted' your Invested Energy now and it seems to work ...<br>
  Dim dx As Single
+
returning nrg and body for all decendants so we are behind here in this discussion.<br>
  Dim dy As Single
+
will update this page as to the new findings as soon as i find time. [[User:4.225.244.160|4.225.244.160]] 10:15, 28 Feb 2006 (MST)
  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
 
</pre>
 

Latest revision as of 12:15, 28 February 2006

would someone please explain how it does so?
exactly where in this code is the number of offspring entered?
what does s(t,1,2,0) mean? how might one use other factors, weighted or whatever, to contribute
to the score?

what is InvestedEnergy(t)?

how about a breakdown of the code or some hints using the discussion tab above?
a clue, a hint ... anything! tnx Griztalk 16:37, 25 Feb 2006 (MST)

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)

I hear ya!
in the interest of keeping it simple ...
shouldn't one be able to add additional 'scores' right here in the FittestFunction?
iow ... right after, or instead of, s=score(t,1,2,0) ...
couldn't one add s=s+ rob(t).age or rob(t).kills or .mutations, whatever?
i'm thinking something like s=# of offspring/age might be more telling about
fittness than a straight # of offspring.
one should be able to 'weight' these in any way one wishes ...
s=s+ rob(t).age * some K or constants + rob(t).kills * a constant, etc.


this

seems to work.

' 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

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

works, a value of 5 offspring adds 50, and energy of 30000 = 30, body of 1200 = 12.

so all these values contribute ... but of course the Invested Energy is only that of
the bot itself, and not the energy of it's offspring and their offspring. but ... this at least works ... and will provide a way to customize fittest bot selection.

now i just need to figure out how to determine what variables one wants to use and

to scale them from some input window. and hints would be appreciated. Griztalk 14:42, 26 Feb 2006 (MST)

Try doing s = score(t,1,2,0) + rob(t).nrg... and add your weights in that way. That should work I think, while still preserving the original intent. --Numsgil 15:17, 26 Feb 2006 (MST)


sure, i could do that ...
but all score(t,1,2,0) gives is #of offspring.
nothing different than i am doing that with rob(t).SonNumber
now if your Invested Energy was being successfully picked up by that ...
so all the decendants were being brought into play ...
then i can see where it might be of use.
that would be the ideal ... although one would have to do some testing
to see what kind of values would be returned, to get them scaled correctly.
i haven't had time to play with it yet though.
:sure, i could do that ...
:but all score(t,1,2,0) gives is #of offspring.
Not Quite. score(t,1,2,0) gives the total number of descendants. That means the number of sons, grandsons, great grandsons, etc. -Numsgil


ah yes.
am 'reconstituted' your Invested Energy now and it seems to work ...
returning nrg and body for all decendants so we are behind here in this discussion.
will update this page as to the new findings as soon as i find time. 4.225.244.160 10:15, 28 Feb 2006 (MST)