Staredit Network > Forums > SC1 UMS Theory and Ideas > Topic: Cyclical Countoffs
Cyclical Countoffs
Feb 9 2012, 11:18 pm
By: jjf28  

Feb 9 2012, 11:18 pm jjf28 Post #1

Cartography Artisan

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
Collapse Box







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
Collapsable Box


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

Post has been edited 10 time(s), last time on Feb 12 2012, 1:42 am by jjf28.



TheNitesWhoSay - Clan Aura - github

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Feb 9 2012, 11:37 pm The Starport Post #2



Interesting. Problem is, why would you want to use less triggers for a countoff? I can't imagine you ever needing more than a handful for any given countoff anyway...



None.

Feb 9 2012, 11:38 pm Lanthanide Post #3



Quote from jjf28
Trigger
Players
  • Player 1
  • Conditions
  • Current player accumulates at least 18 gas.
  • Actions
  • Set Resources for current player: Add 18 minerals.
  • Set Resources for current player: Subtract 18 gas.
  • Preserve trigger.
  • Shouldn't this be:

    Trigger
    Players
  • Player 1
  • Conditions
  • Current player accumulates at least 18 gas.
  • Current player accumulates at most 37 gas.
  • Actions
  • Set Resources for current player: Add 18 minerals.
  • Set Resources for current player: Subtract 18 gas.
  • Preserve trigger.




  • None.

    Feb 9 2012, 11:38 pm jjf28 Post #4

    Cartography Artisan

    A single countoff is never really an issue, it's when you are using many (for something like variable multiplication) that they can get quite bulky

    ah yes, ty lanth



    TheNitesWhoSay - Clan Aura - github

    Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

    Feb 9 2012, 11:42 pm Lanthanide Post #5



    Quote from name:Tuxedo-Templar
    Interesting. Problem is, why would you want to use less triggers for a countoff? I can't imagine you ever needing more than a handful for any given countoff anyway...
    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.



    None.

    Feb 12 2012, 1:32 am TiKels Post #6



    Quote from jjf28
    Shoutouts: Lanthanide, TiKels, and Roy for a bit of help finding patterns in the numbers http://www.staredit.net/?p=shoutbox&start_shout=871437
    D'awwww I was just screwing around. The concept of your system interested me (and I mean why wouldn't it, it's so obvious yet so clever). I just saw the pattern and figured I'd blab it in the spambox. Thanks <3



    "If a topic that clearly interest noone needs to be closed to underline the "we don't want this here" message, is up to debate."

    -NudeRaider

    Options
      Back to forum
    Please log in to reply to this topic or to report it.
    Members in this topic: None.
    [01:39 am]
    Ultraviolet -- no u elky skeleton guy, I'll use em better
    [10:50 pm]
    Vrael -- Ultraviolet
    Ultraviolet shouted: How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
    hey cut it out I'm getting all the minerals
    [10:11 pm]
    Ultraviolet -- :P
    [10:11 pm]
    Ultraviolet -- How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
    [2024-4-17. : 11:50 pm]
    O)FaRTy1billion[MM] -- nice, now i have more than enough
    [2024-4-17. : 11:49 pm]
    O)FaRTy1billion[MM] -- if i don't gamble them away first
    [2024-4-17. : 11:49 pm]
    O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
    [2024-4-17. : 3:26 am]
    O)FaRTy1billion[MM] -- i have to ask for minerals first tho cuz i don't have enough to send
    [2024-4-17. : 1:53 am]
    Vrael -- bet u'll ask for my minerals first and then just send me some lousy vespene gas instead
    [2024-4-17. : 1:52 am]
    Vrael -- hah do you think I was born yesterday?
    Please log in to shout.


    Members Online: Roy