Coding Challenge

Поділитися
Вставка
  • Опубліковано 31 тра 2024
  • In this holiday coding challenge, I create a "Brownian Tree Snowflake" in Processing (Java). This video was recorded as part of a fundraiser for the Processing Foundation. Code: thecodingtrain.com/challenges...
    🕹️ p5.js Web Editor Sketch: editor.p5js.org/codingtrain/s...
    🎥 Previous video: • Coding Challenge #126:...
    🎥 Next video: • Coding Challenge #128:...
    🎥 All videos: • Coding Challenges
    References:
    💰 Support the Processing Foundation: processingfoundation.org/supp...
    💾 Code Golf - Draw a Snowflake: codegolf.stackexchange.com/qu...
    ❄️ Snowflake: www.flickr.com/photos/golanle...
    Live Stream Archive:
    🔴 Coding Train Live Holiday Telethon 2018: • Coding Train Live: Pr...
    Related Coding Challenges:
    🚂 #34 Diffusion-Limited Aggregation: • Coding Challenge #34: ...
    🚂 #52 Random Walker: • Random Walker in p5.js...
    🚂 #128 SketchRNN Snowflakes with ml5.js: • Coding Challenge #128:...
    🚂 #129 Koch Fractal Snowflake: • Coding Challenge #129:...
    🚂 #155 Kaleidoscope Snowflake #SupportP5: • Coding Challenge #155:...
    Timestamps:
    0:00 Introduction
    0:51 Brownian tree
    1:46 Diffusion Limited Aggregation
    2:18 Snowflakes have a hexagonal pattern
    3:52 Create a Particle class
    4:52 Add a random walk to the particle
    6:19 Translate to the center
    7:02 Make an array of snowflakes
    8:00 Write a finished function
    9:05 Write an intersects function
    11:04 Add kaleidoscope
    13:18 Edit code to add a vector
    14:00 Constrain particle to a slice of the hexagon
    15:52 Speed up the animation
    16:43 Improve branching
    17:33 Randomize the starting position
    18:10 Conclusion and creative possibilities
    19:05 Please consider supporting the Processing Foundation!
    Editing by Mathieu Blanchette
    Animations by Jason Heglund
    Music from Epidemic Sound
    🚂 Website: thecodingtrain.com/
    👾 Share Your Creation! thecodingtrain.com/guides/pas...
    🚩 Suggest Topics: github.com/CodingTrain/Sugges...
    💡 GitHub: github.com/CodingTrain
    💬 Discord: thecodingtrain.com/discord
    💖 Membership: ua-cam.com/users/thecodingtrainjoin
    🛒 Store: standard.tv/codingtrain
    🖋️ Twitter: / thecodingtrain
    📸 Instagram: / the.coding.train
    🎥 Coding Challenges: • Coding Challenges
    🎥 Intro to Programming: • Start learning here!
    🔗 p5.js: p5js.org
    🔗 p5.js Web Editor: editor.p5js.org/
    🔗 Processing: processing.org
    📄 Code of Conduct: github.com/CodingTrain/Code-o...
    This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecod...
    #browniantreesnowflake #snowflakegenerator #diffusionlimitedaggregation #processing

КОМЕНТАРІ • 116

  • @markfelixm
    @markfelixm 5 років тому +2

    I’ve been watching your videos for a few months now and learn something new in each one. Just wanted to say thanks for putting this resource out there and making it as accessible as it is. Season’s greetings! Thank you! (EDIT: space-filling curves could be a fun video ;) )

  • @Randios187
    @Randios187 5 років тому +1

    I'm digging that coding trail sweater, haha. I always love these coding challenges; thanks again for all your hard work.

  • @muskel7587
    @muskel7587 5 років тому +32

    You really do good job 💪 I understand more than from tutorials, courses etc. After that I'm trying write my own code. There is just a practice ! You explain everything and that's help me a lot ❤️ Merry Christmas from Poland 🎅

  • @sonik382
    @sonik382 5 років тому

    Merry Xmas! You made all of this look so simple ...every time I watch your video I learn something new! Thank you Dan!

  • @rainerwaeger
    @rainerwaeger 5 років тому +1

    Merry Christmas from Germany! Thank you for your tutorials and keep going!

  • @adityaruplaha
    @adityaruplaha 5 років тому +2

    That last one looked so awesome!!!! 🤩

  • @thibautmodrzyk6215
    @thibautmodrzyk6215 5 років тому +1

    it looks so good !! Good job

  • @AllanMedeiros
    @AllanMedeiros 5 років тому

    As always, Wonderfull! I worked with DLA (for scientific research) when I was an undergrad student. Never thought it would be so much fun!!! Thank you!

  • @NitishKumarPatra
    @NitishKumarPatra 5 років тому +5

    I just saw your channel.. You are awesome. So much of things to learn.

  • @friendofcomputer
    @friendofcomputer 5 років тому

    Wow, can't skip these videos once started watching. Thank you so much for teaching us.❤

  • @Entrxpy_
    @Entrxpy_ 5 років тому

    Thanks for the work you are putting into your channel, it is really great :)
    Merry christmas from Germany :)

  • @ryanarmstrong1788
    @ryanarmstrong1788 10 місяців тому

    This is so over my head it’s unbelievable

  • @LoPhatKao
    @LoPhatKao 5 років тому +2

    Dan, whoever made you that sweater is great :D
    "never forget the this dot"

  • @sidim.aourid9958
    @sidim.aourid9958 5 років тому

    Thank you again for this interesting video and Merry Christmas from Toronto.

  • @tentative_flora2690
    @tentative_flora2690 5 років тому +4

    Render them to their own image buffers and use each one as a particle in a gravity + Brownian motion simulation. Result = realistic snowfall. Or if left as just arrays of particles, allowed them to have a speed, and made them able to break if going to fast when they hit the ground. Then let them pile up on the ground.

    • @TheCodingTrain
      @TheCodingTrain  5 років тому +1

      Great idea! I hope someone does this 😀

  • @sea-cf9fo
    @sea-cf9fo 5 років тому

    Awesome! It’s really cool. 😄

  • @marcosimfeld2876
    @marcosimfeld2876 5 років тому +3

    I love your Videos!😱😱,
    thanks to you I started my channel because you inspired me!

  • @carlosmestra386
    @carlosmestra386 5 років тому +3

    Feliz Navidad desde Colombia 😊

  • @talkaufman8044
    @talkaufman8044 5 років тому

    Awesome video!

  • @eduardomartinez6521
    @eduardomartinez6521 5 років тому

    Thanks for these awesome challenges, its kind of inspiring and fun by the way you do them. Have a nice Holidays and you should make a working Rubiks Cube for another video

  • @raftiable
    @raftiable 5 років тому

    SO COOL!

  • @MsMiyabi88
    @MsMiyabi88 5 років тому

    anything u can coding, u sick dude

  • @FluXR3LieF
    @FluXR3LieF 5 років тому

    Really love your videos! A few others suggested physics; what about slingshots/catapult simulation?

  • @ahmedbadal3795
    @ahmedbadal3795 5 років тому

    u are legend man ...wish i can code like u...keep it up........

  • @jipfr
    @jipfr 5 років тому

    This is the coolest thing I've seen all week (yes, I know this video is 2+ months old)

  • @Oussamaabdallah
    @Oussamaabdallah 5 років тому

    Amazing

  • @johnniegilkerson4724
    @johnniegilkerson4724 4 роки тому

    How do you make the font bigger in processing?

  • @lapischicken
    @lapischicken 5 років тому

    Merry christmas (eve), Dan :>

  • @siddhantjain2402
    @siddhantjain2402 5 років тому +9

    How about ripple animation with motion detection? Tap anywhere and a ripple motion is there BUT it can collide with an existing ripple too. Seems fun, not sure how much of it is possible though. :)

  • @menthoelsr4871
    @menthoelsr4871 5 років тому +1

    Damn.. so cool

  • @robert3258
    @robert3258 5 років тому

    why are you using x_ and y_ in the constructor? does processing not support using this. to disambiguate?

  • @paraschavan014
    @paraschavan014 5 років тому +6

    To kill boredom
    I do programing
    I love to create things

  • @ajkhan1291
    @ajkhan1291 5 років тому

    Merry Christmas

  • @OonHan
    @OonHan 5 років тому +7

    Do a slingshot simulation!

  • @Abhishek-hy8xe
    @Abhishek-hy8xe 3 роки тому

    This is fascination

  • @morphman86
    @morphman86 5 років тому +10

    I want that Christmas sweater!

  • @luisaisat
    @luisaisat 5 років тому +1

    tks

  • @MarinusMakesStuff
    @MarinusMakesStuff 3 роки тому

    I'm trying to turn this into an array of points and then I'm trying to connect those points by using vertexes but I'm not able to retrieve the centers of the ellipses. I'm kinda lost here.

  • @alvinndchipmuck
    @alvinndchipmuck 5 років тому

    Dope

  • @ryonotrio6904
    @ryonotrio6904 5 років тому

    Idea for challenge: elastic collision of two objects: both one moving and one stationary , and both moving

  • @franksimon8375
    @franksimon8375 2 роки тому

    Good outfit

  • @crehenge2386
    @crehenge2386 5 років тому

    is there a way to automatically export the generated image as a PNG with the same resolution as the canvas?

    • @TheCodingTrain
      @TheCodingTrain  5 років тому +3

      Take a look at save() and saveFrame() in Processing.

  • @OonHan
    @OonHan 5 років тому +1

    10:00 when this dot works too well

  • @williansfaria1532
    @williansfaria1532 5 років тому

    Where do i get this sweater?

  • @krishnanshudey3831
    @krishnanshudey3831 5 років тому

    Tnx u sir it's awesome

  • @avi12
    @avi12 5 років тому

    4:07 The "var_" naming kills me inside

  • @johnniegilkerson4724
    @johnniegilkerson4724 4 роки тому

    How would l make this code work in eclipse java?

  • @Bigfootdu78
    @Bigfootdu78 5 років тому

    16:08 This is incredible

  • @nabeelarif4041
    @nabeelarif4041 5 років тому

    Where is he making these programs, I use intellij and it would take me days to do these programs

  • @mutated__donkey5840
    @mutated__donkey5840 5 років тому

    You are such a great programmer! Please attempt to make a rubik’s cube

  • @ark9983
    @ark9983 5 років тому

    A random walk is actually meant to be a random process with independent increments. It is dy that should be Gaussian distributed not y itself.

  • @ryanbrown172
    @ryanbrown172 3 роки тому

    I think you should make a long B roll video of all the graphics you have made with nice music as something to chill and watch. Please?

  • @Sccarlettex
    @Sccarlettex 5 років тому

    Yeyy

  • @roman000111
    @roman000111 5 років тому

    Go particle go, go particle go, go particle go, STOP!!

  • @JiaXueart
    @JiaXueart 3 роки тому

    hi, cool ,,,But I dont really understand why the count++ will be return 0??? Could you pls show me the right way? many thanks!!!!:)

  • @aartikadiyan1592
    @aartikadiyan1592 5 років тому

    Which software you are used?

    • @TheCodingTrain
      @TheCodingTrain  5 років тому

      This video uses Processing (which is built on top of the Java programming language). For more info, visit processing.org and also this video might help ua-cam.com/video/AmlAiKsiy0o/v-deo.html.

  • @miko007
    @miko007 5 років тому

    you really always should use "this.", thats good coding practice and prevents ugly hacks like your float x_ thing.

  • @AmZaDin14
    @AmZaDin14 5 років тому

    Any Python user here? How do you translate, scaling and rotate coordinate in Tkinter?

    • @JaspreetSingh-fo2qe
      @JaspreetSingh-fo2qe 5 років тому

      I don't know whether tkinter has any of those functions but i get around those by making my own functions. I did complete many of his challenges in python.
      It isn't recommended but I'm doing that so that i need to code everything that happens on the screen with the least possible use of library functions. I expect to make my base in programming stronger by doing this.

  • @darcipeeps22
    @darcipeeps22 5 років тому

    I feel like it’d be more snowflakey if you didn’t constrain the angle/particle destination to the one sector

  • @nerdiconium1365
    @nerdiconium1365 5 років тому

    Wow, you've never heard of code golf before

  • @firephoenix5556
    @firephoenix5556 5 років тому

    Woah I'm way earlier than normal. Only 1 hour ago?

  • @liukang81
    @liukang81 5 років тому

    I like you man. You’re intelligent guy. I wish I can be like you are. But I’m not , i am so disappointed my self! Right now I am started learning programming languages JavaScript & c++ they’re so complex too.

    • @JaspreetSingh-fo2qe
      @JaspreetSingh-fo2qe 5 років тому

      A tip would be to learn just one language first, but properly and thoroughly.
      I would recommend C++ over other languages if you ask me.

    • @JaspreetSingh-fo2qe
      @JaspreetSingh-fo2qe 5 років тому

      and get a high school level book that contains programming. That way you wont get overwhelmed by the code that is found in any "Introduction to programming" and still be able to build your base.
      Another tip: Don't get overconfident about solving a problem. Some things feel really easy and simple at first but when you attempt them then you get to know.
      Just be thorough with that book and see the results.

    • @JaspreetSingh-fo2qe
      @JaspreetSingh-fo2qe 5 років тому

      Once you've build your base then you can come over to youtube and see videos like these to understand the various problems that are encountered and what approach do programmers take to takle such issues.
      And don't expect to learn programming in a month or even 2 to 3 months. It will take time, a long of time even if you are diligent.

    • @liukang81
      @liukang81 5 років тому

      Thank you for your advice man. And I like to ask you one more question, what’s the programming languages should I take first, JavaScript, or c++, the both of them which ones is better to compare? Right now I’m just take self learning on this courses , it’s hard to understand without a constructor’s explains .thank you.

    • @JaspreetSingh-fo2qe
      @JaspreetSingh-fo2qe 5 років тому

      @@liukang81 I would recommend C++.
      There's a reason I asked you to start learning from high school books. They are simple. These books assume that the guy knows nothing about programming and that's why they are absolutely the best books to start learning.

  • @arenacloserst5474
    @arenacloserst5474 5 років тому

    jij ben nederlands or aren't you?

  • @billyjoe1057
    @billyjoe1057 5 років тому

    where can i learn processing online?

    • @whatsup7341
      @whatsup7341 5 років тому

      This channel. He has a playlist called
      "Learning Processing: A Beginner's Guide to Programming Images, Animation, and Interaction"
      After you finish that, he has a playlist (or alternatively or along-side it, his book) called
      "The Nature of Code: Simulating Natural Systems with Processing"

    • @TheCodingTrain
      @TheCodingTrain  5 років тому

      Indeed, here are two playlists to start from the beginning! There are also many other books and resources at processing.org and p5js.org.
      ua-cam.com/users/shiffmanplaylists?view=50&shelf_id=14&sort=dd
      ua-cam.com/users/shiffmanplaylists?view=50&shelf_id=2&sort=dd

  • @woutuuur
    @woutuuur 5 років тому +1

    I have an idea for another merch item:
    Roses are red
    Violets are blue
    Expected { or ;
    At line 32

  • @rukna3775
    @rukna3775 5 років тому +1

    can u please code "THE LIBRARY OF BABLE"????????????? PLSSSS!!

  • @avi12
    @avi12 5 років тому

    Dan, please go to Codewars and solve difficult Katas

  • @bibashkatel1090
    @bibashkatel1090 5 років тому +1

    which language are u using?

    • @oscard4801
      @oscard4801 5 років тому +1

      Bibash Katel He using Processing of Java

    • @TheCodingTrain
      @TheCodingTrain  5 років тому

      Indeed! This video uses Processing (which is built on top of the Java programming language). For more info, visit processing.org.

    • @Caraxian
      @Caraxian 5 років тому +1

      (He only said it like 6 times in the video)

    • @bibashkatel1090
      @bibashkatel1090 5 років тому +1

      caraxian .. i heard he said java many times but processing its the first time i have heard of .. and it is completely different from what we actually code in java .. so what i meant was , is it a different language or some kind of framework or library.. but now i got the point..

    • @Caraxian
      @Caraxian 5 років тому

      Bibash Katel fair enough

  • @TonzLanggoy
    @TonzLanggoy 5 років тому

    black haired santa... sexy... lol

  • @SavingShredz
    @SavingShredz 5 років тому

    You should make an erosion simulation as a challenge

  • @franksimon8375
    @franksimon8375 2 роки тому

    Christmas Sweater Alg

  • @adzo202
    @adzo202 5 років тому

    Not sure if anyone's commented this yet but it looks like you only randomised the initial particle. Great video though!

  • @gouripanda7517
    @gouripanda7517 5 років тому

    Hey, the website doesn't work.

  • @k1zmt
    @k1zmt 5 років тому

    Watch a water crystallization and you will guess the best snowflake.

  • @porigonopop
    @porigonopop 5 років тому

    Can't you just call the current particule.show instead of the whole snowflake ? Since it's the only moving part

    • @katherinegaymes
      @katherinegaymes 5 років тому +1

      except he is reloading the background each frame as well which clears the screen, thus he needs to redraw the snowflake. If he took out the part of re-drawing the background then the particles would leave a trail of their entire path

    • @TheCodingTrain
      @TheCodingTrain  5 років тому

      This would be a useful optimization for sure! I suppose by drawing all the particles all the time there is more opportunity for animation, etc.

    • @porigonopop
      @porigonopop 5 років тому

      It's depends on what the goal is, like if you only want to draw a snowflake, but for sure, it could be useful to keep it

    • @JaspreetSingh-fo2qe
      @JaspreetSingh-fo2qe 5 років тому

      @@katherinegaymes There's a way around this. If we display the particle only after it reaches its end position then this issue won't occur.

    • @katherinegaymes
      @katherinegaymes 5 років тому

      @@JaspreetSingh-fo2qe yes, but then it loses the animation aspect

  • @chocolateimage
    @chocolateimage 5 років тому +1

    hello

  • @c.janssen4390
    @c.janssen4390 5 років тому +1

    Could you try to program this simple game from scratch?
    www.humanbenchmark.com/tests/memory
    It is about testing your visual memory.

    • @TheCodingTrain
      @TheCodingTrain  5 років тому

      Please suggest here! github.com/CodingTrain/Rainbow-Topics/issues

  • @RahulKumar-pt2su
    @RahulKumar-pt2su 5 років тому

    God will punish you,,, for making me mad about coding....
    🙏🙏🙏🙏🙏🙏🙏