Long Logic Timming

    Joined
    Mar 30, 2014
    Messages
    44
    Reaction score
    19
    Reading the forums as I do and I came across a post by Sven_The_Slayer in this thread.
    http://starmadedock.net/threads/next-generation-advanced-carriers.728/

    The important part is how many logic blocks it takes to achieve long timings so as a sort of PSA I would like to introduce you to Coprime Numbers. Two numbers are called coprime if the only factor they share is 1. For example, 2 and 3, 7 and 9, 4 and 11 are all coprime.

    So how is this helpful?

    Lets just jump to an example. Starting small lets choose the coprime numbers 2 and 3. We'll create two cyclic groups of timers (meaning the last block activates the first), one 2 blocks long and one 3 blocks long. Now we'll have one more activator block that will activate the first block of both timers. The last thing we need is an and-gate connecting the last block in both groups. Here's a (bad) picture.



    With this configuration the light will only be activated when the last block in both groups is active at the same time. This will only happen after the 3 group runs twice and the 2 group runs three times. I can show you this in a table. D is a delay block, 0 is off 1 is on.

    DDD|DD
    100|10
    010|01
    001|10
    100|01
    010|10
    001|01

    As you can see with the and-gate on the last blocks it will only get activated once every 6 ticks.
    So for 6 seconds this isn't too helpful but for longer delays it gets significantly better. For example if you want to delay 60 seconds we'll need to choose two coprime number who's product is as close to 60 as we can get. Luckily 4 and 15 are coprime so we can create two groups, one 4 long and one 15 long. Combing the last blocks of both groups with an and-gate gives us a total of 4+15+1=20 blocks. Pretty good. If we don't need to be so precise we can do three groups one of 2, one of 3, and one of 11. These added with the two and-gates (just run one into the other) gives us a 66 second delay with 18 blocks. So this will be even more effective for longer delays. For example we can get 231 seconds (little less than 4 min) with just three groups 3, 7, 11 and two and-gates for a total of 23 blocks. Beats the pants off of 231 blocks...

    Now if you want to take this even further you can reuse the cyclic groups in multiple timers allowing you to have ship clocks with very a long timer but with subdivisions. You could, for example, have a row of plexlights turning off and on with a scrolling pattern of 10010001000001 or whatever set of coprime gaps.

    Math.

    Aside: If I can get on the dev build I can make a tutorial at some point.
     

    Attachments

    Last edited by a moderator:
    Joined
    Jan 22, 2014
    Messages
    1,047
    Reaction score
    299
    That is so cool. Why didn't I think of this when playing Minecraft? That would probably have saved me the Cobweb+Hopper experiments (only mentioning the latest, of course).

    Edit: Wait. Won't we get problems with signal length?
     
    Last edited:
    Joined
    Mar 30, 2014
    Messages
    44
    Reaction score
    19
    That is so cool. Why didn't I think of this when playing Minecraft? That would probably have saved me the Cobweb+Hopper experiments (only mentioning the latest, of course).

    Edit: Wait. Won't we get problems with signal length?
    Perhaps, depends on how the logic is implemented. If I did it I would have it update all blocks every tick before processing the logic for the next tick. So this does depend on the clocks (groups) staying in sync. I would have to be able to test to say any more.
     
    Joined
    Aug 14, 2013
    Messages
    2,811
    Reaction score
    960
    • Councillor 3 Gold
    • Wired for Logic
    • Top Forum Contributor
    Ah, very nice, but now you can calculate it :D
    That thing was built so long ago I can't remember exactly how it was calculated and it would probably take forever for me to find the thread on the Minecraft forums that contains the discussion with the calculations.
     
    Joined
    Jun 30, 2013
    Messages
    390
    Reaction score
    285
    • Video Genius
    • Legacy Citizen 8
    • Community Content - Silver 1
    Reading the forums as I do and I came across a post by Sven_The_Slayer in this thread.
    http://starmadedock.net/threads/next-generation-advanced-carriers.728/

    The important part is how many logic blocks it takes to achieve long timings so as a sort of PSA I would like to introduce you to Coprime Numbers. Two numbers are called coprime if the only factor they share is 1. For example, 2 and 3, 7 and 9, 4 and 11 are all coprime.

    So how is this helpful?

    Lets just jump to an example. Starting small lets choose the coprime numbers 2 and 3. We'll create two cyclic groups of timers (meaning the last block activates the first), one 2 blocks long and one 3 blocks long. Now we'll have one more activator block that will activate the first block of both timers. The last thing we need is an and-gate connecting the last block in both groups. Here's a (bad) picture.



    With this configuration the light will only be activated when the last block in both groups is active at the same time. This will only happen after the 3 group runs twice and the 2 group runs three times. I can show you this in a table. D is a delay block, 0 is off 1 is on.

    DDD|DD
    100|10
    010|01
    001|10
    100|01
    010|10
    001|01

    As you can see with the and-gate on the last blocks it will only get activated once every 6 ticks.
    So for 6 seconds this isn't too helpful but for longer delays it gets significantly better. For example if you want to delay 60 seconds we'll need to choose two coprime number who's product is as close to 60 as we can get. Luckily 4 and 15 are coprime so we can create two groups, one 4 long and one 15 long. Combing the last blocks of both groups with an and-gate gives us a total of 4+15+1=20 blocks. Pretty good. If we don't need to be so precise we can do three groups one of 2, one of 3, and one of 11. These added with the two and-gates (just run one into the other) gives us a 66 second delay with 18 blocks. So this will be even more effective for longer delays. For example we can get 231 seconds (little less than 4 min) with just three groups 3, 7, 11 and two and-gates for a total of 23 blocks. Beats the pants off of 231 blocks...

    Now if you want to take this even further you can reuse the cyclic groups in multiple timers allowing you to have ship clocks with very a long timer but with subdivisions. You could, for example, have a row of plexlights turning off and on with a scrolling pattern of 10010001000001 or whatever set of coprime gaps.

    Math.

    Aside: If I can get on the dev build I can make a tutorial at some point.

    Before I say anything you need to come and visit.

    also. have actually tried this yet?

    You have me interested.
     
    Last edited by a moderator:
    Joined
    Jun 30, 2013
    Messages
    390
    Reaction score
    285
    • Video Genius
    • Legacy Citizen 8
    • Community Content - Silver 1
    Also. There is no delay on signal length.

    Have you seen any of the videos I put out on this so far? In any case I'd love to hear from anyone with an interest in Logic
     
    Joined
    Mar 30, 2014
    Messages
    44
    Reaction score
    19
    Also. There is no delay on signal length.

    Have you seen any of the videos I put out on this so far? In any case I'd love to hear from anyone with an interest in Logic
    Seen every one of them, in fact the images came from them. I haven't been able to test this though I would really like to because it effects other logic stuff I'm working on.
     
    Joined
    Mar 2, 2014
    Messages
    1,293
    Reaction score
    230
    • Thinking Positive
    • Community Content - Bronze 1
    • Legacy Citizen 3
    For example if you want to delay 60 seconds we'll need to choose two coprime number who's product is as close to 60 as we can get. Luckily 4 and 15 are coprime so we can create two groups, one 4 long and one 15 long. Combing the last blocks of both groups with an and-gate gives us a total of 4+15+1=20 blocks. Pretty good.
    5+12 is better.

    That is so cool. Why didn't I think of this when playing Minecraft? That would probably have saved me the Cobweb+Hopper experiments (only mentioning the latest, of course).
    I used this to time my suffocator, but I think it's easier to use two hoppers.
     

    NeonSturm

    StormMaker
    Joined
    Dec 31, 2013
    Messages
    5,110
    Reaction score
    617
    • Wired for Logic
    • Thinking Positive
    • Legacy Citizen 5
    Currently, an activation block loses it's activation-state when a weapon computer uses it as trigger

    Does the AND-gate -currently- not deplete the 1-state so that you can't use the very same signal elsewhere afterwards or before?