Darwinbots Forum

Bots and Simulations => DNA - General => The Gene depository => Topic started by: Endy on February 21, 2005, 12:52:43 AM

Title: Handy Genes
Post by: Endy on February 21, 2005, 12:52:43 AM
Here is my little contributation. Value freezing using inc/dec. This technique allows you to "freeze" values or to raise or lower a number to a value and then freeze it.
This is best used for when you need a value at a constant number, but without the cost of continously storring it.

' Basic method to demonstrate
' Will keep .tieloc at -1 permanently
cond
start
.tieloc *.tieloc *.tieloc div mult inc
.tieloc dec
stop

' More complex method demonstrates freezing
' at a value with .ploc=7
cond
start
' When *.ploc = 7 dec by 1
.ploc *.ploc 7 sub 1000 mult add dec
.ploc inc
stop

Primarily these are for use with SG's but I'm sure you all can find other uses for them. Unfortunantly some of the more desirable values (shoot, .tieval, up) don't allow this, so you may have to do some searching for the ones that do.

Feel free to post your own finds here. Eventually any bot posted is fair game, so the real challenge is in the use of these codes to build a true top bot.

Endy ;)
Title: Handy Genes
Post by: Anonomous Guest Person on February 21, 2005, 11:07:16 AM
More specifically, it doesn't work for any memory location between 1 and 8.
Or memory locations above 1000, but that's less of an evil rule that's needed to make sure bots need to expend SOME energy and more of a safeguard.
Title: Handy Genes
Post by: Botsareus on February 21, 2005, 05:12:28 PM
A.G.P. SO?
Title: Handy Genes
Post by: Anonomous Guest Person on February 21, 2005, 06:41:12 PM
That's rather important knowledge.
That is, knowing that one can not inc or dec the system variables 1-8.
Which means that DOES work for .tieval.
Title: Handy Genes
Post by: Botsareus on February 21, 2005, 06:51:04 PM
ic
Title: Handy Genes
Post by: Guest on February 22, 2005, 04:34:42 PM
Thanx, for the info. I mainly used trial and error to find out which it worked for.

Endy ;)
Title: Handy Genes
Post by: Endy on March 07, 2005, 12:56:53 AM
Figured out this handy code for use with the new version.

cond
start
-1 .shoot
*.eye5 50 sub sgn dup dup mult
*.eye5 50 sub sgn add 2 div mult store
' Compares the two and stores -1 in .shoot if *.eye5 50 >
stop

I'm currently in the process of converting as much of DIN as possible to a massive SG form. Still having some trouble with the aiming values though, can't exactly knock out the "mult mult" the same way.

Endy B)
Title: Handy Genes
Post by: Endy on March 13, 2005, 12:22:16 AM
Figured out, while waiting for sgn fix, that the square root function returns zero for anything less than 1. To give you an example:

' This yields 1 if shflav is less than 0
*.shflav sqr dup div 1 sub -1 mult *.shflav dup div mult

Alright enough math tricks, I can't be giving you all my secrets.

P.S.
Please never add imaginary numbers to DB. Even thinking of "imaginary" bots calculating imaginary numbers makes my head hurt.

Endy B)
Title: Handy Genes
Post by: Numsgil on March 13, 2005, 12:33:39 AM
Imaginary numbers you say?   :whisper:  :wacko: Mwahahahahaha.

Seriously though I can't imagine any reason at all to have imaginary numbers.  Imaginary numbers aren't even useful until you get to some advanced harmonic motion differential equations.

But if you insist... :P
Title: Handy Genes
Post by: PurpleYouko on March 13, 2005, 01:45:19 PM
What if I want a multi-bot to form up in the shape of a Mandelbrot set?

Can't do that without imaginary numbers now can I :bigginangel:

 :D  PY  :D
Title: Handy Genes
Post by: Endy on March 19, 2005, 02:59:39 AM
I'm [you]very[/you][/b] scared.

Endy B)
Title: Handy Genes
Post by: PurpleYouko on March 19, 2005, 11:08:17 AM
Could probably do with some Fourier Transforms too. That way I can teach my bots to ananlyze their surrounding by using the infra-red spectrum emitted by the pixels in the screen.

 B)  Fourier Transform Infra Red Spectroscopy  B)
Title: Handy Genes
Post by: Endy on March 19, 2005, 05:38:55 PM
The bots would also be able to see the mouse...that would be seriously creepy.

