Cyclical Countoffs, Reducing that trigger count!
Post #1
jjf28
Feb 9 2012, 11:18 pm
|
Relax.
|
Binary Countoffs are “used to move the value of one counter to another counter with as few triggers as possible” in one trigger cycle. Often times, especially when using hyper triggers (which run 11.9 times per second), you can wait more than one trigger cycle for your Countoffs to complete…
In such cases you probably wish to use less triggers, but are unsure what numbers would be best to use, and how many cycles a set of numbers would take, the sequences below should help you find an optimal solution (n = Countoff number). Code n: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ... nth One cycle: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 ... 2n-1 Two cycles: 1, 3, 8, 18, 38, 78, 158, 318, 638, 1278, 2558, 5118 ... 2*2n-1 + 2n-2 - 2 Three cycles: 1, 4, 11, 25, 53, 109, 221, 445, 893, 1789, 3581, 7165 ... 3*2n-1 + 2n-2 - 3 Four cycles: 1, 5, 14, 32, 68, 140, 284, 572, 1148, 2300, 4604 ... 4*2n-1 + 2n-2 - 4 C cycles: 1, C+1, 3C+2, 7C+4, 15C+8 ... C*(2n-1 - 1) + 2n - C Note: adding cycles yields diminishing returns. The maximum value your sequence can handle = 2*(highest number in sequence)+1 Example case & triggers: I can wait two trigger cycles, and my first counter can get as high as 45 So i'll use 1, 3, 8, 18, and 38 as countoffs... Triggers Haven’t got around to finishing a proof yet (eww, sets!) but it checks out with brute force tests, feel free to try it yourself! Brute Force Test Code Bit more math... ![]() C*(2n-1 - 1) + 2n – C = C*2n-1 + 2n – 2 - C = C*2n/2 + 2n/4 - C Pn = 2 * Pn - 1 + C Shoutouts: Lanthanide, TiKels, and Roy for a bit of help finding patterns in the numbers http://www.staredit.net/?p=shoutbox&start_shout=871437 This post was edited 10 times, last edit by jjf28: Feb 12 2012, 1:42 am. |
Post #3
Lanthanide
Feb 9 2012, 11:38 pm
Post #5
Lanthanide
Feb 9 2012, 11:42 pm
|
In my map I have a set of countoffs for almost all buildable buildings, including addons. For most of them I support up to 63 buildings, so require 6 triggers per building type using binary countoffs. Using the 1,3,8,18,38 sequence I can reduce this to 5 triggers that support up to 77 buildings.
Also in my map I actually want to split the spawning over 2 trigger cycles, so using these countoffs gives me that behaviour as well as using fewer triggers to accomplish it. Edit: jjf, the triggers are still a bit screwy, the 8 one says "at most 18" when it should be 17, and the 3 one says "at most 17" when it should be 7. ![]() ![]() ![]() ![]() ![]() ![]() O)FaRTy1billion -- "Lanthanide -- surely you have photos of yourself dressed up as a girl, az?" I don't have pictures of me dressed up as a girl.
O)FaRTy1billion -- One time I was jumping on a trampoline (at that very friend's house xD) with water balloons in my shirt held up by a belt. Azrael.Wrath -- ... |
0 members in this topic (italic members are currently writing a reply): None
+ guest(s)
+ guest(s)
[05:14 am]
[04:42 am]
[04:42 am]
[04:22 am]
[04:21 am]
[04:18 am]
[04:18 am]






![[close]](/images/up.gif)