Darwinbots Forum

Bots and Simulations => DNA - General => The Gene depository => Topic started by: Reiyuki on April 27, 2008, 01:07:20 PM

Title: Timerless timer
Post by: Reiyuki on April 27, 2008, 01:07:20 PM
cond
*.robage 20 mod 1 =
start
stop

Activates gene every 20 cycles


(change to *.robage 50 for 50 cycles, etc)


Took some tinkering to figure out, but was beautiful once I got it.
Title: Timerless timer
Post by: gymsum on April 27, 2008, 02:08:49 PM
Quote from: Reiyuki
cond
*.robage 20 mod 1 =
start
stop

Activates gene every 20 cycles


(change to *.robage 50 for 50 cycles, etc)


Took some tinkering to figure out, but was beautiful once I got it.

I think you should make a bot that uses timed behaviors and timed triggers. You'll need a master gene switcher to prevent retardation or wrong behaviors. I think this would be perfect for say a mating ritual, or even a complex movement by a multi-bot.
Title: Timerless timer
Post by: Reiyuki on April 27, 2008, 03:16:46 PM
Quote from: gymsum
Quote from: Reiyuki
cond
*.robage 20 mod 1 =
start
stop

Activates gene every 20 cycles


(change to *.robage 50 for 50 cycles, etc)


Took some tinkering to figure out, but was beautiful once I got it.

I think you should make a bot that uses timed behaviors and timed triggers. You'll need a master gene switcher to prevent retardation or wrong behaviors. I think this would be perfect for say a mating ritual, or even a complex movement by a multi-bot.

Actually, I find it most useful in creating very efficient bots for harsh environments.  My test bot was a grasshopper that 'hopped' every 20 cycles but was otherwise dormant unless food was in sight.
[you]Extremely[/you] efficient, almost hibernating.
Title: Timerless timer
Post by: bacillus on April 27, 2008, 05:44:47 PM
This would be a very useful approach when using Single Store bots, actually.
If you want to limit this to just a few stores, it would be more efficient to multiply one of the values instead of making a new gene:

start
 VALUE *.robage 20 mod 1 sub sgn abs .MEMLOC mult store
stop
Title: Timerless timer
Post by: EricL on April 27, 2008, 09:00:24 PM
FYI, this will only work for bots of age 32000 or below.  Using .timer is better for periodic firing since it wraps...
Title: Timerless timer
Post by: bacillus on April 27, 2008, 09:07:45 PM
Yes, I remember reading this on several forums, and a guy recently put on the wiki. Thanks for the reminder though.
Title: Timerless timer
Post by: Peksa on April 28, 2008, 07:38:07 AM
The problem with using timer is that it's the same for every bot. If bot relies on *.timer X mod Y =, all bots of the same species trigger at the same time. Of course you could add some randomness with rnd command, but that needs a new gene or some extra lines of code.
Title: Timerless timer
Post by: fulizer on April 28, 2008, 08:55:51 AM
cond
*.robage 20 10 rnd sub mod 1 =
start
stop

would this work
Title: Timerless timer
Post by: Peksa on April 28, 2008, 10:11:54 AM
Quote from: fulizer
cond
*.robage 20 10 rnd sub mod 1 =
start
stop

would this work

Not with *.robage over 32000. That's the reason to use .timer instead of .robage. There's no need for rnd with trigger with robage as condition. And while I'm at, probably not too much with .timer either. It could cause slight problems in leaguebots when eg. all periodical venom shooting happened during one cycle as opposed to nearly even spread that can be archieved by .robage. League matches rarely last over 32 kcycles though.
Title: Timerless timer
Post by: gymsum on April 28, 2008, 03:10:15 PM
Quote from: Peksa
Quote from: fulizer
cond
*.robage 20 10 rnd sub mod 1 =
start
stop

would this work

Not with *.robage over 32000. That's the reason to use .timer instead of .robage. There's no need for rnd with trigger with robage as condition. And while I'm at, probably not too much with .timer either. It could cause slight problems in leaguebots when eg. all periodical venom shooting happened during one cycle as opposed to nearly even spread that can be archieved by .robage. League matches rarely last over 32 kcycles though.

cond
*.robage 32000 sub mod 1 =
start
stop

this works even at birth aeven if it lives to see hundreds of generations at 320,000 cycles (never seen it myself).
Title: Timerless timer
Post by: bacillus on April 28, 2008, 05:33:17 PM
Why would synchronized behaviour pose a problem? Besides, you can always make your custom timer.
Title: Timerless timer
Post by: Peksa on April 28, 2008, 06:01:29 PM
Quote from: bacillus
Why would synchronized behaviour pose a problem? Besides, you can always make your custom timer.

