Author Topic: Say hello to my little friend! (Skin Generator Based on DNA!)  (Read 4609 times)

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Say hello to my little friend! (Skin Generator Based on DNA!)
« on: November 06, 2010, 04:10:33 PM »
The idea is to convirt dna to binary first.
In 5 steps generates skin:

Step 1 vortex map skin.
Step 2 Change the resolution to 6x6 pixels
Step3 Contrast the pixels to Black and White
Step4 Run lines from the resutling contrast overwriting existing pixels
Step5 (Step4 +) Runs the same lines into skin.

It gets kind of boring when the DNA is too long, so we might have to selectively select DNA  for system.
« Last Edit: November 06, 2010, 04:34:08 PM by Botsareus »

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Say hello to my little friend! (Skin Generator Based on DNA!)
« Reply #1 on: August 16, 2011, 01:29:19 PM »
The following is my final revision of the skin generator code.

The original code is 100% based on the randomizer.

My code is 50% based on the dna, 47% based on file name, and 3% based on the randomizer.

It also adds that special DNA length tag I need for my experiments.

Code: [Select]

Private Sub AssignSkin(k As Integer, path As String) 'need to pass full path of robot

Randomize 0

Dim robname As String
robname = Replace(TmpOpts.Specie(k).Name, ".txt", "")

Dim newR As Double
Dim nextR As Double
Dim nameR As Double
Dim x As Long

Dim dbls() As Double

ReDim dbls(Len(robname) - 1)
For x = 1 To Len(robname)
dbls(x - 1) = Rnd(-Asc(Mid(robname, x, 1)))
Next 'pre seeds

For x = 1 To Len(robname)
newR = dbls(x - 1)
nextR = Rnd(-(Fast_angle(nextR - 0.5, newR - 0.5)))
Next 'randomize by name

nameR = nextR
newR = 0
nextR = 0

Dim holdtext As String
Dim e7 As Integer 'make sure path contains dna length

Open path For Input As #21
Line Input #21, holdtext
Close #21

e7 = val(Replace(holdtext, "'", ""))


  ReDim rob(0)
  If LoadDNA(path, 0) Then
 
  If e7 = 0 Then 'write dna length to file if not found
    Dim grablength As Integer
    Dim alldnatext As String
    grablength = DnaLen(rob(0).DNA)
   
    Open path For Input As #33   ' Open file.
    Do While Not EOF(33)   ' Loop until end of file.
    alldnatext = alldnatext & Input(1, #33)
    Loop
    Close #33   ' Close file.

    Open path For Output As #33
    Print #33, "'" & grablength & Chr(13) & Chr(10) & alldnatext
    Close #33
   
  End If
 
  Randomize 0
 
  ReDim dbls(UBound(rob(0).DNA))
  For x = 0 To UBound(rob(0).DNA)
  dbls(x) = Rnd(-(Fast_angle(Rnd(-rob(0).DNA(x).value) - 0.5, Rnd(-rob(0).DNA(x).tipo) - 0.5)))
  Next 'pre seeds
 
  For x = 0 To UBound(rob(0).DNA)
  newR = dbls(x)
  nextR = Rnd(-(Fast_angle(nextR - 0.5, newR - 0.5)))
  Next 'randomize by dna
 
  ReDim rob(0)
 
  End If

Randomize nextR * 1000

  Dim i As Integer
  If k > -1 Then
    For i = 0 To 7 Step 2
      TmpOpts.Specie(k).Skin(i) = Random(0, half)
      TmpOpts.Specie(k).Skin(i + 1) = Random(0, 628)
        If i = 2 Then Randomize nameR * 1000
    Next i
    Randomize
    TmpOpts.Specie(k).Skin(6) = (TmpOpts.Specie(k).Skin(6) + Random(0, half) * 2) / 3
  End If
End Sub
Private Function Fast_angle(ByVal dx As Single, ByVal dy As Single) As Single
  Dim an As Single
  If dx = 0 Then
    'an = 0
    an = PI / 2
    If dy < 0 Then an = PI / 2 * 3
  Else
    an = Atn(dy / dx)
    If dx < 0 Then
      an = an + PI
    End If
  End If
  Fast_angle = an / PI
End Function

Comments???

Offline havingphun

  • Bot Builder
  • **
  • Posts: 54
    • View Profile
Re: Say hello to my little friend! (Skin Generator Based on DNA!)
« Reply #2 on: October 15, 2011, 10:14:04 AM »
So does this just make more variety in bot skin?

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Say hello to my little friend! (Skin Generator Based on DNA!)
« Reply #3 on: October 15, 2011, 02:55:48 PM »
Post a screenshot?

Offline havingphun

  • Bot Builder
  • **
  • Posts: 54
    • View Profile
Re: Say hello to my little friend! (Skin Generator Based on DNA!)
« Reply #4 on: October 17, 2011, 04:05:21 PM »
Post a screenshot?
download the attachment skin.exe on his first post

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Say hello to my little friend! (Skin Generator Based on DNA!)
« Reply #5 on: October 27, 2011, 05:21:18 PM »
No, No, that .exe file is the old version.

Numsgil, I use the same skin architecture that was in the program, it is just randomized differently, so there is really no need for a screen shot.

Quote
So does this just make more variety in bot skin?

The idea was:

If you have a robot with a certain  name and DNA, it will always load the same skin based on this perimeters, in any simulation the robot occurs. This lets you  ID a robot just by looking at it's skin. Also, if you load robots for the same simulation but in different order, the system will still assign the proper skin to each robot.

I should start submitting more work by Monday.
I will submit this system with my version of the program.
« Last Edit: October 27, 2011, 05:34:17 PM by Botsareus »

Offline atrop

  • Bot Neophyte
  • *
  • Posts: 7
    • View Profile
Re: Say hello to my little friend! (Skin Generator Based on DNA!)
« Reply #6 on: October 28, 2011, 12:11:28 PM »
so all the bots sharing the same DNA would look the same, right? that's kind of cool - there's no way for me to use it in the actual program though, is there?

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Say hello to my little friend! (Skin Generator Based on DNA!)
« Reply #7 on: October 31, 2011, 03:55:24 PM »
All robots sharing the same dna AND NAME actually.

Lets say you are watching a simulation, and now you can ID some of the robots that look familiar by there skin. The other idea, this one is the big one: Let's say you start a new simulation, you ran this one before, but you load in the robots in the wrong order. Now you still can tell which robot is which just be looking at them.

(All robots sharing the same dna and name will look the same only on startup , if they mutate they still have there initial skin, but change color)

Later, we need a way to link this system to simulation saves... (does simulation saves still load the robots from files?)

edit: think of it like every robot has a unique universal finger print.
« Last Edit: November 01, 2011, 03:41:17 PM by Botsareus »