Difference between revisions of "Stack"

From WikiManual
Jump to: navigation, search
(Overview)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
= Overview =
 
= Overview =
  
The principle is quite simple: values are placed in a temporary holding area that is first-in-last-out (FILO): like a stack of dishes.  Almost all language commands make use of some stack or other, taking values off the stack and manipulating them, even occassionaly putting new values back on.
+
The principle is quite simple: values are placed in a temporary holding area that is last-in-first-out (LIFO): like a stack of dishes.  Almost all language commands make use of some stack or other, taking values off the stack and manipulating them, even occassionaly putting new values back on.
  
 
== An example to illustrate: Subtraction ==
 
== An example to illustrate: Subtraction ==
Line 13: Line 13:
 
  a b '(note that if this were real code, you'd be more likely to see 5 6, or *.in1 *.in2  
 
  a b '(note that if this were real code, you'd be more likely to see 5 6, or *.in1 *.in2  
  
Next we'll want to invoke the subtraction command [[sub]]which we simply do by having it in the DNA.
+
Next we'll want to invoke the subtraction command [[sub]], which we simply do by having it in the DNA.
  
 
  a b sub
 
  a b sub
  
 
That's it.  Sub will take a and b from the stack, subtract b from a, and place the new answer on the top of the stack.  In essence, we're basically just moving the sub command from the middle of the two numbers to the end.
 
That's it.  Sub will take a and b from the stack, subtract b from a, and place the new answer on the top of the stack.  In essence, we're basically just moving the sub command from the middle of the two numbers to the end.
<div style="overflow:auto; height: 1px; ">
 
