The Fascinating Math behind Piston Extenders

Sdílet
Vložit
  • čas přidán 17. 05. 2024
  • This is my submission for the Summer of Math Exposition, hosted by @3blue1brown
    some.3b1b.co/
    Patreon: / mattbatwings
    Discord: / discord
    My socials: linktr.ee/mattbatwings
    My texture pack: modrinth.com/resourcepack/mat...
    World Download: (JAVA 1.18.2) www.planetminecraft.com/proje...
    Piston Animations created by @Sloimay
    0:00 Introduction
    0:36 What is Minecraft?
    1:42 What is a Piston Extender?
    2:16 Problem Statement
    2:35 Extension Sequences
    8:51 Extension Optimality
    9:13 Extension Parallelization
    11:11 Extension Circuit
    12:38 Retraction Sequences
    16:15 Retraction Optimality
    17:16 Retraction Parallelization
    17:40 Retraction Circuit
    18:52 Showcase
    19:45 Thanks for watching!
    Music (in order):
    Patricia Taxxon - Wavetable • Patricia Taxxon - Wave...
    LAKEY INSPIRED - Chill Day • LAKEY INSPIRED - Chill...
    Infraction - Serotonin • Vlog Lo-Fi Chill by In...
    Harris Heller - Streamline • Streamline
    Harris Heller - Plethora • Plethora
    Harris Heller - Tokyo Rain • Tokyo Rain
    Harris Heller - Iridescent • Iridescent
    Harris Heller - Path Less Traveled • Path Less Traveled
    Harris Heller - In My Shadow • In My Shadow
    Harris Heller - 90's • 90's
    Sascha Ende - Finger ins Ohr • Sascha Ende Finger ins...
    JNATHYN - Dioma • JNATHYN - Dioma [NCS R...
    Gucci Louis - Rap Beat 2 • Gucci Louis - Rap Beat 2
    Mokka - Only You and Me • (No Copyright Music) R...
    Harris Heller - Manhattan Project • Manhattan Project
    Harris Heller - Golden Age • Golden Age
    Harris Heller - Guilty Spark • Guilty Spark
    Alexander Nakarada - Favorite • Favorite
    Infraction - Sapporo • Lo-Fi Anime Fashion Ch...
    JNATHYN - Dioma • JNATHYN - Dioma [NCS R...
    Gee - Electroswing Revival • Gee - Electroswing Rev...
    Jeremy Blake - Heaven and Hell • Heaven and Hell
    mellowind - Bored || Vibin in the 80s • Bored || Vibin in the 80s
  • Hry

Komentáře • 1,4K

  • @mattbatwings
    @mattbatwings  Před 7 měsíci +99

    CHECK OUT PART 2 for corrections and more math! :D czcams.com/video/6emS04mkRGs/video.htmlsi=RLGIBlMooxlgN848

  • @arcycatten
    @arcycatten Před 9 měsíci +3535

    I think a more optimal way to do piston extenders for n blocks is to use modular arithmetic. ([x mod y] is the remainder when x is divided by y, e.g. 35 mod 10 = 5) [these brackets aren't required, i just use them for clarity]
    basically, you push the first [n mod 12] blocks ([n mod 12] -> 1), then [12 + n mod 12], and repeat until you get to n.
    this is actually a generalization of @abugidaiguess's method for 13 pistons.
    If n mod 12 = 0 (i.e. n is divisible by 12), then it saves no extra steps.
    But otherwise, it saves exactly [n - (ceil(n / 12)) * (n mod 12)] over what is shown in the video!
    some examples:
    13 pistons (video): 12 -> 1, 13 -> 1; 12 + 13 = 25 steps
    13 pistons (modular): 1, 13 -> 1; 1 + 13 = 14 steps
    steps saved: 25 - 14 = 11
    30 pistons (video): 12 -> 1, 24 -> 1, 30 -> 1; 12 + 24 + 30 = 66 steps
    30 pistons (modular): 6 -> 1, 18 -> 1, 30 -> 1; 6 + 18 + 30 = 54 steps
    steps saved: 66 - 54 = 12
    500 pistons (video): 12 -> 1, 24 -> 1, ..., 492 -> 1 (that's 12 * 41, btw), 500 -> 1; 12 * (1 + 2 + ... + 41) + 500 = 10832 steps
    500 pistons (modular): 8 -> 1, 20 -> 1, 32 -> 1, ..., 488 -> 1, 500 -> 1; 8 * 42 + 12 * (1 + 2 + ... + 41) = 10668
    steps saved: 10832 - 10668 = 164 (that's a lot!)
    btw I used a computer program to generate the number of steps for that last one, so it may not be 100% accurate!

    • @mattbatwings
      @mattbatwings  Před 9 měsíci +1075

      nice, that makes sense! for all cases other than multiples of 12, this way of doing it produces a shorter sequence.
      funnily enough, this is actually what gets implemented in the redstone version! In game, I always forced the subsequences to line up with the back, because that way I can change the number of pistons without having to shift the redstone. notice how at 19:09 it starts with 4 -> 1 because its a 40 piston extender
      mind if I pin this comment? would be nice to share this info with everyone! and it could serve as a thread for more discussion about this in the replies

    • @arcycatten
      @arcycatten Před 9 měsíci +331

      @@mattbatwings yeah that would be awesome! i'm totally fine with being pinned :)
      interesting that the redstone ends up producing the shorter sequence anyway. and i'm not much of a redstone guy, so those builds you make always blow my mind, even after all the explanations!
      also i just joined the discord server and it looks great ^^

    • @ElliotsLegoCreations
      @ElliotsLegoCreations Před 9 měsíci +121

      Damn, nice funny words Mr magic man!

    • @deleted_handle
      @deleted_handle Před 9 měsíci

      0_0

    • @d_00
      @d_00 Před 9 měsíci +14

      @mattbatwings
      yeeeaaahh I fel smerter that Matt it took me like 1 sec to figure out this
      anyway I hope this little mistake didn't make this video feel less professional, since you could have made a program that tested all possibilities, knowing that there is a finite and small number of them for a 13-long extender. This way you could have seen that this method was more optimal.
      no worries though, you can't be the best at redstone computing and door making.

  • @rohiem7554
    @rohiem7554 Před 9 měsíci +984

    For a 13 piston extender 1 , 13 -> 1 is more optimal than 12->1, 13->1. Further for a n-piston extender rather than iterating 12->1, 24->1 … n->1 you can simply do (n mod 12) -> 1, (n mod 12) + 12 -> 1, (n mod 12) + 24 -> 1 … n -> 1

    • @rohiem7554
      @rohiem7554 Před 9 měsíci +114

      This saves you floor(n/12)*(12 - (n mod 12) total steps on the extension. Correct me if I’m wrong but this is provably optimal

    • @profx33
      @profx33 Před 9 měsíci +5

      @@rohiem7554 now prove that this is the fastest :D

    • @rohiem7554
      @rohiem7554 Před 9 měsíci +96

      @@profx33this method optimizes the number of piston extensions, however it can still be run in parallel so asymptotically it would take the same amount of time per extension as the method proposed in the video, simply with fewer extensions hence less time. Additionally the use of zero tick mechanics can be used to improve the time between piston firing.

    • @peterbullard8040
      @peterbullard8040 Před 9 měsíci +7

      13->1 does not move all the blocks. Remember there is iron (or some other block) in front and the index of a piston is equal to the number of blocks in front of it. Pistons can only push 12 blocks, so piston 13 can’t activate since it has 13 blocks in front of it.

    • @elliott2501
      @elliott2501 Před 9 měsíci +58

      @@peterbullard8040thats why they activated 1 first.

  • @youtubeviewerxx
    @youtubeviewerxx Před 9 měsíci +831

    It's so cool that #SoME3 is getting some really creative entries even from the channels you wouldn't expect to join.

    • @TyphoonBeam
      @TyphoonBeam Před 9 měsíci +9

      This is the second video I've seen on that, but the first I've actually watched and I have no idea what it is.
      (the other being mate in Omega, the chess one)

    • @shauryagupta3644
      @shauryagupta3644 Před 9 měsíci

      @@TyphoonBeam It's a yearly competition organized by 3Blue1Brown (a yt channel) to support smaller educational and other math related creators

    • @burningnetherite4206
      @burningnetherite4206 Před 9 měsíci +6

      What’s SoME3?

    • @deweiter
      @deweiter Před 9 měsíci

      @@burningnetherite4206 Summit of Math Education is competiton to foster the creation math content online. Anyone could join competition until 19th August. Now you can't join as a participant but you can still join as a judge

    • @nightytime
      @nightytime Před 9 měsíci

      @@burningnetherite4206third edition of the summer of math exposition

  • @anamoyeee
    @anamoyeee Před 9 měsíci +962

    The true infinite piston extender: A flying machine
    Edit: How did this get 600 likes? wow. If anything i thought i'd get criticised for dodging the video's topic

  • @Starwort
    @Starwort Před 9 měsíci +357

    For the record, short (1TP/0TP) pulses will also retract blocks, *if* the block was in the extended position when the pulse was produced - so can also be time-optimised in that way

    • @PCHSwS
      @PCHSwS Před 8 měsíci +24

      Which is what every single demonstration after that explanation uses. So yeah, that's some crucial information.

    • @hunorfekete7413
      @hunorfekete7413 Před 8 měsíci +2

      i was gonna say that

    • @LineOfThy
      @LineOfThy Před 6 měsíci

      Thing is the system measures time in extensions/retractions, not in tick speed.

    • @hunorfekete7413
      @hunorfekete7413 Před 6 měsíci

      @@LineOfThy that is because as far as i know a 0/1t pulse still takes 2t to move the block

    • @LineOfThy
      @LineOfThy Před 6 měsíci +1

      @@hunorfekete7413 Ye but it's still one extension/retraction

  • @ifroad33
    @ifroad33 Před 9 měsíci +453

    I feel like this is exactly the type of video that 3b1b loves to see with this SoME. I love how gaming communities can go together like this with the math community.

    • @niklasschmidt3610
      @niklasschmidt3610 Před 9 měsíci +17

      In the case of minecraft, all the people that are serious about redstone builds (talking about "technical" minecraft players) are on the smarter side of the gaming community and are not afraid of crunshing numbers and investing more time doing math about the game than actually playing it. I always like it, when I catch myself calculating growth of supplies, output of farms, speed of a vehicle, damage over time, and so on, in the middle of a gaming session 😅

    • @niklasschmidt3610
      @niklasschmidt3610 Před 9 měsíci +4

      Looked at the profile of the video creator just now, and in fact, it is not a math guy doing minecraft, but a minecraft guy doing math 😂 Technical player right there.

    • @viewera
      @viewera Před 9 měsíci

      As a math nerd and minecraft fan, I am very happy with this video

    • @ME0WMERE
      @ME0WMERE Před 2 měsíci

      haha, the minecraft community (specifically the redstone community) is intertwined with the maths community. There's just too much overlap for it not to be the case.

  • @cheeseburgermonkey7104
    @cheeseburgermonkey7104 Před 9 měsíci +17

    It appears 3Blue1Brown has reached the Minecrafters

  • @Julian_H
    @Julian_H Před 9 měsíci +85

    The way you parallelized this is actually really similar to how CPUs are optimized. Cpus have several stages they have to do, and they used to have to every stage before the clock cycle. But modern cpus will only do one stage per clock cycle, but will run them all in parallel by starting a new instruction on each clock cycle.

  • @abugidaiguess
    @abugidaiguess Před 9 měsíci +824

    for a 13 piston extender, you can just do 1, 13 → 1
    saves 11 extensions, and should be fairly simple to generalise up until 24 at least
    edit: as a few replies have pointed out, it actually doesn't really matter which piston is extended first. i just happened to choose 1 in my head
    edit 2: wow okay
    so it turns out the method i thought of has since been generalised by the pinned commenter (who actually called it "@abugidaiguess's method"!)
    i honestly didn't put much thought into the comment beyond the specific case for a 13 piston extender, so i'm really glad other people did! :D

    • @AWigglePig
      @AWigglePig Před 9 měsíci +50

      Came here to say this.

    • @Humulator
      @Humulator Před 9 měsíci +15

      This

    • @Eivindhamre
      @Eivindhamre Před 9 měsíci +62

      I was thinking 12, 13→1 which works basically the same way

    • @kajatoth9151
      @kajatoth9151 Před 9 měsíci +21

      I had the same idea only just starting from the back. (12,13→1)
      Edit: eivindhamre3026 wrote the same thing 30s before me

    • @Eivindhamre
      @Eivindhamre Před 9 měsíci +7

      @@kajatoth9151 too slow

  • @ncolyer
    @ncolyer Před 9 měsíci +623

    after finding that dispensers are a dynamical system I'm not surprised you've found some math surrounding piston extenders that warrants a whole math explanation vid, excited to see what you've put together and best of luck with your submission

    • @austinclees9252
      @austinclees9252 Před 9 měsíci +19

      (This comment was made before the premiere)
      My guess for the video is gonna be deriving an algorithm for finding the order in which pistons need to be fired to close/open an nth long piston extender
      That and/or deriving the correct timings to do such

    • @Gekoloudios
      @Gekoloudios Před 9 měsíci +8

      ​@@austinclees9252extender designs are simpler than that, my prediction is that it's gonna be about the observer + 2tick-repeater design which is infinitely expandable and uses just a clock and a timer to get all the pulses, it's a really smart design because although the inputs are kinda intuitive, the piston sequence isn't but in the end it all somehow manages to work

    • @NickGarcia1519
      @NickGarcia1519 Před 9 měsíci +2

      Which vid was this?

    • @ncolyer
      @ncolyer Před 8 měsíci

      ​@@NickGarcia1519it's just a dispenser math video, can look it up on yt

  • @sammyuri
    @sammyuri Před 9 měsíci +128

    A detailed analysis of the optimal extension sequence:
    Consider the total cost of an n-extension. We can consider the total cost to move all required blocks 1 block forward, 2 blocks forward, 3 blocks forward etc. separately, because each extension pushes a subset of the pistons/block which have all currently been moved forward the same amount of times (i.e. it is impossible to simultaneously push two pistons that have moved a different number of times each, because there will be an air gap in between). The first set of blocks (that needs to be moved forward once) has size n, then the next set (that moves forward twice) n - 1, then n - 2 and so on until there is only 1 block that must be moved n times. The kth of these has size (n - k + 1) and requires ceil[(n - k + 1) / 12] extensions as each extension can only push at most 12 blocks. So the total cost is the sum from k=1 to n of ceil[(n - k + 1) / 12]. Notice, however, that this is equivalent to ceil[(n - 1 + 1) / 12] + cost(n - 1), that is, ceil(n / 12) + cost(n - 1), with cost(0) = 0. This can therefore be expressed as cost(n) = ceil(n/12) * (6 + n - 6*ceil(n/12)).
    Also note that this lower bound is achievable because we can simply do the process one step at a time, moving forward the first n-1 pistons in ceil(n/12) steps, then the next n-2 in ceil((n-1)/12), etc.
    The most interesting piston extender math (in my opinion) is that of "hipster" extenders, which are piston extenders that extend beyond the wiring itself. This means in order to power pistons beyond the wiring, movable power sources such as redstone blocks or observers must be extended and retracted themselves. This makes the analysis of the optimal sequence slightly more tricky. Every distance extended/retracted beyond the wiring requires recursively using the distances 1, 2 or 3 blocks before it one or more times (in order to extend and retract the power source, and move the piston back 1 block), leading to exponential growth in the length of the sequence.

    • @amongus_pvp
      @amongus_pvp Před 9 měsíci +5

      So wait you boiled the extension process down to a function? I could be very wrong because i am dog ass at math, nice explanation though!

    • @sammyuri
      @sammyuri Před 9 měsíci +4

      Yes, what we care about most is the length of the sequence (not the actual sequence itself), so I defined the function cost(n) to be the length of an optimal n-extension.

    • @amongus_pvp
      @amongus_pvp Před 9 měsíci +1

      @@sammyuri ah okay thanks for clarifying

    • @viktort9490
      @viktort9490 Před 9 měsíci +3

      Solution "may" not be optimal. It "may" be the case that somewhere in an optimal solution, a piston extension is used in both the moving of the 7th block and also the 10th which could make a better solution than the one you propose.
      I put "may" because I think you're right, but you didn't prove this "may" had to be wrong.

    • @sammyuri
      @sammyuri Před 9 měsíci +5

      @@viktort9490No, this solution is rigorous. In fact, what you say is true (a piston extension IS used in the moving of both the 7th and 10th blocks) - the point is that it can be used to move BOTH those blocks if and only if they have moved the same amount of times so far, or there would be an air gap between and only the 10th block would be moved. This then leads to the independence of each distance moved and the rest of the proof.

  • @wildwyatxbox
    @wildwyatxbox Před 9 měsíci +85

    I've gotta give you props for this. This is gotta be one of the most clear explanations I've seen. No crazy music; and straight to the point, and showing the steps behind each thought and conclusion.
    Subbed.

  • @commandblock1
    @commandblock1 Před 9 měsíci +212

    The formula at 9:11 doesn't produce optimal results every time. Take the 13 piston extender, you could do 1, 13->1 and that's 14 pushes insted of 25

    • @howdeedoo
      @howdeedoo Před 9 měsíci +27

      the formula does allow for an infinitely expandable and modular design to an extender though. using the most optimal number of pushes would require different extenders to have their own different redstone circuits.

    • @cosmo1248
      @cosmo1248 Před 9 měsíci +19

      the formula ends up being the same after parrelisation

    • @commandblock1
      @commandblock1 Před 9 měsíci +2

      @@Drawliphant You need to 1 tick piston 1, or honestly any piston other than 13, and then extend all pistons 13 -> 1

    • @GhostGlitch.
      @GhostGlitch. Před 8 měsíci +1

      ​@@Drawliphantyou don't need to push an expanded piston. You do a quick pulse with one of the first 12 pistons. It will push everything forward and not have time to pull it back. Then the gap created means 13 can now fire to fill that gap and then you can just go down the line.

  • @shhdev
    @shhdev Před 8 měsíci +3

    oh my god this was the most beautiful math video i've ever seen

  • @caspermadlener4191
    @caspermadlener4191 Před 9 měsíci +15

    There is a way to think about piston extenders which I would like to share!
    1. Think about the blocks being moved to be air block, instead of pistons.
    2. When an air block is in a certain location, movement on the two sides doesn't interfere with each other.
    3. We can look at only a single air at a time, we can simply assume the movement in the back to happen first, until the air space is filled.
    4. When extending, there are N air blocks to be moved. The first air block moves N meter, and the N'th air block moves 1 meter.
    5. Moving air K meter to the back takes at least K/12 piston movements, rounded up, which is written as ⌈k/12⌉.
    This is because air moves a maximum distance of 12 blocks per piston movement.
    6. Since this is always possible, the minimal amount of piston movements for an extension of N meter is the sum of ⌈k/12⌉, from k=1 to k=N.
    7. This logic works the same for retraction; the minimal amount of movements is the sum of ⌈k/1⌉=k, from k=1 to k=N, which is actually just equal to ½N(N+1), or the N'th triangular number.
    Personally, I think my proof is very elegant, hope this helps!

    • @mattbatwings
      @mattbatwings  Před 9 měsíci +4

      This is the most elegant proof I've seen so far - thank you for sharing! I saw your note about winning IMO - that's absolutely incredible, congratulations!

    • @caspermadlener4191
      @caspermadlener4191 Před 9 měsíci +2

      @@mattbatwings Thank you, but I didn't 'win' the International Mathematical Olympiad; multiple people win gold medals every year.
      In all of the Olympiads, half of the competitors wins a medal, and the ratio between gold, silver and brons is 1 : 2 : 3.
      100 countries send their six best competitors to the IMO, so a little less than 50 people win a gold medal.
      I was 19th.

    • @Lumix32
      @Lumix32 Před 7 měsíci

      ​@@caspermadlener4191I appreciate your work to the Minecraft community and I Hope, One day, to see your name in the podium of the IMO👏

    • @caspermadlener4191
      @caspermadlener4191 Před 7 měsíci

      @@Lumix32 Thank you, but I was already on the IMO podium in 2022, and the IMO is ment for people before university.

    • @Lumix32
      @Lumix32 Před 7 měsíci +2

      @@caspermadlener4191 In every case, your explanation was perfect, even if I am not a great mathematical Person, i clearly understood It, thx

  • @squorsh
    @squorsh Před 9 měsíci +31

    So I had an idea at around 8:12, and that's that the 13 block extension could be done more simply than 12->1, 13->1. I believe that the sequence 12, 13, 12->1 would also work but with less repetition. Therefore, this disproves that the formula for sequences of individual extensions does not necessarily always give an optimal result.
    Edit: Well it's not something unique I've came up with, but it is still true so I'll take that. Great video as always

  • @agma
    @agma Před 8 měsíci +13

    14:05 The little touch with the empty blocks accentuated by the glass texture is so aesthetically pleasing!

  • @berndl_3925
    @berndl_3925 Před 9 měsíci +16

    mattbatwings and 3blue1brown crossover is not something I know I needed, but holy crap I'm all here for it O.O

    • @ncolyer
      @ncolyer Před 9 měsíci +1

      if only

    • @Mxolqi
      @Mxolqi Před 9 měsíci +5

      its not really a crossover. Its just a video for 3b1bs math video contest

    • @Omena0
      @Omena0 Před 9 měsíci

      Lol

  • @cdamerius2895
    @cdamerius2895 Před 6 měsíci +4

    9:05
    You can find a quadratic lower bound on the number of elements in your extension sequence as follows.
    Your initial state with n pistons can be represented by a sequence
    P^(n+1) H^n
    where P denotes a piston (or the block to push) and H a "hole", i.e., air. Your final state is
    (P H)^n P
    Note that both states have the same length. All your moves, i.e., individual piston extensions,
    will just swap P's and H's around in the state.
    So this means that the n holes must be moved somehow such that they appear in the even
    (2nd, 4th and so on) positions, by means of piston extensions.
    Observe that every move must take a clump
    P^l H with l

  • @gallium-gonzollium
    @gallium-gonzollium Před 9 měsíci +21

    This is the intersection of multiple internal Venn Diagrams I have. Math, Redstone, etc. What a video! Hope your SoME3 sub wins!

  • @Emailminecraft
    @Emailminecraft Před 9 měsíci +47

    I legit am so happy you are making these videos. You explained so much to me about computer science and maths better than my actual teachers. Thanks so much

    • @gorlix
      @gorlix Před 9 měsíci

      erm... no.
      but the vid is good tho
      i got so much satisfaction from parallelized pistons

  • @LupusMobile
    @LupusMobile Před 9 měsíci +30

    3Blue1Brown--Grant Sanderson is one of my most watched channels on youtube. You are an absolute legend for sharing with the world the wonders of Maths and Minecraft, Mattbatwings. Thank you for all that you do; this is incredible!

  • @theodoreastor3443
    @theodoreastor3443 Před 9 měsíci +2

    Something that didnt get said here but i think is mathematically interesting is that the retraction system is just the reverse of the push system when the push limit is 1 block.

  • @aaryananand7288
    @aaryananand7288 Před 9 měsíci +3

    Also, I just came up with another algorithm for piston retraction that makes waaaay more sense as just numbers.
    Sequence(n) = 1-> n, Sequence(n-1)
    Which when you write it out, let's say for 3 pistons, is
    1, 2, 3, 1, 2, 1
    And for 4 pistons is
    1, 2, 3, 4, 1, 2, 3, 1, 2, 1
    You basically have to reduce the number you're counting up to by one after each time you count to it.
    So for 4 pistons, you first count up to 4, then up to 3, then to 2 and finally just the one last piston.
    If I'm not wrong, this should be just as efficient as the sequence you mention in the video having the same number as the minimum retraction, but the numbers here just go together so well. Heck this even just works the same way you use to calculate the min retractions possible!

  • @austinclees9252
    @austinclees9252 Před 9 měsíci +61

    I’m so excited.
    SoME has been a great way for a pure math undergrad like myself to pass the summer. Cant wait to see how you take things :D

    • @ZephyrysBaum
      @ZephyrysBaum Před 9 měsíci +1

      even just a middle schooler like me!

    • @anon1963
      @anon1963 Před 9 měsíci

      why math bruh it's so boring when you don't have anything to apply it to

    • @ZephyrysBaum
      @ZephyrysBaum Před 9 měsíci

      @@anon1963 frick you! Maths is the best

    • @uwuowo7775
      @uwuowo7775 Před 9 měsíci

      ​@@anon1963some people just find it fun.😊😊😊😊

    • @reesespieces5386
      @reesespieces5386 Před 8 měsíci

      @@anon1963First of all, higher level math is beautiful and not boring in its own right. Second, there are millions of applications of many, if not most, areas of math

  • @swies2344
    @swies2344 Před 9 měsíci +13

    I didn't think you would participate SoME3 ! This was definitely a surprise, but a pleasant one =)

  • @TwentySeventhLetter
    @TwentySeventhLetter Před 9 měsíci +7

    Love this, math isn't exactly the _last_ thing I think of when I think of minecraft, so it's cool to see a deep dive into one of the game's most versatile mechanics!

  • @culibrity
    @culibrity Před 9 měsíci +8

    This is probably one of the most intriguing and entertaining Redstone videos I've ever watched

  • @rubensf7780
    @rubensf7780 Před 9 měsíci +23

    The footage of you actually building the contraptions is really nice, please continue to do this

  • @supersmiley5587
    @supersmiley5587 Před 9 měsíci +7

    Funfact: retraction doesnt need a long pulse. With a sticky piston and a block on it. You can use 2 short pulses to extract and then retract

    • @atlascove1810
      @atlascove1810 Před 8 měsíci +1

      Sometimes it's better to assume cows are spheres in a vaccum.

    • @kyucumbear
      @kyucumbear Před 7 měsíci

      @@atlascove1810 This makes me remember the science diagram of a cow's aerodynamics.

  • @HedgehogGolf
    @HedgehogGolf Před 9 měsíci

    That's really cool! I always love seeing all the SoM videos. Yours in particular is super well editing with great pacing and great explanations.

  • @OmerLink54
    @OmerLink54 Před 9 měsíci +1

    Man, videos like this is why I love studying CS

  • @imwatchingasalways
    @imwatchingasalways Před 9 měsíci +11

    for a 13 piston extender can't you just do 12 then 13->1 for the extension

    • @huseyinemreeken3024
      @huseyinemreeken3024 Před 9 měsíci

      You have to give a pulse, wich maked it more complicated

    • @imwatchingasalways
      @imwatchingasalways Před 9 měsíci +1

      @@huseyinemreeken3024 but it still would be the fastest way without grouping

  • @pipipiwalopimeja
    @pipipiwalopimeja Před 9 měsíci +3

    Its not that sticky pistons can't retract blocks with just a one tick pulse, but that they toggle the position of the block
    so if the block is touching the piston, after a one tick pulse it wont be, but if the block is not, a one tick pulse will pull it in.

  • @micahjacobson8533
    @micahjacobson8533 Před 7 měsíci +1

    This was an incredible video, the visuals were super helpful and the math was impressive. Great job!

  • @lima7132
    @lima7132 Před 9 měsíci +2

    Many people commented the extension in not optimal as you said, but I'd like to contribute with what I found:
    For N pistons with a delay D=(N-1)//12, the optimal sequence will be: 12->1[t=0],24->[t=1],36->1[t=2],...,N->1[t=D], where the number of steps will be N+D, with D+1 parallel sequences, each one being offset in time "t" by D too.
    For N=12 you can do 12->1[t=0]
    For N=13 you need to trigger a piston

  • @spacefun101
    @spacefun101 Před 9 měsíci +11

    The extension sequence you describe is not optimal for every length piston extender. For example, with the 13 extender, you can have any one of the pistons 1-12 fire, creating a gap, then just extend from 13 to 1. However, I think this is just as fast as the sequence you named with parallelization, although requiring more piston extensions. Yours is probably easier to wire though (at least smaller) because you can just repeatedly power the same line from the back.

  • @theolimagameplays
    @theolimagameplays Před 9 měsíci

    Amazing video! Great editing and clever solutions!

  • @Anaoa_Official
    @Anaoa_Official Před 9 měsíci +1

    This video unironically made math interesting to me. Your visuals are really easy to follow, I only backtracked like once (I usually backtrack a lot in videos). I like how you started simple and gradually went more complex leading to formulas. I'm definitely subbing!

  • @wiirambo7437
    @wiirambo7437 Před 9 měsíci +3

    Extending two pistions (and having one pushing the other) at the same time (in the same game tick) is possible. I uploaded a short video showing in which cases this is possible, because there are some limitations to that. I don't know if this can be used to speed up pistion extenders even more.

  • @Gekoloudios
    @Gekoloudios Před 9 měsíci +3

    here's the optimal extension sequence: (I'm gonna be refering to pistons by p+n)
    let's say we have a 13 extender, so push limit becomes a problem
    your way of doing it results in 25 extensions, which is of course not optimal
    the optimal sequence for a 13PE would be to first power p1 and then do p13 -> p1 (14 extensions in total)
    this works because by powering p1 we've "freed" p13 from the push limit, and it can now push p12 - p2
    now when that happens the next piston we would ideally want to power is p12, so we'd want it to not be at its push limit
    as you said the piston's number also shows how many blocks are in front of it, and since we're now at 12 push limit is nonexistent and we can just push them all in order (p12 -> p1)
    here's the sequence in case you're confused: 1,13,12,11,10,9,8,7,6,5,4,3,2,1 (this is for 13pe)
    for bigger extenders here's how you'd find the optimal sequence:
    first of all, your sequence formula which you asked us to figure out if it's optimal or not, is only optimal for n*12 extenders so 12,24,36 etc
    the reason is because your sequence happens to only allow the last piston to fire after multiples of 12
    so for a 24PE because it's the largest extender for which you only need one subsequence (25+PE need at least 2 subsequences) that means it's optimal
    the reason your idea isn't optimal for anything other than n*12 extenders is because most of the time it's wasting extensions
    that's why I made the 13PE example at the start of this comment...
    you're using 25 extensions while you only need 14 extensions, and you only need 14 because the push limit is already no longer a problem after extending p1
    another example is a 14pe, for that you'd need 16 extensions, 2 of them would be to get p14 out of the push limit (those can be anywhere in the extender, as long as they make 2 gaps in the piston line which help the p14 -> p1 sequence always be out of the push limit) and the other 14 would be just p14 -> p1
    another example is a 24PE - for that you'd need 12 extensions to get the p23 out of the push limit and then another 24 extensions to make the entire thing extend, resulting in 36 extensions total, which I can say with confidence is the optimal for 24PE
    TLDR:
    here's the logic for extenders of any length:
    you start with trying to extend every piston beginning from the one with the largest number and going towards p1, then when you find the first one that can extend, make all the ones after it also extend in order - now do the entire thing again until you reach the n piston (n is how big the extender is) this should look like the pistons extend in chunks of 12, first p12 -> p1 then p24 -> p1 then p36 -> p1 and so on... until you reach piston [n-n mod 12] at which point you should be able to power them all in order of n -> p1 for the full extension
    --------------------------------
    if you didn't understand anything reply to this comment and I will try to explain

    • @redcrafted_
      @redcrafted_ Před 9 měsíci +2

      U can trust this mans word, he holds multible Piston Extender Wr's

    • @Gekoloudios
      @Gekoloudios Před 9 měsíci +2

      @@redcrafted_ xD thanks for the vouch

    • @Gekoloudios
      @Gekoloudios Před 9 měsíci +2

      @@redcrafted_ bruh I was the first to comment about the optimal sequence and people saying "um actually" for the 13pe and nothing else are getting all the likes... ffs

    • @redcrafted_
      @redcrafted_ Před 9 měsíci +1

      @@Gekoloudios most ppl just dont have a long enough attention span, not ur fault xD

  • @TimeWisely
    @TimeWisely Před 9 měsíci +1

    damn dude, that ending video was kinda beautiful

  • @HomeGrownPyrotechnics
    @HomeGrownPyrotechnics Před 9 měsíci +1

    the way you have the parallel pisron firing reminds me of a smarter every day video called STRANGE but GENIUS Caterpillar Speed Trick with caterpillars that ride each other like a wave

  • @abberant3112
    @abberant3112 Před 9 měsíci +7

    This is actually a great way to introduce mathematical induction, that I've never thought of as a huge maths and redstone nerd! Ty again mattbattwings and best of luck !!

  • @btvoidx
    @btvoidx Před 9 měsíci +5

    Very good visuals! Sloimay made very cool animations. But I'd like to see more on retraction parallelization, it seemed quite glossed over.

    • @arcycatten
      @arcycatten Před 9 měsíci

      it’s not that complicated! each retraction of n pistons takes exactly 2n - 1 steps with parallelization, and n(n + 1)/2 steps without it

  • @gregoriopescucci4997
    @gregoriopescucci4997 Před 9 měsíci +1

    10:20 it's the same principle used in CPUs to parallelize instructions, it's called "instruction pipelining"

  • @ArtificialDjDAGX
    @ArtificialDjDAGX Před 9 měsíci +1

    I see that some people want piston 1 to push the block right in front of it, and then do [13,1], but I feel like starting as close to the next chunk as possible would be a bit more optimal, as in, for 13 pistons, piston 12 pushes, then you do [13,1].
    For 25 pistons, you'd do 12, then 24, then [25,1], so you always end up only doing the n->1 pushes when you can push for the entire chain, instead of having any sub-chain pushes that aren't a single push that moves 12 pistons 1 step forward to free up pistons further back in the chain.
    To further extrapolate:
    Make every multiple of 12, starting from 12*1 and working up towards 12*m < n, push the 12 blocks in front of it, and when you reach 12*(m+1) >= n, just do the n->1 push chain.

  • @CraftyMasterman
    @CraftyMasterman Před 9 měsíci +9

    but spacewalker 46 piston extender >>>>

    • @KodeurKubik
      @KodeurKubik Před 9 měsíci

      Crafty!! Hi :)

    • @KodeurKubik
      @KodeurKubik Před 9 měsíci

      And btw avogadoo’s infinite extendable instant piston extender >>>>>>>>>>> :)

  • @kix4christ130
    @kix4christ130 Před 9 měsíci +3

    Just casually scrolling through for all of the people who think they are smart and found the more optimal Extention method

  • @alexpym8216
    @alexpym8216 Před 9 měsíci +1

    This brings me back to mumbo jumbo building triple piston extenders

  • @accidentalengineering
    @accidentalengineering Před 9 měsíci +1

    This was your best video so far!

  • @kyokajiro1808
    @kyokajiro1808 Před 9 měsíci +2

    you cant get a proof because its not optimal, for 13 you want 12 13 12->1 which is as fast as parallel but but without any parallel use, the way you want to think of this is you want it to push 12 as many times as you can, i havent formalized exactly what you have to do to do this but something along the lines of that will result in more possibly most optimal runtime

  • @coffeemanwantsumcoffee
    @coffeemanwantsumcoffee Před 7 měsíci +5

    10:30 twin towers

  • @ssbmfan4
    @ssbmfan4 Před 9 měsíci +1

    Glad you made this video, I've spent a lot of time thinking about this same concept. I really like your design, it is very easily scalable.

  • @astrovation3281
    @astrovation3281 Před 9 měsíci +1

    very smart submission for 3b1b

  • @coral3397
    @coral3397 Před 9 měsíci +1

    i love this video! the editing was fantastic and i love the math behind it.

  • @Gee25
    @Gee25 Před 9 měsíci

    Beautiful video! Well done!

  • @Hi_Brien
    @Hi_Brien Před 9 měsíci

    You did a fantastic job with this one!

  • @lordofbanana842
    @lordofbanana842 Před 6 měsíci

    The explanation of redstone and specifically the piston was done so well and allows people who haven’t even played Minecraft to get into the video.

  • @user-le7ze8os6m
    @user-le7ze8os6m Před 8 měsíci

    there is actually a pattern for the retraction pattern for the piston, it's called the " Triangle read by rows: row n lists the first n positive integers in decreasing order", which is quite fascinating to find this mathematical coincidence

  • @mec1789
    @mec1789 Před 9 měsíci

    Very well explained. Good job mate

  • @kf7872
    @kf7872 Před 7 měsíci +1

    Justwatched 3b1b SoME3 recommendations. Sadly didn't see this in the 25, but did see it in the comments. So came here to watch it. Again. Good job. 👍

  • @ArtoreeGD
    @ArtoreeGD Před 9 měsíci

    this is so cool! the animations are very well made!

  • @thenuggywuggy8389
    @thenuggywuggy8389 Před 9 měsíci

    BRO YOU ARE RIGHT!!! I thought you were just trying to make fun of us with the "Just be good" thing, so i whipped out my sketch book, drew from a reference, and IT LOOKS SO FUCKING GOOD!!!!!! imma try to keep up with this.

  • @PurpleBroadcast
    @PurpleBroadcast Před 2 měsíci

    Thank you for helping fellow youtubers by putting the music you use in the description, well all appreciate it

  • @iamtraditi4075
    @iamtraditi4075 Před 9 měsíci

    Hey, this is insanely cool! Great video ❤

  • @Potato__Editor
    @Potato__Editor Před 9 měsíci

    Beautiful explanation, im amazed

  • @nekrugderzweite8298
    @nekrugderzweite8298 Před 9 měsíci +1

    Beautiful animations. Thx

  • @bimbaj270
    @bimbaj270 Před 8 měsíci

    Your design is so clean, simple, and infinitely expandable!

  • @raedev
    @raedev Před 9 měsíci

    Very nice! Also some clarifications:
    • pistons don't need a long pulse to retract, they can retract with a normal single pulse. Technically you can get away with zero tick stuff to push multiple pistons in sequence at the same time but that gets very glitchy with update order shenanigans and you really don't wanna mess with that.
    • as others have pointed out, the reason you can't prove that the repeated steps are optimal is cause they aren't: the modular method is!
    • the act of sticky Pistons leaving behind a block when powered for a single tick is called "block spitting" and it was originally a bug, much like some other redstone features (quasi-connectivity comes to mind)
    • we technically have infinite piston extenders and retractors, though it's a bit cheaty to call then "extenders" since those are their own category of redstone tech: if you place a piston to push something that drags a sticky piston (facing backwards) with itself - such as a slime block - and then that triggers this piston to pull the other one along, you'd have a self-dragging contraption that moves infinitely until it encounters an obstacle. You can make the movement itself trigger pistons by using observer blocks. TA-DA! You have made a *redstone flying machine*! And fun fact, observers triggering when they move is ALSO a bug that became a feature! Aaaaah Minecraft...

  • @bengineer8
    @bengineer8 Před 9 měsíci

    Loved this! Answered questions I pondered.

  • @PennyLapin
    @PennyLapin Před 9 měsíci +2

    It was fun to follow along with the maths of deriving the sequences you used. Before watching past 2:30 I thought through the logic of a fast retraction sequence and found the same logic of alternating pulls and extensions explained by your parallelized sequence! The 13-block dilemma I also thought through several avenues of how to cut the sequence, but the same philosophy of 12-long chunks was shared by your solution.

  • @noahglimcher5445
    @noahglimcher5445 Před 9 měsíci

    I love this kind of video, hope you will continue to make them after SoME3. The incorporation and application of mathematics into minecraft was really well done. My one minor piece of constructive criticism is that, while I could feel that it worked, the proof that you showed for the retraction being optimal needed to be completed. Thank you so much for this great video.

  • @icyy9319
    @icyy9319 Před 9 měsíci

    This, kids, is a man of focus, commitment, and sheer will

  • @aaryananand7288
    @aaryananand7288 Před 9 měsíci +1

    Just came up with an idea for piston pushing optimization without parallelization.
    This is a pretty long comment, so if you don't like math, pls don't put yourself through pain by reading this.
    Defining variables :-
    total number of pistons = x (Let's say there are x pistons)
    piston push limit = L = 12
    piston's position argument = n (each time we identify a piston, let's call it n)
    time/steps taken = t (t here acts as a counter, counting the number of steps taken)
    Note : x and L here is a fixed values while y and n keep changing based on the state of the system.
    t starts at zero and is incremented each time a piston moves.
    Math:-
    mod = modulus function, returns remainder of the division of the two arguments
    // = floor function, returns the closest integer smaller than the division quotient
    n to be pushed = f(x, t) = mod(x, L) - t for t < mod(x, L)
    mod(x, L) + ((t + mod(x, L)) // L) + L - t + 1 for t >= mod(x, L)
    after each loop, t is incremented by 1 (t++)
    I'm pretty sure this should work. If there are any math smarty-pants who wanna double check this, pls lemme know if I went wrong somewhere...

  • @raxyl67
    @raxyl67 Před 9 měsíci

    This video is so cool, good job !

  • @wavez4224
    @wavez4224 Před 7 měsíci +1

    Honestly this is a great vid, the topic is interesting and presented very well.

  • @AscendingAdventures
    @AscendingAdventures Před 9 měsíci +2

    Minecraft is honestly what convinced me to go to engineering school.

  • @sorrellion1414
    @sorrellion1414 Před 6 měsíci

    This video was everything I was hoping it'd be from the premise. Very nice

  • @ThatWeirdCellist
    @ThatWeirdCellist Před 6 měsíci

    This helped me make a one sided stackable piston extender using coppet bulbs and I just wanted to say thank you for simplifying these things for us!

  • @joeyfloyd4741
    @joeyfloyd4741 Před 9 měsíci

    Nice job this gives me some great inspiration for some new machines.

  • @kalisz9135
    @kalisz9135 Před 9 měsíci

    It is just amazing work. I have very much respect to people like you, because you made whole video which have a lot of details and explains in easy way smart, little tricky and interesting thing

  • @lmartinson6963
    @lmartinson6963 Před 9 měsíci

    I love how this breaks things down. You're wrinkling my brain frfr.

  • @ceejayred
    @ceejayred Před 9 měsíci

    I’m so happy to see you participating is #SoME3

  • @dolamskudoiski306
    @dolamskudoiski306 Před 9 měsíci +2

    waaaait- the retraction sequence looks similar to playing towers of Hanoi. I feel there's some connection there.

  • @jojo989GD
    @jojo989GD Před 9 měsíci

    such a nice submission :D

  • @wolfiegames1572
    @wolfiegames1572 Před 9 měsíci +1

    As someone who loves both Minecraft and 3blue1brown, I absolutely adore this video

  • @yisus.avocado
    @yisus.avocado Před 9 měsíci

    I didn't know I needed this video, but I'm glad I watched it, really interesting!

  • @Yoyo-ct5yl
    @Yoyo-ct5yl Před 9 měsíci

    Started watching in the background while playing minecraft, just for background audio, but I have now spent the last 15 minutes just watching the video, standing still in minecraft. Nice work, very entertaining, and awesome :)

  • @jacksonburger2081
    @jacksonburger2081 Před 9 měsíci +2

    This is the best video I've seen in a while. Obviously math and redstone relate quite heavily, but somehow with the animations and explanation, it was very clear and concise. Thank you for your inspiration.

  • @deepmaths9677
    @deepmaths9677 Před 8 měsíci +1

    EXTENSION PARALLELIZATION is exactly what GPU's do comparatively to CPU's ... and there are engineers called CUDA programmers their job is to find a way to parallelize chunks of repetitive codes in order to take advantage of the shear amount of cuda cores that can parallelize process data

  • @0Friedrich
    @0Friedrich Před 9 měsíci

    did not expect to watch an math video to the end. good job!

  • @NovaSpaceAssociation
    @NovaSpaceAssociation Před 9 měsíci +1

    This was amazeballs... My head has exploded with brilliant math. Also the piston retraction is so trippy/mesmerizing!

  • @christophergilbert5988
    @christophergilbert5988 Před 9 měsíci +1

    Loved this video! Another interesting bit of minecraft math that I've been looking into is an algorithm for generating piston sequences for a piston door of any size

  • @nicholasd1655
    @nicholasd1655 Před 9 měsíci

    Your clarity is poetry.

  • @givrally7634
    @givrally7634 Před 9 měsíci

    A few observations :
    1. Extension length formula is 6*floor((n-1)/12)*(floor((n-1)/12)+1) + n
    2. For retraction, two different recursive formulas are possible, depending on whether you chose 1 or 3 for the 3 piston extender. You can choose to bridge the nth gap first and then recursively bridge the next gap, on and on, or you can do it the opposite way, bridging the 1st gap, then the 2nd, and so on.
    Indicating relevant subsequences with a semicolon, one sequence gives 1; 2, 1; 3, 2, 1, while the other gives 1, 2, 3; 1, 2; 1.
    Both are the same length. In recursive notation they both start with S(1) = 1, but the one in the video is Sequence(n) = Sequence(n-1), n - > 1, while the alternative is Sequence(n) = Sequence(n-1), 1 -> n.

  • @blacklight683
    @blacklight683 Před 9 měsíci +1

    The hardest part is retracting the block to its original place

  • @ebinmemes2298
    @ebinmemes2298 Před 9 měsíci +1

    the 13-piston example is best to illustrate that the 12-1, 13-1 system isn't optimal:
    If you trigger piston 1 first, then piston 13 has 12 blocks in front of it. the sequence 1, 13-1 would thus work the same as your sequence of 12-1, 13-1 while only adding a single piston push to the original.
    For something like 24 pistons, firing piston 12 first will "break off" the front set of blocks, then piston 24 can push the latter section, but then it stalls again so you need to push 12 again, then you can pust piston 23 etc.
    so the sequence becomes an alternation: 12,24,12,23,12,22 etc. which should end up being a lot faster than 12-1, 24-1
    I've not finished the video but i saw you ask so i thought i'd post. I tried to build something in creative mode really quickly to see what i can do but realised i don't know how to pulse the redstone signal yet lol.

  • @glyveozone7303
    @glyveozone7303 Před 9 měsíci

    this vid has some top notch quality btw 🔥