7.2: Wolfram Elementary Cellular Automata - The Nature of Code

Поделиться
HTML-код
  • Опубликовано: 9 июн 2024
  • This video covers the basics of Wolfram's elementary 1D cellular automaton.
    (If I reference a link or project and it's not included in this description, please let me know!)
    Read along: natureofcode.com/book/chapter-...
    A New Kind of Science: www.wolframscience.com/nksonli...
    Elementary Cellular Automaton: mathworld.wolfram.com/Elementa...
    github.com/shiffman/The-Natur...
    Help us caption & translate this video!
    amara.org/v/Qbvb/
    📄 Code of Conduct: github.com/CodingTrain/Code-o...

Комментарии • 246

  • @romanhrobot9347
    @romanhrobot9347 2 года назад +11

    I enjoyed this "stream of consciousness" style presentation and the "let`s have some fun with this great hobby" attitude. A nice refreshment after all the pompous, overstressed, getting a job oriented, "I`m better than others" programming videos that youtube is so full off. Your video took me back from the horrible "i have to program more or else" attitude that I got into, to "i want to program now!" joyful state.
    So... THANK YOU!

  • @ahmadalasadi3636
    @ahmadalasadi3636 4 года назад +143

    "this is not my best video"
    me : this is one of the best videos I've ever seen on youtube ^_^ .
    keep going bro , you are amazing .

    • @babyeater5234
      @babyeater5234 4 года назад +2

      lol simp

    • @ugurburan133
      @ugurburan133 2 года назад +1

      hahah true, best train ride I've ever had with this video

  • @denebvegaaltair1146
    @denebvegaaltair1146 2 года назад +6

    Wanted to give some appreciation for the efforts you took to make these videos. We can tell you, like the average engineer, is probably a little awkward. Yet you're obviously doing your best to lighten things up. Thanks you.

  • @stipplebyatomiclabrador5077
    @stipplebyatomiclabrador5077 7 месяцев назад +2

    That "if you're not too busy" comment around 7:30 really got me.

  • @roypaoloreal897
    @roypaoloreal897 7 лет назад +45

    I am learning all by myself and I gotta say that this is the explanation I want to see. Well done explaining this! I also like the enthusiasm. It feels like you're a friend discussing. Keep up the good work! :D

    • @TheCodingTrain
      @TheCodingTrain  7 лет назад +4

      I'm so glad to hear, thank you!

    • @roypaoloreal897
      @roypaoloreal897 7 лет назад +1

      No problem. Would you create more of these vids? I'm interested in 2D CA and I hope you'll create more videos about that.

    • @randytighe7150
      @randytighe7150 2 года назад +2

      Totally agree - the enthusiasm is infectious (in a very good non pandemic way) - this is great!!

  • @loic.bertrand
    @loic.bertrand 5 лет назад +29

    14:27 "This is not my best video, but I'm gonna keep going" 😂😂😂😂😂😂😂

  • @friendly.mammal
    @friendly.mammal 3 года назад +1

    Got here because I picked up A New Kind of Science on a whim with very little prior knowledge, and I needed help visualizing how c.a. work. It makes me really happy to be able to learn from someone who clearly thinks the material is as exciting and fascinating as I do. It's nice to know I'm not the only one who gets passionate about how cool this stuff is, lol :) Thanks for the help!

  • @michalbotor
    @michalbotor 6 лет назад +40

    shorter way to implement rules function would be:
    int rules( int left, int me, int right ) {
    int idx = 4*left + 2*me + right;
    return ruleset[ 7 - idx ];
    }

    • @egregory314
      @egregory314 4 года назад +3

      Yes!!!! 7 - idx This is the fix I needed for my code to agree with Wolfram's output. Thanks.

    • @greenaum
      @greenaum 2 года назад

      @@egregory314 Ah, you had your table upside-down!

    • @greenaum
      @greenaum 2 года назад +1

      You could use (left

    • @adiaphoros6842
      @adiaphoros6842 2 года назад +1

      @@greenaum For multiplication or division by powers of 2, a good compiler will optimize that to bit shifts anyway.

  • @beenn15
    @beenn15 6 лет назад +79

    the framerate in the clip makes me dizzy.

  • @pavlosstefanidis7145
    @pavlosstefanidis7145 28 дней назад

    Extremely helpful for both my project and my understanding of this topic... This series of videos is truly amazing and you make it very interesting too. Whats more, in the last video you proposed some ways to apply c. a. and expand our knowledge on them. I appreciate your work very much.

  • @guitarmann3001
    @guitarmann3001 2 года назад +1

    This was my introduction to CA and I found it very helpful for my understanding and very amazing results! Thanks!

  • @9wattcat
    @9wattcat 3 года назад

    Thank you so much for making this video! Not only did you make the subject interesting to learn but your explanation finally made it click for me. Again, many thanks

  • @lucia4062
    @lucia4062 7 лет назад +1

    I just found your channel and boooy i am addicted to it!

  • @mybluemars
    @mybluemars 3 года назад +5

    First let me say that I love your videos!
    It took me a while to figure out the logic of Wolframs rulesets, but once it clicked now I'm hooked.
    I am curious though. At 5:52 You made up a rule of (00101110) which is Wolframs ruleset #46. Ok, all is well in my mind, since 46 is the decimal equivalent of binary 00101110. But when I look at your code at 10:27 I got confused. This is because when I compare the decimal rule numbers in your code comments they don't correspond to Wolfram's rulesets. For example, 01111011 should be 123 not 222, since 222 has a binary equivalent of 11011110 . Can you explain this? Am I missing something?
    -------------------
    (edit) Never mind, I see now that they are backwards in your array. Example: the conjugate of ruleset = {0, 1, 1, 1, 1, 0, 1, 1} is 11011110.
    -------------------
    Thank You!

  • @icaruslives4748
    @icaruslives4748 7 лет назад +1

    The only coding channel that I enjoy!

  • @sallerc
    @sallerc 7 лет назад +14

    Great explanation of CA, thanks man. And yeah, really like your teaching style :)

  • @TheGlitch11
    @TheGlitch11 3 года назад +3

    And how rules work in the margins of the array where reference can be made only for 1 or 2 cells of the previous generation?

  • @AjayKrews
    @AjayKrews 3 года назад +5

    Just love all this energy and passion! Makes the content a lot more engaging! Kudos!

  • @djalexander968
    @djalexander968 5 месяцев назад

    appreciate you taking the time out of work to give out free education, helps those that wont end up going into collegiate level stuff, but still want to learn
    i also noticed you laughing at the quality, but i subbed just for this, it was super helpful!

  • @iangolsby8471
    @iangolsby8471 6 лет назад +2

    I noticed that when you make your temporary array to calculate the next generation you're making a for loop to copy all the elements over. This works fine but Processing3 has a built-in function that does this for you. It's called arrayCopy. So you may replace your for loop with arrayCopy(gen, nextGen); or whatever you want to call your arrays. (The first parameter is copied into the second).

  • @thabo256
    @thabo256 2 месяца назад

    I like how he just redid this video this year

  • @jjgsfamily4353
    @jjgsfamily4353 7 лет назад +2

    Thanks for your wonderful lecture...

  • @nikobekris8542
    @nikobekris8542 8 лет назад +2

    Great video! Really enjoyed your way of explaining the topic. Keep it up I just subed!

  • @leilalovegood8364
    @leilalovegood8364 6 лет назад +1

    CA is amaaaaazing!! And thx for the video!

  • @mushman05
    @mushman05 8 лет назад +236

    cocaine is hell of a drug.
    But very good video!

    • @TheCodingTrain
      @TheCodingTrain  8 лет назад +37

      +mushman05 hah. Thanks for the feedback.

    • @e.1220
      @e.1220 4 года назад +7

      @@TheCodingTrain I don't agree with that feedback. Good video all around!

    • @HostanGouthier
      @HostanGouthier 4 года назад +4

      You are a sad individual!

    • @iworeushankaonce
      @iworeushankaonce 4 года назад +9

      you could get double experience if you watch it in 2x

    • @lmv2s
      @lmv2s 4 года назад +5

      MATH. Not even once.

  • @patrickharvey9361
    @patrickharvey9361 5 лет назад

    Hey @coding train great video! I’m currently a computer science student tasked with creating a python program (rule_110(x,y)) where x is “width” or number of cells and y is the number of generations/time steps. This helped in understanding CAs in general, but is there way to modify the code such that it prints characters versus programming an image? Also, how does one program in python so that it computes the next generation but still maintains the values from the previous generation?

  • @moumitaghosh7368
    @moumitaghosh7368 4 года назад +1

    Wonderful way of teaching. Plz provide a lecture how to implement irregular cellular automata

  • @flipvanwijk
    @flipvanwijk 8 лет назад +7

    Great video! I just started my Algorithms & Complexity course, which features CA's and didn't quite understand the concept fully. Your videos are really helpful and also fun to watch, due to your enthusiasm! Keep it going!

    • @MrThelol2030
      @MrThelol2030 8 лет назад

      +Daniel Shiffman would you please make another video about Elementary Cellular Automata ... you seem to understand it more than wolfram though.

    • @TheCodingTrain
      @TheCodingTrain  8 лет назад +2

      +JL KL I'm hoping to get to remake some of these videos with higher quality and using JavaScript at some point!

  • @memeveels1387
    @memeveels1387 8 лет назад +7

    :) informative and fun! Best way to learn Thnx!

  • @danny_racho
    @danny_racho Год назад

    Very nice! I followed your example and did this today as well on my channel using MATLAB. Cellular Automata!!

  • @Beesheep
    @Beesheep 3 года назад

    14:04 "or previous videos" and the swag is amazing - thanks for the video!

  • @zbnmth
    @zbnmth 4 года назад +1

    5:22 :'-D
    Excellent explanation though. I'm already familiar with CA's, and am learning python 3.0 to attempt philosophical in-silica experiments, just stumbled upon your video and am enjoying the side-info a lot. And your enthusiasm is contagious.
    EDIT: 8:03, I'm slapping my knees.

  • @michadreksler2401
    @michadreksler2401 3 года назад +2

    18:30 The problem here is that this is not "complete randomness". Behaviour of automata is strictly determined, non-chaotic, and depends just on starting values. It doesn't even depend on random number generator, because.....there is ..... simply.....not present any random number generator in the code - just a set of rules. If you repeat your experiment milion times, up to a infinite number of iterations you'll get exactly the same results, depending just on 1. Set of rules, and 2. Starting values.

  • @DonaldKronos
    @DonaldKronos 6 лет назад +1

    At 4:18, in a sense you were correct to say that you don't evolve generation 1, but rather compute it. However, there is a hidden accumulation of change (or potential change) over multiple cells in the production of generation 1, and any accumulation of change is evolution. Generation 2 is of course unmistakably evolved from generation 0 by way of generation 1.

  • @bradsillasen1972
    @bradsillasen1972 Год назад

    Very helpful, and fun tut! Thanks :)

  • @jaschanarveson5550
    @jaschanarveson5550 2 года назад

    This has probably been commented upon already, but: niiiiiice choice of shirt for this video. Full marks.

  • @michadreksler2401
    @michadreksler2401 3 года назад

    8:00 What about border values? Do we "wrap" all the array, so -1 index becomes n, and (n+1) becomes zero index? Or we make special rules just for one neighbour at the border?

  • @olli3686
    @olli3686 2 года назад

    16:45 For those asking for a way to quickly index, you may do a*2^2+b*2^1*c*2^0 = 4*a+2*b+c for this example (neighborhood=3 squares, base=2). This results in ::: return ruleset[4*a+2*b+c];

  • @themartingcastaneda
    @themartingcastaneda 4 года назад +1

    You are hilarious. I wish I had once a teacher half -- no, a quarter as fun as you are.

  • @davidianmusic4869
    @davidianmusic4869 2 года назад +1

    Great vid, love the meta stuff, just crushing that 4th wall.
    I did get some comprehension of ca I didn’t have before, thanx.
    You probably know this by now, but wolfram alpha does use rule 30 as a pseudo random generator. Good intuition!
    Hitting subscribe now.

  • @RaccoonEatingCacti
    @RaccoonEatingCacti 5 лет назад +2

    It would be interesting to see what happens if you could change the rule set between generations. An oscillation between rule 30 and 110, something to that effect. I would imagine that the capacity for complexity would explode exponentially, especially if you determined the rule set by sampling eight consecutive cells from rule 30, each generation changing the rule set. This wouldn't be difficult to do with Python, thanks for the stimulating video!

  • @klausalberts2240
    @klausalberts2240 8 лет назад +2

    Thank you for that great Lesson :-) !

  • @vinzbrain
    @vinzbrain Год назад

    Great video! Very easy to follow and entertaining. There is a thing I don't understand. If gen0 is an array filled with 0, for any ruleset where 0,0,0 = 0, how does anything at all happen?

  • @diptendumukherjee9316
    @diptendumukherjee9316 4 года назад

    what will be the right neighbour cell(or precisely the array index) of the last cell in the array?

  • @acos21
    @acos21 4 года назад +4

    The best example ever of "being all over the place". Lol. Great lecture btw.

  • @TheGroundskeeper
    @TheGroundskeeper 5 лет назад +5

    14:30 "this is not my best video". maybe not, but the content is totally solid. take a breath man, slow by 10%, it's good stuff

  • @SENG-lq4kt
    @SENG-lq4kt 2 года назад

    I have a question which is about on video 6.22, he say 000 represent 0, 001 represent 0, 010 represent 1 and .... so on. Why 000 is represent to 0 , can it become 1? or it just user to random define which mean that we can defined 000 as zero or one both is accepted?

  • @zaidsserubogo261
    @zaidsserubogo261 5 лет назад

    The beauty of complex(nondeterminism as a function of determinism) automatic evolutionary process happening in complex limits.

  • @eduardosuela7291
    @eduardosuela7291 4 года назад +2

    What if we make a loop of rules...
    Line 1 -> rule 4,
    line 2 -> rule 222,
    L3 -> r134, and loop again.
    With 2 rules looping you'll have 64k behaviours

    • @tim40gabby25
      @tim40gabby25 3 года назад

      .. or weight with sequences of primes, or add in rules the choice of which is determined by the previous line.. did you get anywhere with your suggestion? UK amateur here :)

  • @mateothode5603
    @mateothode5603 Год назад +1

    This man is perfect

  • @ktvx.94
    @ktvx.94 3 года назад

    Hey man these videos are awesome. This one's really old so I don't know how you do them now, but they're way better than you say! Though even then, you say it in a relaxed, more human way so not annoying self deprecation.
    That aside, I'm gonna take a guess and say that the fractal rule counts as complexity since in a way applying the same rule in each iteration is repetition, regardless of what rule it is. I hope it's not silly-level wrong, I'll find out!

  • @user-cm1zh4jc5r
    @user-cm1zh4jc5r 5 лет назад

    for people using processing, if you try to input ruleset in right way (github files need you to implement ruleset in reversed way) just make change in
    CA file this way.
    CA(int[] r) {
    ruleset = reverse(r);
    cols = width/w;
    rows = height/w;
    matrix = new int[cols][rows];
    restart();
    }

  • @user-hh2is9kg9j
    @user-hh2is9kg9j 2 года назад +1

    How to calculate the cells on the edge? They have only two cells above them.

  • @niaschimnoski882
    @niaschimnoski882 6 лет назад +2

    What if I map my 1-dimensional CA onto the surface of a circle, and then I make every cell the same state: do they all cease to exist? What if my CA demands an intermediary state and-or translation?
    Would it be forced oscilate?
    What are some solutions to an edge case like this?

    • @niaschimnoski882
      @niaschimnoski882 6 лет назад

      What if, instead of tracking each cell, we just scanned the entire image, gave each state a unique color, and then did a single gpu calculation on the entire frame, regardless of how many things are going on at once? [Because it would require the same number of computational steps, on every iteration of ths engine's loop]

    • @tim40gabby25
      @tim40gabby25 3 года назад

      @@niaschimnoski882 sounds like a pixelation of sorts? UK amateur here.

  • @martinlaslett8600
    @martinlaslett8600 8 месяцев назад

    love it - interesting and made me laugh out loud! thanks

  • @JT-nq9vh
    @JT-nq9vh 7 лет назад

    This is great, thank you

  • @mike_o7874
    @mike_o7874 6 лет назад +1

    i actually did a random start of cells,
    when u said try make one your self last video
    and each cell calculates its value by saying
    if(neigbor[x] == 1)
    state = !state;
    that the result
    sure that gonna be some rule
    like
    01101001
    that kinda xor
    or rule 113

  • @zhabiboss
    @zhabiboss Год назад

    I have more clue of how good he is coding everything than fps the video has

  • @cometmace
    @cometmace 5 лет назад +1

    You've inspired me. @12.17, you talk about a 2d grid that becomes a frame in a sequence of frames in an animation. How about -- rather than a 1d automata that becomes a 2d grid, how about a 1d grid of cells that's animated. OR how about a sequence of 2d grids, stacked one on top of the other to form a 3d shape. Then add a left-eye / right-eye projection and view it cross-eyed (or the other way). And then rotate it about any axis in the same way chemists might rotate a molecule in space. I wonder if that will yield new insights into the rule sets.

    • @Raghad-mz8el
      @Raghad-mz8el 4 года назад

      I've thought the same thing, I'd love to see how it would look in 3d

  • @MacShrike
    @MacShrike 2 года назад

    I only wonder how you get the left index of cell[0](or the right for cell[cells.length-1]) without a boundary constraint(and more important not causing an index out of range on the array itself)? Does it wrap around? Is it always 0, or 1? Don't see it in the code. Boring question but still..

  • @sp0tt3r
    @sp0tt3r 5 лет назад +5

    Hi! I know this video is quite old but I was trying to create a wolfram elementary simulator in python, but I ran into a problem, which is handling edges.
    What am I supposed to do with the edges of the grid, since I can't make the grid infinite? If I simply try to request the next cell of the last, I get an index error.

    • @reintael4287
      @reintael4287 2 года назад

      There are two ways edges are usually handled. You either set a fixed boundary condition or you wrap the boundaries like a pac-man game.

  • @Husamadin
    @Husamadin 8 лет назад

    Thanks Daniel, ,,,I have one question please, how we compute the transition rules?

    • @TheCodingTrain
      @TheCodingTrain  8 лет назад +1

      +Husam Atallah This is described here: natureofcode.com/book/chapter-7-cellular-automata/

  • @aditya95sriram
    @aditya95sriram 3 года назад

    Gotta love that retro Dan enegy :)

  • @klausalberts2240
    @klausalberts2240 8 лет назад +1

    Are Wolfram's Rulsesets also working for 1D Cell automatons with 1 or 2 Cells?

    • @TheCodingTrain
      @TheCodingTrain  8 лет назад +1

      I'm not sure exactly what you mean, but you can see all the rulesets for 1D CAs here: mathworld.wolfram.com/ElementaryCellularAutomaton.html

    • @klausalberts2240
      @klausalberts2240 8 лет назад +1

      Thank you for the Link :-) ! I also read this chapter natureofcode.com/book/chapter-7-cellular-automata/ of your book, because i did not understood the concept of the automatons fully. But after your video and the chapter of your book, things are now much more clearer :-) .

  • @vishavjeetsinghthakur
    @vishavjeetsinghthakur 4 года назад

    Great video

  • @AidenOcelot
    @AidenOcelot 7 лет назад

    So we start with a single cell. then with a rule set in binary up to 256 changes the cells below it?
    I'm gonna program this

    • @AidenOcelot
      @AidenOcelot 2 года назад

      I remember writing this, I did well programming it

  • @mukeshkumar2265
    @mukeshkumar2265 3 года назад

    Amazing video :)

  • @shaikmaricar6685
    @shaikmaricar6685 4 года назад +1

    Amazing.

  • @ishi92
    @ishi92 7 лет назад +1

    how do you get the screen to follow the animation down the screen?

    • @250nate
      @250nate 7 лет назад

      I've been thinking the same thing

    • @Tin98Tin
      @Tin98Tin 7 лет назад

      Maybe he translates the axis a distance equal to the height of a new row

  • @krzysztofp923
    @krzysztofp923 5 лет назад

    what did you take, is it expensive ?

  • @YQN2149
    @YQN2149 2 года назад

    @17:43 Isn't repetition a necessary part of complexity?

  • @hanniffydinn6019
    @hanniffydinn6019 7 лет назад +8

    I got a seashell with a rule 135 ish pattern on..... These exist in nature...

    • @tim40gabby25
      @tim40gabby25 3 года назад +1

      Hi. UK here. Good spot - me too. Follow your observation up.. :)

  • @djbabbotstown
    @djbabbotstown 2 года назад +1

    If stacked 1D CA generate emergent 2D patterns. Does a 2D CA generate 3D patterns when stacked in a lattice? Reminiscent of holographic principle?
    "The holographic principle is a tenet of string theories and a supposed property of quantum gravity that states that the description of a volume of space can be thought of as encoded on a lower-dimensional boundary to the region"
    Space and the dynamic things in it being an emergent 3D pattern. Which means we are already ghosts of some curious nature.

  • @durbadas3596
    @durbadas3596 10 дней назад

    thank you so much

  • @divyanarayanan1927
    @divyanarayanan1927 7 лет назад

    could u please tell whether u r using open gl to execute the above code or something else?

    • @JGunlimited
      @JGunlimited 7 лет назад

      He's using Processing in this video. Check out his other videos if you want to learn more about it.

  • @josephlicari8830
    @josephlicari8830 2 года назад +1

    This guy loves his automata

  • @olli3686
    @olli3686 2 года назад

    There is a lot of assumption that some of the results are completely random non-repeating, but I don't see any lines of code checking to see if any lines repeat.

  • @rmrfboy
    @rmrfboy 3 года назад

    oh wow. this is seriously cool

  • @kaplumbagaefendisi2837
    @kaplumbagaefendisi2837 8 лет назад

    can we use CA for solve differential equation. Like finite difference or FEM. for example I wanna solve 2D Laplace equation with some boundary.

  • @ipdavid1043
    @ipdavid1043 5 месяцев назад

    thank you....❤

  • @franchello1105
    @franchello1105 Год назад

    Advent of Code 2018 Day 12 uses similar ideas. It uses a 5 cell neighborhood.

  • @ipdavid1043
    @ipdavid1043 5 месяцев назад

    thank you

  • @sspirial
    @sspirial 17 дней назад

    wow - this is so profound

  • @ulkem
    @ulkem 4 года назад

    i have no idea what each of these words mean separately or as a whole but they sounds so fucking cool that I had to see whats this about

  • @aronpop1447
    @aronpop1447 4 года назад

    nextgen[i] will skip 0 and cells.length because u start from 1 and end at cells.length - 1 which is logical but that will lead to undefined behavior cause nextgen[0] and nextgen[cell.length - 1] is uninitialized

  • @irsarafaqat7678
    @irsarafaqat7678 4 года назад

    How u find rule set plz explain

  • @marvinfernandes6191
    @marvinfernandes6191 2 года назад

    What if we dó calculate with one state?

  • @muzzers2776
    @muzzers2776 4 года назад +1

    Hocam bizi nerelere attınız ya. Adam kokain çekip gelmiş herhalde. CS223 projesini bitirmenin sırrı bu mu yoksa?

  • @Beesheep
    @Beesheep 3 года назад +1

    12:50 I think it is "Repetition"

  • @papinkelman7695
    @papinkelman7695 6 лет назад +12

    Warning: in 2 years time you are going to fall of your bike.

    • @aa-rh1lp
      @aa-rh1lp 5 лет назад +7

      Your comment haunts me to this day. I'm still waiting.

    • @ziquaftynny9285
      @ziquaftynny9285 5 лет назад +3

      jokes on you. I never ride a bike

    • @h-Films
      @h-Films 4 года назад

      success you were correct

    • @Theooolone
      @Theooolone 4 года назад

      Ok what how did you know

  • @hamburgrhelpless
    @hamburgrhelpless 5 лет назад +3

    repetition is naturally occuring when it comes to true randomness

    • @ghostnoodle9721
      @ghostnoodle9721 3 года назад +3

      Wtf "true randomness" doesnt exist, just because we cant predict when/where/how its going to happen

  • @rifkihusnilmujalas4570
    @rifkihusnilmujalas4570 5 лет назад

    What kind application you use?

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад +1

      This series uses Processing (which is built on top of the Java programming language). For more info, visit processing.org and also this video might help ruclips.net/video/AmlAiKsiy0o/видео.html.

  • @peterfarrell66
    @peterfarrell66 8 лет назад

    Hi, Dan, excellent video! But the github links are broken.

  • @fabse64
    @fabse64 8 лет назад +1

    What about cells that don't have two neighbors? Such as the left-most and the right-most ones.

    • @RussellTeapot
      @RussellTeapot 8 лет назад +3

      you can deal with cells on the "borders" in two ways: 1) you assign a different neighborhood or 2) you wrap the borders around. For the first case, instead of having a 3-neighborhood (the central cell, the one on the left, the one on the right) you could use a 2-neighborhood (the cell itself and the immediate neighbor) for the leftmost and rightmost cell, since obviously there's only one cell adjacent to the cell on the border.
      However, usually the second solution is used: imagine that the "strip" of cells is made into a ring, by gluing together the leftmost cell and rightmost one. Now these two cells can have a 3-neighborhood.
      Just for clarification: let's say that we have four cells,which are labeled A-B-C-D. For B, the neighborhood is A-B-C. For C, is B-C-D. If you bend the strip into a ring, now A is close to D, so the neighborhood of A becomes D-A-B, and the n.b. for D becomes C-D-A. Makes sense?

    • @fabse64
      @fabse64 8 лет назад +1

      Yes, very much so, thank you. The alternative is to just assign cell -1 and n a fixed value, right?

    • @RussellTeapot
      @RussellTeapot 8 лет назад

      fabse64 ah yes, this is another option that I forgot!

    • @TheCodingTrain
      @TheCodingTrain  8 лет назад +2

      Great answers!

    • @RussellTeapot
      @RussellTeapot 8 лет назад

      Daniel Shiffman thank you very much :D Great video, by the way!

  • @michalbotor
    @michalbotor 6 лет назад +4

    and now to the question, that everybody here craves to ask but is afraid that it will open a pandora's box..
    how to we handle the left most and the right most cells, hah? ;p
    examining your generate function i noticed, that you simply let them remain unchanged, treating them as what i believe are called a shadow cells: the cells that serve as a source of information for their neighbors, but do not constitute as an actual cells themselves.
    and this is great, don't get me wrong. but i just wonder whether new interesting, never-seen-before patterns couldn't have emerged if we've linked the right most cell with the left most one instead (i.e. by treating our grid like a circle and not like a segment).

    • @petitbuddha
      @petitbuddha 5 лет назад

      you just give them a default value. wether 0 or 1

    • @Anonymous-sw5jx
      @Anonymous-sw5jx 5 лет назад

      actually the left and rightmost cells are being used the generational algorithm displays top down and you can see the wave outward from the middle cell because in this particular cellular automaton they always start with 1 singular cell in the middle preactivated. The outcome depends on the particular rule as well as the starting world (Which the latter was controlled for this demonstration; always 1 cell preactivated in the same location in GEN1).

    • @Anonymous-sw5jx
      @Anonymous-sw5jx 5 лет назад +1

      the tape is infinite in both directions i believe

    • @tim40gabby25
      @tim40gabby25 3 года назад

      Like space invaders?.. you could certainly join the left and right edges to form a tube, then the tube rims to form a doughnut..

  • @jwrm22
    @jwrm22 7 лет назад

    Pretty interesting. Only it seems to be overly complicated. It's easier to understand but not at all resource friendly.
    Note: I''m used to write for micro controllers with 2k ROM and 256B of RAM.
    My approach:
    I would replace the array for a single n bit value.
    1. Mask the bits i need to compute the next generation.
    2. Lookup the next value of the cell.
    3. Repeat 1,2 for the binary length
    There are some tricks like making a struct or array of binairy numbers. (saved as one int)

  • @peterhayman1789
    @peterhayman1789 7 лет назад

    omg decrese cell size over time = suuuuuper cool!!!! :-D

    • @TheCodingTrain
      @TheCodingTrain  7 лет назад

      nice tip!

    • @alixturcq2282
      @alixturcq2282 7 лет назад

      I've been trying to do that unsuccessfully, how did you manage to do it ?

    • @peterhayman1789
      @peterhayman1789 7 лет назад

      full project: 1drv.ms/f/s!AlCwAhlxoW_Qg8UdNR5jmg-o-DaXTw
      These are the functions that play with the resolution each frame
      void InitCells(int res_){
      res = res_;
      xLen = width/res;
      yLen = height/res;
      cells = new int[xLen][yLen];
      cells[xLen/2][0] = 1;
      }
      This is my render function, essentially mapping the pixels to elements of the 2D cell array. this seems to be a very fast way of drawing lots of little squares
      void Render() {
      loadPixels();
      for (int y = 0; y < height; y++) {
      for (int x = 0; x < width; x++) {
      int iX = constrain( x/res, 0, xLen-1); //heres where it maps
      int iY = constrain( y/res, 0, yLen-1); //and here :-)
      if (cells[iX][iY] == 0) {
      pixels[x + y * width] = color(255, 0, 255);
      } else {
      pixels[x + y * width] = color(0, 255, 0);
      }
      }
      }
      updatePixels();
      }

  • @vcjg287
    @vcjg287 4 года назад +3

    I wonder how this dude would look like on high caffeine amounts and a nice dosis of not sleeping huehuehue

  • @joshstubblefield9093
    @joshstubblefield9093 2 года назад

    At 13:00 it looks like you did your binary math a little off. The right most bit represents 1, not 2. You were just shifted by one place that’s all. So 0101 would be 5, not 10 for example.

  • @iliapopovich
    @iliapopovich 4 года назад

    He enjoys himself:)