Endy ;)
Title: Handy Genes
Post by: PurpleYouko on March 19, 2005, 06:47:56 PM
Sounds like you are headed into the possession thread (http://s9.invisionfree.com/DarwinBots_Forum/index.php?showtopic=111)

My suggestion there is to make a possessed robot head toward the mouse.

 :D  PY  :D
Title: Handy Genes
Post by: Endy on April 16, 2005, 09:53:57 PM
Figured out what was keeping *.shang .aimshoot store from working right. The problem is that *.shang is returning the conjugate angle, ie. (If it should be 314 it returns 942). It isn't much of a bug since to counter just subtract *.shang from 1256.


It works right but I ran into some problems with bots killing their babies; when they rotate during birthing. Anyone have any ideas let me know.

Here's what I've got so far:

cond
*.shflav 0 !=
*.shflav -2 !=
start
' Shflav stays when hit...added this checker to counter
70 *.shdx *.shsx add *.shdn *.shup add add dup div mult inc
1256 *.shang sub .aimshoot *70 mult store
-6 .shoot *70 mult store
70 *70 dup div mult dec
stop

Endy B)
Title: Handy Genes
Post by: Light on April 17, 2005, 02:49:06 PM
Quote
It works right but I ran into some problems with bots killing their babies; when they rotate during birthing. Anyone have any ideas let me know.
you could just use some sort of counter when the bot has just reproduced so it cant activate the gene for the next 10 cycles or so

does *.shang refresh each cycle?
Title: Handy Genes
Post by: Numsgil on April 17, 2005, 03:00:35 PM
I could be wrong but I think it refreshes only when you're hit again.
Title: Handy Genes
Post by: Endy on April 18, 2005, 02:54:32 AM
Could we please fix shflav? It probably wouldn't be anything major just reset the next turn. The checker works but it's kind of annoying to have to use it.

I tried different counter methods, but the bots have trouble knowing when they are about to reproduce. Might be able to check if near repro level and then stop firing.

Endy B)
Title: Handy Genes
Post by: Endy on August 24, 2005, 09:56:59 PM
Alright here's my little counter, only about 99% accurate but much closer than any other method.

'g1
cond
start
971 inc
.delgene inc
stop

'g2
cond
start
971 *971 dup div mult inc
stop

This will in cy1 prime 971 to contine increasing. The bots apparantly can only receive a new number if the location is free of all other numbers. I've thought about adding a sort of hour hand to it for when the values get too high but haven't yet.

Been playing around with racial memory for randomizing basic values for a family line. Stuff like repro levels, turns, and speed are all I've done so far. Kind of hard on the first cy's bots, but after several lines die off, you have all one species of bot with multiple different basic behaviors.

I'd really like to use it for a true Stemcell bot, I think it'd be cool to see them seperate into different species.
Title: Handy Genes
Post by: abyaly on August 25, 2005, 12:46:31 AM
Quote
Figured out, while waiting for sgn fix, that the square root function returns zero for anything less than 1.
*.eye1 *.eye2 sub sqr dup div
*.eye1 *.eye3 sub sqr dup div add
*.eye1 *.eye4 sub sqr dup div add
*.eye1 *.eye5 sub sqr dup div add
*.eye1 *.eye6 sub sqr dup div add
*.eye1 *.eye7 sub sqr dup div add
*.eye1 *.eye8 sub sqr dup div add
*.eye1 *.eye9 sub 1 add sqr dup div add 7 sub sqr -140 mult

*.eye2 *.eye1 sub 1 add sqr dup div
*.eye2 *.eye3 sub sqr dup div add
*.eye2 *.eye4 sub sqr dup div add
*.eye2 *.eye5 sub sqr dup div add
*.eye2 *.eye6 sub sqr dup div add
*.eye2 *.eye7 sub sqr dup div add
*.eye2 *.eye8 sub 1 add sqr dup div add
*.eye2 *.eye9 sub 1 add sqr dup div add 7 sub sqr -105 mult

*.eye3 *.eye1 sub 1 add sqr dup div
*.eye3 *.eye2 sub 1 add sqr dup div add
*.eye3 *.eye4 sub sqr dup div add
*.eye3 *.eye5 sub sqr dup div add
*.eye3 *.eye6 sub sqr dup div add
*.eye3 *.eye7 sub 1 add sqr dup div add
*.eye3 *.eye8 sub 1 add sqr dup div add
*.eye3 *.eye9 sub 1 add sqr dup div add 7 sub sqr -70 mult

*.eye4 *.eye1 sub 1 add sqr dup div
*.eye4 *.eye2 sub 1 add sqr dup div add
*.eye4 *.eye3 sub 1 add sqr dup div add
*.eye4 *.eye5 sub sqr dup div add
*.eye4 *.eye6 sub 1 add sqr dup div add
*.eye4 *.eye7 sub 1 add sqr dup div add
*.eye4 *.eye8 sub 1 add sqr dup div add
*.eye4 *.eye9 sub 1 add sqr dup div add 7 sub sqr -35 mult

