Darwinbots Forum

Bots and Simulations => DNA - General => Topic started by: Shasta on December 14, 2010, 06:21:01 AM

Title: Randomly choosing a sysvar
Post by: Shasta on December 14, 2010, 06:21:01 AM
In response to a discussion page on the wiki (don't use those, really, the forum is much more likely to get a response) I made this snippet:
Code: [Select]
def aimrx 971
start
    *.aimrx 0 =
        1 rnd 0 = overbool overbool and
            .aimsx .aimrx store
        dropbool not and
            .aimdx .aimrx store
    dropbool
    true
    10 *.aimrx store
stop

This will randomly chose between turning left and right and then makes it easy to use the choice anywhere with the "new sysvar" of aimrx. 971 is a Racial Memory location, so the value will persist across generations. If you don't want that just change the def.