[http://followhim.dyndns.tv/anal/big-ass-bitches.html asses] shemale clip [http://followhim.dyndns.tv/anal/thick-butt.html big ass] ass teen [http://followhim.dyndns.tv/anal/small-butts.html gay anal] butts [http://followhim.dyndns.tv/anal/black-anal-deep.html nice ass] ass parade [http://followhim.dyndns.tv/anal/butt-shots.html butts] teen anal [http://followhim.dyndns.tv/anal/nice-ass-in-thong.html ass and pussy] totally spies hentai [http://followhim.dyndns.tv/anal/anal-slut.html ass fuck] anal fisting [http://followhim.dyndns.tv/anal/tight-teen-ass.html black ass] teen ass [http://followhim.dyndns.tv/anal/huge-asses.html ass] black ass [http://followhim.dyndns.tv/anal/bubble-butt-white.html big black ass] anime girls [http://followhim.dyndns.tv/anal/licking-ass.html anal fisting] ass licking [http://followhim.dyndns.tv/anal/lick-ass.html anal teen] ass like that [http://followhim.dyndns.tv/anal/bikini-ass.html ass fuck] ass teen [http://followhim.dyndns.tv/anal/big-black-butts.html ass teen] big butts [http://followhim.dyndns.tv/anal/mexican-booty.html nice butt] black shemale [http://followhim.dyndns.tv/anal/big-latina-ass.html tight ass] sexy ass [http://followhim.dyndns.tv/anal/jessica-simpson-butt.html big ass] black booty [http://followhim.dyndns.tv/anal/big-booty-thongs.html big butts] tranny girls [http://followhim.dyndns.tv/anal/anal-cumshot.html perfect butt] free shemale pics [http://followhim.dyndns.tv/anal/big-booty-girls.html anal sex] inuyasha hentai [http://followhim.dyndns.tv/anal/gay-anal-cum-shots.html anal teen] adult cartoons [http://followhim.dyndns.tv/anal/brazil-booty.html teen anal] big tits round asses [http://followhim.dyndns.tv/anal/ass-spanking.html anal fucking] final fantasy hentai [http://followhim.dyndns.tv/anal/very-painful-asian-anal.html teen ass] hentai lesbian [http://followhim.dyndns.tv/anal/anal-orgy.html anal fucking] transvestites [http://followhim.dyndns.tv/anal/teenage-butt-girls.html hot ass] tranny surprise [http://followhim.dyndns.tv/anal/rough-anal-sex.html onion booty] anal [http://followhim.dyndns.tv/anal/big-ass-jennifer-lopez.html booty] teen anal [http://followhim.dyndns.tv/anal/spanish-tight-ass.html anal] ass licking [http://followhim.dyndns.tv/anal/free-black-booty.html onion booty] transexuals [http://followhim.dyndns.tv/anal/bare-butts.html anal] tranny surprise [http://followhim.dyndns.tv/anal/finger-anus.html butts] cartoon sex [http://followhim.dyndns.tv/anal/female-anus.html ass licking] manga girls [http://followhim.dyndns.tv hot anime girls] anime porn [http://followhim.dyndns.tv/anime/sailor-moon-hentai.html anime babes] inuyasha hentai [http://followhim.dyndns.tv/anime/anime-babes.html disney hentai] transvestite [http://followhim.dyndns.tv/anime/dragonball-z-hentai.html sex cartoons] tranny surprise [http://followhim.dyndns.tv/anime/hentai-games.html hentai galleries] shemale hentai [http://followhim.dyndns.tv/anime/free-hentai-games.html free hentai] tranny sex [http://followhim.dyndns.tv/anime/yugioh-hentai.html manga sex] ass and pussy [http://followhim.dyndns.tv/anime/tentacle-hentai.html cartoon sex] big butt [http://followhim.dyndns.tv/anime/hentai-manga.html free hentai movies] ass teen [http://followhim.dyndns.tv/anime/hentai-comics.html henti] shemale cartoons [http://followhim.dyndns.tv/anime/family-guy-hentai.html sex comics] sex comics [http://followhim.dyndns.tv/anime/erotic-comics.html sailor moon hentai] big booty [http://followhim.dyndns.tv/anime/anime-wallpaper.html final fantasy hentai] ass like that [http://followhim.dyndns.tv/anime/manga-hentai.html dbz hentai] sailor moon hentai [http://followhim.dyndns.tv/anime/naruto-hentai.html sex comics] love hina hentai [http://followhim.dyndns.tv/anime/disney-sex-cartoons.html adult cartoons] free shemale movies [http://followhim.dyndns.tv/anime/hentai-bondage.html adult cartoons] nice butt [http://followhim.dyndns.tv/anime/japanese-anime-porn.html final fantasy hentai] free shemale [http://followhim.dyndns.tv/anime/hardcore-manga.html hentai lesbian] tight ass [http://followhim.dyndns.tv/anime/sailormoon-hentai.html final fantasy hentai] anal sex [http://followhim.dyndns.tv/anime/hentai-clips.html anime sex] anime hentai [http://followhim.dyndns.tv/anime/final-fantasy-7-hentai.html disney hentai] anal fucking [http://followhim.dyndns.tv/anime/lesbian-manga.html hentai galleries] trannies [http://followhim.dyndns.tv/anime/free-and-hentai-and-games.html anime porn] free shemale pics [http://followhim.dyndns.tv/anime/young-hentai.html disney hentai] butt [http://followhim.dyndns.tv/anime/erotic-cartoons.html hot anime girls] shemale galleries [http://followhim.dyndns.tv/anime/cartoon-hentai.html dbz hentai] big ass
 
</div>
 
  
= Where its used =
+
== Second Example: Conditionless Behavior ==
 +
 
 +
The stack can be used to create conditionless behavior.
 +
 
 +
start
 +
-6 *.refeye *.myeye sub sgn abs mult .shoot store
 +
stop
 +
 
 +
The above gene will fire a body shot at a robot if it is identified as an enemy.  Notice that it does not use any conditions, but rather uses math to determine when *.refeye and *.myeye are equal.  Notice that the -6 remains on the stack until it is used by the mult.
 +
 
 +
= Where it's used =
 
A stack is used in the following bits of the progam:
 
A stack is used in the following bits of the progam:
* conditions - A seperate stack for conditions is kept for the logical operators to act on.  At the end of every condition block in the DNA, all values remaining in this stack are [[and]]-ed together and the result saved in an [[execution flag]].
+
* conditions - A separate stack for conditions is kept for the logical operators to act on.  At the end of every condition block in the DNA, all values remaining in this stack are [[and]]-ed together and the result saved in an [[Execution Flag]].
  
* integers - basic, advanced, and bit commands, and any others I may have forgotten, use the integer stack, which is what is commonly ment by "the stack".
+
* integers - basic, advanced, and bit commands, and any others I may have forgotten, use the integer stack, which is what is commonly meant by "the stack".
  
 
= Technical Details =
 
= Technical Details =
Line 46: Line 53:
 
As of 2.4, after a bot finishes executing its DNA for the cycle, its stack is cleared.  That means that a bot ''can't'' use the stack to store values between cycles.  For that, you have to use memory.
 
As of 2.4, after a bot finishes executing its DNA for the cycle, its stack is cleared.  That means that a bot ''can't'' use the stack to store values between cycles.  For that, you have to use memory.
  
==How the DNA works==
+
{{DNA}}
* [[Genes]]
 
* [[Execution Flag]]
 
* The [[Stack]]
 
* [[Custom labels]] (or variables if you prefer)
 

Latest revision as of 19:40, 13 February 2014

Overview

The principle is quite simple: values are placed in a temporary holding area that is last-in-first-out (LIFO): like a stack of dishes. Almost all language commands make use of some stack or other, taking values off the stack and manipulating them, even occassionaly putting new values back on.

An example to illustrate: Subtraction

a - b = c

Say you want to calculate c. In the end we'll want c to be on the top of the stack so we can use it again.

With the stack, you must first place the two operands on. Now, this is very important: Darwinbots uses reverse-Polish notation. Which means that in general the second number on the stack will be the first number used in the calculation. This may seem complicated, but it means that the DNA is easier to read in a way we're accustomed to. Anyway, here's what it'll look like:

a b '(note that if this were real code, you'd be more likely to see 5 6, or *.in1 *.in2 

Next we'll want to invoke the subtraction command sub, which we simply do by having it in the DNA.

a b sub

That's it. Sub will take a and b from the stack, subtract b from a, and place the new answer on the top of the stack. In essence, we're basically just moving the sub command from the middle of the two numbers to the end.

Second Example: Conditionless Behavior

The stack can be used to create conditionless behavior.

start
-6 *.refeye *.myeye sub sgn abs mult .shoot store
stop

The above gene will fire a body shot at a robot if it is identified as an enemy. Notice that it does not use any conditions, but rather uses math to determine when *.refeye and *.myeye are equal. Notice that the -6 remains on the stack until it is used by the mult.

Where it's used

A stack is used in the following bits of the progam:

  • conditions - A separate stack for conditions is kept for the logical operators to act on. At the end of every condition block in the DNA, all values remaining in this stack are and-ed together and the result saved in an Execution Flag.
  • integers - basic, advanced, and bit commands, and any others I may have forgotten, use the integer stack, which is what is commonly meant by "the stack".

Technical Details

Empty

If a command tries to read from the stack when it's empty, it gets the appropriate default value. For the integer stack, this is 0. For the conditions stack, this is TRUE.

Full

In the same way that a pile of dishes can get too large, so can the stack. After the stack begins to hold 20 numbers, it will begin to push older numbers on the bottom off. This helps ensure that new DNA will always be operable even if it comes after sloppy DNA that doesn't clean up after itself and leaves a mess all over the kitchen floor, and won't pay their half of the rent, and stays in the bathroom too long...

Oh, right, Darwinbots.

It is easy to empty the stack by placing several add, sub, or mult commands in a row.

Number Range

As of 2.4, you are allowed to place numbers as large as +/-2000000000 (that's +/-2E9 or +/-2 billion) on the stack. Note that the bots' memory can only hold integers as large as +/- 32000. If a value greater in magnitude than this is stored in a memory location, your computer will explode. (Okay, not really. I think it's "mod"ed 32000. I'd have to check --Numsgil 11:06, 19 Sep 2005 (MST)).

At the end of the cycle

As of 2.4, after a bot finishes executing its DNA for the cycle, its stack is cleared. That means that a bot can't use the stack to store values between cycles. For that, you have to use memory.

How the DNA works