Darwinbots Forum
Bots and Simulations => DNA - General => Topic started by: Testlund on September 13, 2014, 05:35:36 PM
-
I made this for myself to have a better grip on how it works, but maybe it can be helpful for others too.
'.eye1 through 9 are located clockwise in numerical order.
'
'Positive numbers are anti-clockwise and negative numbers are clockwise.
'
'Default positions of the eyes are:
'
'.eye1 = 140
'.eye2 = 105
'.eye3 = 70
'.eye4 = 35
'.eye5 = 0
'.eye6 = -35
'.eye7 = -70
'.eye8 = -105
'.eye9 = -140
'
'Eye width:
'
'Smallest = -34
'Default = 0
'Widest = 1221
'
'Below is an example of eye settings.
'
'=====================
'Maximum surveillance:
'
start
50 .eye5width store
240 .eye4width store
240 .eye6width store
277 .eye1width store
277 .eye9width store
-20 .eye3width store
-20 .eye2width store
-20 .eye7width store
-20 .eye8width store
stop
start
145 .eye4dir store
-145 .eye6dir store
333 .eye1dir store
-333 .eye9dir store
stop
start
*.robage .eye3dir store
stop
start
*.robage sub .eye2dir store
stop
start
*.robage .eye7dir store
stop
start
*.robage sub .eye8dir store
stop
cond
*.robage 2
start
0 .focuseye store
stop
cond
*.robage 4 mod 0 =
start
-1 .focuseye store
stop
cond
*.robage 4 mod 1 =
start
1 .focuseye store
stop
cond
*.robage 5 mod 0 =
start
-4 .focuseye store
stop
cond
*.robage 5 mod 1 =
start
4 .focuseye store
stop
cond
*.robage 6 mod 0 =
start
-5 .focuseye store
stop
cond
*.robage 6 mod 1 =
start
2 .focuseye store
stop
cond
*.robage 7 mod 0 =
start
-2 .focuseye store
stop
cond
*.robage 7 mod 1 =
start
3 .focuseye store
stop
end
-
Uuuhh... I just realised that anything based on .robage only works for 32000 cycles. :glare:
-
def robage2 998
def robage1 997
cond
start
.robage1 inc
stop
cond
*.robage1 32000 =
start
.robage2 inc
stop
'actual age = *.robage *.robage2 32000 mult add 32000 mod
'close enough, play with it...
-
Wow! The bot gets a second childhood! :D Thanks.
-
def robage2 998
def robage1 997
cond
start
.robage1 inc
stop
may i modify this to:
cond
*.robage 32000 =
start
.robage1 inc
stop
but if we're going there how about this:
def robagemult 50
def robage1 51
cond
*.robage 32000 =
start
.robage1 inc
stop
cond
*.robage1 32000 =
start
0 .robage1 store
.robagemult inc
stop
now bots have 32000 childhoods :D (yes i have had some bots over 100,000 cycles old before usually bigbirthas)
-
Ding! Ding! Ding! Ding!
Then you simply use
*.robage1 *.robagemult 32000 multi add 32000 add
Good find Shadowgod2 :)
-
Cool! I'll try it out tomorrow. Let me just show you what I tried:
def robage2 998
def robage1 997
start
*.robage *.robage1 32000 mult add 32000 mod
stop
cond
*.robage 32000 =
start
.robage1 inc
stop
cond
*.robage1 256 =
start
100 .mkpoison store
stop
start
*.robage1 *.robage2 32000 mult add 32000 mod
stop
cond
*.robage1 32000 =
start
.robage2 inc
stop
cond
*.robage2 256 =
start
100 .mkvenom store
stop
I expected the bot to make venom at 64512 cycles but instead it made poison again like it did at 32256 cycles. Why is that?
I have to go to bed now. It's almost 3 am here. :sleepin:
-
Testlund in a more serious programming language people always write 2 + 2 = 4 as 4 = 2 + 2, review my posts, good night. :sleepin:
-
oops i forgot the *.robage 32000 =
all fixed now :D
-
lol, shadow now has 32000 x 23000 childhoods. That will not work as it can not handle bigger then a long as follows: I am more interested in usage, say modulated between 0 and 100 = *.robage *.robage1 32000 mult add 101 mod. Meaning it will give you a number between 0 and 100. :sleepin:
-
oh i had also made a simple eye scanning today too
start
*.robage 9 mod 4 sub .focuseye store
stop
now with the new code:
start
*.robage1 *.robagemult 32000 mult add *.robage add 9 mod 4 sub .focuseye store
stop
it doesn't seem to be storing anything in .robagemult though
-
lol, I know it is a pointless exercise, I just want people to get the math involved without spelling anything out. That does not make them better programmers. If you take a + 4 mod 4 it is going to be equal to a mod 4. duh!
It becomes useful as Numsgil exposed math to conditions a while back, you can for example get away with
cond
*.robage *.robage1 32000 mult add
32000 777 add >
start
...
stop
I am really going to sleep now :)
-
Well, that's my problem. I suck at math. With these operators I can't figure out what exactly is being calculated, so it becomes all trial and error for me.
OK, let's see what I can do with your examples...
-
Testlund in a more serious programming language people always write 2 + 2 = 4 as 4 = 2 + 2, review my posts, good night. :sleepin:
Yeah, I'm aware of the reversed polish notation or whatever it's called, otherwise I wouldn't have gotten this far. But I don't understand why the .robage2 instruction wasn't executed in my example.
-
I'm getting the same problem here. The first instruction to move forward is carried out, but not the second where it's supposed to move backwards.
def robagemult 50
def robage1 51
start
*.robage1 *.robagemult 32000 multi add 32000 add
stop
cond
*.robage 32000 =
start
.robage1 inc
.up inc
stop
cond
*.robage1 32000 =
start
0 .robage1 store
.robagemult inc
.dn inc
stop
-
it doesn't seem to be storing anything in .robagemult though
So it seems. Your example doesn't work beyond 32000 cycles either.
-
OK, I think this is good enough. The rotating eyes will stop after 32000 cycles but the eye sweeping will continue.
'============
'EYE TEMPLATE
'============
'
'.eye1 through 9 are located clockwise in numerical order.
'
'Positive numbers are anti-clockwise and negative numbers are clockwise.
'
'Default positions of the eyes are:
'
'.eye1 = 140
'.eye2 = 105
'.eye3 = 70
'.eye4 = 35
'.eye5 = 0
'.eye6 = -35
'.eye7 = -70
'.eye8 = -105
'.eye9 = -140
'
'Eye width:
'
'Smallest = -34
'Default = 0
'Widest = 1221
'
'Below is an example of eye settings.
'
'=====================
'Maximum surveillance:
'
def robagemult 50
def robage1 51
start
50 .eye5width store
240 .eye4width store
240 .eye6width store
277 .eye1width store
277 .eye9width store
-20 .eye3width store
-20 .eye2width store
-20 .eye7width store
-20 .eye8width store
stop
start
145 .eye4dir store
-145 .eye6dir store
333 .eye1dir store
-333 .eye9dir store
stop
start
*.robage .eye3dir store
stop
start
*.robage sub .eye2dir store
stop
start
*.robage .eye7dir store
stop
start
*.robage sub .eye8dir store
stop
'The next four genes makes it possible to sweep the eyes beyond 32000 cycles.
start
*.robage 9 mod 4 sub .focuseye store
stop
start
*.robage1 *.robagemult 32000 mult add *.robage add 9 mod 4 sub .focuseye store
stop
cond
*.robage 32000 =
start
.robage1 inc
stop
cond
*.robage1 32000 =
start
0 .robage1 store
.robagemult inc
stop
'The gene below puts the eyes back in their default positions.
cond
*.robage 32000 =
start
0 .eye1dir store
0 .eye2dir store
0 .eye3dir store
0 .eye4dir store
0 .eye6dir store
0 .eye7dir store
0 .eye8dir store
0 .eye9dir store
0 .eye1width store
0 .eye2width store
0 .eye3width store
0 .eye4width store
0 .eye5width store
0 .eye6width store
0 .eye7width store
0 .eye8width store
0 .eye9width store
stop
end
-
I've been trying another crazy eye idea. I want the eyes to be like antennas on an insect scanning the area in front of it. I'm halfway there, but I'm wondering if there are limitations to what can be calculated here, because the eyes use negative values for half of their possible positions and it might not be possible to use that in the custom labels here.
To properly see how it works so far you need to pause the simulation, set it to the slowest speed, click on the bot before you start the sim.
def anticlockwise 100
start
280 .eye1width store
190 .eye2width store
-24 .eye3width store
-16 .eye4width store
140 .eye5width store
-16 .eye6width store
-24 .eye7width store
190 .eye8width store
280 .eye9width store
stop
start
333 .eye1dir store
95 .eye2dir store
-95 .eye8dir store
-333 .eye9dir store
stop
'Eye 3 moves anticlockwise a short distance and then stops. When it stops it must mean that it's value is no longer below 70.
cond
*.anticlockwise 70 <
start
.eye3dir inc
.anticlockwise inc
stop
'If it's not below 70 it must be above 70, so why doesn't it move back again here?
cond
*.anticlockwise 70 >
start
.eye3dir dec
.anticlockwise dec
stop
-
this is very similar to what i will be doing. so far i just have the start pos
-
OK, but the eyes don't move. I was thinking something more like this: