Staredit Newtork
Community
StarCraft
Games
Site
Favourites
 
[*]
Binary Countoffs

Binary

It is important to know how the binary, or base 2, number system works. You can learn about binary in-depth from the Wikipedia article. The reason for knowing how binay works is to help you understand how this trigger system works.

Binary Countoff

A binary countoff is used to move the value of one counter to another counter with as few triggers as possible.

These are triggers that will transfer a number from gas (up to 31 at a time in this example), to minerals.

Code

=Conditions=
-Current player accumulates at least 16 gas.

=Actions=
-Preserve trigger.
-Set Resources for current player: Add 16 minerals.
-Set Resources for current player: Subtract 16 gas

---

=Conditions=
-Current player accumulates at least 8 gas.

=Actions=
-Preserve trigger.
-Set Resources for current player: Add 8 minerals.
-Set Resources for current player: Subtract 8 gas

---

=Conditions=
-Current player accumulates at least 4 gas.

=Actions=
-Preserve trigger.
-Set Resources for current player: Add 4 minerals.
-Set Resources for current player: Subtract 4 gas

---

=Conditions=
-Current player accumulates at least 2 gas.

=Actions=
-Preserve trigger.
-Set Resources for current player: Add 2 minerals.
-Set Resources for current player: Subtract 2 gas
=Conditions=
-Current player accumulates at least 1 gas.

=Actions=
-Preserve trigger.
-Set Resources for current player: Add 1 minerals.
-Set Resources for current player: Subtract 1 gas


As you can see the triggers take this form:
Quote
Conditions:
Current player accumulates at least 2^x gas.

Actions:
Preserve trigger.
Set Resources for current player: Add 2^x minerals.
Set Resources for current player: Subtract 2^x gas

Where x keeps going down until it reaches 0. In the previous example x goes from 4 to 0.

Notice that the numbers are powers of 2 (1, 2, 4, 8, 16, etc) in reverse order. In order to calculate the maximum number transferable per trigger run, take the sum of the same value from each trigger. A simpler way to calculate it would be to take the next power of 2 higher than the highest power of 2 in the countoff (2^5 in the example) and subtract 1. In the above case, 31 gas will be converted into minerals per trigger run.
Because of the use of powers of two in the order shown, any number between 0 and 31 can be transferred in one trigger cycle with just these 5 triggers.

Adding more triggers increases the number range exponentially.

A binary countoff like this can be useful for various things, such as counter arithmatic, or almost anything else.


[09:31 pm]
Centreri -- It's good to be King. ;)
[09:24 pm]
madroc -- tazz that is a great avvy
[09:23 pm]
madroc -- haha falkoner
[09:22 pm]
GameLoader1337 -- if you guys are temple siege fans perhaps can you look at what i posted on the thread tell me what you think
[09:21 pm]
GameLoader1337 -- hey guys
[09:21 pm]
Falkoner -- I modeled the SeN skin on my site off of Carbonite/SeN :P
[09:20 pm]
madroc -- wow I didn't see notice the margins that is niice
You must log in to shout.

©2003-2008 Staredit Network.
Starcraft & Starcraft II are trademarks of Blizzard Entertainment.
Site Index   |   Terms of Service   |   Privacy Policy   |   Contributions