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:24 pm]
    Vrael -- NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
    [2024-4-30. : 5:08 pm]
    Oh_Man -- https://youtu.be/lGxUOgfmUCQ
    [2024-4-30. : 7:43 am]
    NudeRaider -- Vrael
    Vrael shouted: if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
    Yeah I'm not a big fan of Westernhagen either, Fanta vier much better! But they didn't drop the lyrics that fit the situation. Farty: Ich bin wieder hier; nobody: in meinem Revier; Me: war nie wirklich weg
    [2024-4-29. : 6:36 pm]
    RIVE -- Nah, I'm still on Orange Box.
    [2024-4-29. : 4:36 pm]
    Oh_Man -- anyone play Outside the Box yet? it was a fun time
    [2024-4-29. : 12:52 pm]
    Vrael -- if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
    [2024-4-29. : 11:17 am]
    Zycorax -- :wob:
    [2024-4-27. : 9:38 pm]
    NudeRaider -- Ultraviolet
    Ultraviolet shouted: NudeRaider sing it brother
    trust me, you don't wanna hear that. I defer that to the pros.
    [2024-4-27. : 7:56 pm]
    Ultraviolet -- NudeRaider
    NudeRaider shouted: "War nie wirklich weg" 🎵
    sing it brother
    [2024-4-27. : 6:24 pm]
    NudeRaider -- "War nie wirklich weg" 🎵
    Please log in to shout.


    Members Online: Roy