This is just a guess, but I I magine that if multiple bots attack the same bot and periodically shoot venom, it'd be more useful if venom was "adminstered" randomly. The difference - if there is one - wouldn't be big though.

Secondly I love the simplicity of

   *.robage 5 mod 1 =

It looks much nicer than creating a new timer and using it instead
Title: Timerless timer
Post by: Numsgil on April 29, 2008, 02:14:33 AM
*cough*
Code: [Select]
*.timer 5 mod 1 =*cough*
Title: Timerless timer
Post by: EricL on April 29, 2008, 02:19:23 AM
ahem

Code: [Select]
5 rnd 1 =
ahem

Title: Timerless timer
Post by: fulizer on April 29, 2008, 08:58:13 AM
nope timers not my thing wheres the point of randomley moving foward?
that would cause serious problems in friction high sims.
so dont make anyomore refrences about how my timer sucked if I thought it worked I woudnt ask if it did would I?
Title: Timerless timer
Post by: Reiyuki on April 29, 2008, 04:15:39 PM
I didn't know .timer wrapped, so that would definitely work.    
*.timer 10 mod 1 =
(runs once every 10 cycles)


Figured I'd add some hacks to this concept too..  

Lets say you want to only run a certain gene 10 cycles out of 100:
*.timer 100 mod 90 >=

will activate when timermod= 90,91,92,93,94,95,96,97,98,99  but no other time.
Would result in a 10% duty cycle with a 100 cycle frequency.


It might be useful for synchronized breeding, virii propagation, flock management, etc.  I know I use it all the time.
Title: Timerless timer
Post by: Peksa on April 29, 2008, 04:47:00 PM
Quote from: EricL
ahem

Code: [Select]
5 rnd 1 =
ahem


Haha, agreed.
Title: Timerless timer
Post by: Moonfisher on April 30, 2008, 03:06:55 AM
Ehm, just so peopel know, triggering a gene every x cycles is not the only use for mod (modulus).
Basicaly when you divide one number by another you always have a remainder (sometimes 0), mod gives you that remainder and disregards the result of the actual division.

So :
20 10 mod : Means divide 20 by 10 and give me the remainder... in this case 0

You can also use that for setting eyefocus and such stuff :

'Cycle between all eyes.
start
*.timer 9 mod 4 sub .focuseye store
stop


The timers also good for several genes that takes more than one cycle to execute :

cond
*.enemysighted 1 =
start
*.timer .timestamp store
stop

cond
*.timestamp 0 add *.timer =
start
'step 1
stop

cond
*.timestamp 1 add *.timer =
start
'step 2
stop

asf...

Anyway moving off topic, point was that mod is just modulus... a very simple math operator. If you can divide you can use mod...
Title: Timerless timer
Post by: gymsum on April 30, 2008, 05:11:13 PM
Timers are perfect for fetch and store through veg ties. Every cycle, a bot forces sonme var into another location, then on the next cycle (or every 2 cycles), another bot reads that location and var, and acts acordingly. The trick for syncronization is using the lowest common denominator, so that you don't get an overlap down the line.

Timers aren't the greaetest for focuseye especially if you use the 360 configurations. Timers are better for information transfer among large MB networks, so that a bot doesn;t try telling the same two bots the same thing while the rest go derrrr. Mod is the remainder of a quoteint or product, or in the case of a graph, it is a point with which a conical sphere (or doughnut) is formed around leaving a whole, or in certain aplications, antoher plane for say imaginary numbers. It reset 0 to whatever number you want, perfect for Myan convertions. GOd how I love Mod functions....

For isntance time is a modular function on anolog clocks. 12 mod 24 should always read as 12, and 24 mod 24 should read as 0, so that is to say that all the numbers wrap around the number 24. Modular functions are also perfect for 3d vision systems; I'm working on an MB to use two bot's eyes on one target to acurately pinpoint its location using a mod from the eyef vars of both bots. You use a mod to wrap other numbers around them, meaning *.robage mod 20 will always wrap the robots age around the number 20 (or for those that raelly love math, it replaces the number 0 with 20, now we can go into quantum physics, or stay on point). Modulous is a wonderful thing, in fact, I think I might have figured a method for ceating complex structures in DB using MB.. Bacillius, can I edit your Ant bot? The one where hive id was introduced, I think I can make a unique thing for the Ant dna that wouldn't be to complex or large. I woudl add it to the Slim Evo project, but I'm thinking more along the lines of a multibot that never becomes single bot again, the Ant Bot project would raelly get some use out of it, both in tactics and hive formation.
Title: Timerless timer
Post by: bacillus on May 14, 2008, 02:33:41 AM
Sure, knock yourself out.
Just so you know, basing a unique Id mightn't be the best of ideas, chiefly because the first generations will always have the same ID, a big problem for hive Ids.