*.eye5 *.eye1 sub 1 add sqr dup div
*.eye5 *.eye2 sub 1 add sqr dup div add
*.eye5 *.eye3 sub 1 add sqr dup div add
*.eye5 *.eye4 sub 1 add sqr dup div add
*.eye5 *.eye6 sub 1 add sqr dup div add
*.eye5 *.eye7 sub 1 add sqr dup div add
*.eye5 *.eye8 sub 1 add sqr dup div add
*.eye5 *.eye9 sub 1 add sqr dup div add 7 sub sqr -1 mult

*.eye6 *.eye1 sub 1 add sqr dup div
*.eye6 *.eye2 sub 1 add sqr dup div add
*.eye6 *.eye3 sub 1 add sqr dup div add
*.eye6 *.eye4 sub sqr dup div add
*.eye6 *.eye5 sub sqr dup div add
*.eye6 *.eye7 sub 1 add sqr dup div add
*.eye6 *.eye8 sub 1 add sqr dup div add
*.eye6 *.eye9 sub 1 add sqr dup div add 7 sub sqr 35 mult

*.eye7 *.eye1 sub 1 add sqr dup div
*.eye7 *.eye2 sub 1 add sqr dup div add
*.eye7 *.eye3 sub sqr dup div add
*.eye7 *.eye4 sub sqr dup div add
*.eye7 *.eye5 sub sqr dup div add
*.eye7 *.eye6 sub sqr dup div add
*.eye7 *.eye8 sub 1 add sqr dup div add
*.eye7 *.eye9 sub 1 add sqr dup div add 7 sub sqr 70 mult

*.eye8 *.eye1 sub 1 add sqr dup div
*.eye8 *.eye2 sub sqr dup div add
*.eye8 *.eye3 sub sqr dup div add
*.eye8 *.eye4 sub sqr dup div add
*.eye8 *.eye5 sub sqr dup div add
*.eye8 *.eye6 sub sqr dup div add
*.eye8 *.eye7 sub sqr dup div add
*.eye8 *.eye9 sub 1 add sqr dup div add 7 sub sqr 105 mult

*.eye9 *.eye1 sub sqr dup div
*.eye9 *.eye2 sub sqr dup div add
*.eye9 *.eye3 sub sqr dup div add
*.eye9 *.eye4 sub sqr dup div add
*.eye9 *.eye5 sub sqr dup div add
*.eye9 *.eye6 sub sqr dup div add
*.eye9 *.eye7 sub sqr dup div add
*.eye9 *.eye8 sub sqr dup div add 7 sub sqr 140 mult

*.refeye *.myeye sub dup div 200 mult
add add add add add add add add dup
1 add dup div -2 mult 7 add store


yay, math...
Title: Handy Genes
Post by: Numsgil on August 25, 2005, 08:58:06 AM
Wow, what the heck is that? :lol:
Title: Handy Genes
Post by: PurpleYouko on August 25, 2005, 09:44:28 AM
:blink:
Title: Handy Genes
Post by: abyaly on August 25, 2005, 10:58:46 AM
Well, the refeye line is wrong. Added without thinking. I need to mult it with the eye5 value.


if ((eye1 > eye2) &&
   (eye1 > eye3) &&
   (eye1 > eye4) &&
   (eye1 > eye5) &&
   (eye1 > eye6) &&
   (eye1 > eye7) &&
   (eye1 > eye8) &&
   (eye1 >= eye9))
{
 -140 is put on the stack
}
if (similar thing for eye2..)
{
 the angle you want to turn to if eye2 has the largest value goes onto the stack
}
...[similar things for eyes 3, 4, 6, 7, 8, 9]...
Eye5 (if larger or equal to everything else) puts -1 on the stack instead of a larger number..

add add add add add add add add dup
'adds up all the numbers (8 of which should logically be zeroes. I assumed integer
'values for the eyes - this is wrong if they can be other things)
'and copies the top one

1 add dup div -2 mult 7 add
'this puts a 7 on the stack if the top number on the stack is -1
'and a 5 if it is something else

store
'so we get the result of the giant mess up there stored in either address 5 or address 7..


I never made any bots before.
I just thought the stack abuse was an interesting puzzle ^^
Title: Handy Genes
Post by: Numsgil on August 25, 2005, 02:35:52 PM
Write up a bot that tries to use that sometime.  I think it'd be fun.  Of course, I wouldn't want to try and decode it :P
Title: Handy Genes
Post by: Endy on August 25, 2005, 05:55:29 PM
Wow :blink:

I'm impressed, I never imagined sqr would be used to such an extent.  :pray:

Man, it's going to be scarry out there when you start making bots :D

Agree with about DB's math being interesting, it can be fun(and useful) finding the nooks and crannies of the program.