Coding Challenge #17: Fractal Trees - Space Colonization

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 พ.ย. 2024

ความคิดเห็น • 119

  • @willjones655
    @willjones655 7 ปีที่แล้ว +2

    Hells bells your videos are amazing. You work so quickly that it can be hard to keep up but your diagrams really help.
    Thank you for your incredibly hard work and I will defo be donating.
    Keep up the hard work.

  • @quillaja
    @quillaja 6 ปีที่แล้ว +11

    Actually, this is really cool. I bet you could combine this with terrain generation to simulate the way erosion creates streams, thereby making the generated terrain more realistic looking.

  • @setupdraw7642
    @setupdraw7642 8 ปีที่แล้ว +49

    This was very interesting but also very difficult (at least for my poor programming skills). What about introducing a labeling system for coding challenges? Something like green for easy, yellow for intermediate, red for hard? This could maybe be useful for less expert programmers.

  • @disko.kommando
    @disko.kommando 8 ปีที่แล้ว +2

    You did an amazing job! It was a pleasure to watch your thought process grow just like the fractal tree pattern :)

  • @UltraLightSP
    @UltraLightSP ปีที่แล้ว +5

    "It does not have to do with colonizing space, it's really about colonizing a two-dimensional space"

  • @ThatGuyNamedBender
    @ThatGuyNamedBender 3 ปีที่แล้ว +1

    I enjoy following his JS tutorials in processing, good challenge there

  • @DaleBasye
    @DaleBasye 8 ปีที่แล้ว +9

    thanks again learning so much after my stroke 10 years ago and learning Processing and Arduino and now p5 !!!

  • @gloubiboulgazeblob
    @gloubiboulgazeblob 5 ปีที่แล้ว +1

    Cool ! I would be pleased to see the same algorithm with a light positionned somewhere in the canvas to tell the tree where to go (direction), and why not, moving, to see how it goes...
    Anyway, always a pleasure to watch your videos, thanks !

  • @BrandNewByxor
    @BrandNewByxor 8 ปีที่แล้ว +55

    Does p5.js come with a function that lets me draw myself a beard like yours?

    • @Dadaskis
      @Dadaskis 6 ปีที่แล้ว +1

      BrandNewByxor nope, but u can make this function easily.

  • @vincentcleaver1925
    @vincentcleaver1925 3 ปีที่แล้ว

    You can use this with multiple trunks to make a forest (looking down into it; the branches connect to one or another of the trunks, we get terminal leaves, etc.

  • @prototy
    @prototy 2 ปีที่แล้ว +1

    Love your videos! would love to see a redo of this video though with the knowledge you have now :)

  • @isadorateles1823
    @isadorateles1823 8 ปีที่แล้ว +1

    Thank you so much for this video ! I'm heaving a lot of trouble translating the algorithm to openframeworks though

  • @twistedsim
    @twistedsim 8 ปีที่แล้ว +2

    Nice video ! I like the "live" part of your video.

  • @LordGrrr
    @LordGrrr 5 ปีที่แล้ว +7

    Building a tree by the leaves 🤯

  • @veronicacasco1958
    @veronicacasco1958 3 ปีที่แล้ว

    great exposition -- Is it possible to model an agave plant using fractal geometry? the agave plant is a fractal?

  • @Piflik
    @Piflik 7 ปีที่แล้ว +2

    Just a small comment: adding x unit-vectors does *not* result in a vector of length x, unless all of them are the same vector, so actually normalizing would be 'more correct' than dividing by number of vectors.

    • @maverickstclare3756
      @maverickstclare3756 6 ปีที่แล้ว

      While you are stating a fact, the algorithm in the paper uses the average :
      "The node v' is positioned at a distance D from v, in the direction defined as the average of the normalized vectors toward all the sources s ∈ S(v)."

  • @cpdorli
    @cpdorli 8 ปีที่แล้ว +2

    I post this as a possible optimization: When you definen a function for an object, you usually do it like this, = function... This is not very effective as each object you make needs to define this function separately. You should use prototypes and define functions like .prototype. = function... This may sound like a micro-optimization (and it is) but it can make a big difference if you have hundreds or thousands of objects.

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว +2

      Yes, this is a really good point. I have been avoiding "prototype" because of the confusion it often causes with students. I would like to do a video about "prototype" soon.

  • @sitongzhao4982
    @sitongzhao4982 7 ปีที่แล้ว +3

    what happen about the line 21 in tree.js?There is something lost at 16:53. I cannot see which part you change.

    • @dead_engineer
      @dead_engineer 3 ปีที่แล้ว

      Same

    • @dead_engineer
      @dead_engineer 3 ปีที่แล้ว

      i found the issue that i had (java not p5js)
      in the constructor of the branch there were new vars created instead of assigning the values to the ones of the branch
      Derp:
      Branch(Branch par,PVector pos,PVector dir){
      PVector position=pos;
      Branch parent=par;
      this.dir=dir;
      }
      Correct:
      Branch(Branch par,PVector pos,PVector dir){
      this.position=pos;
      this.parent=par;
      this.dir=dir;
      }

  • @anokheejandhyala1074
    @anokheejandhyala1074 4 ปีที่แล้ว +1

    Watching you explain this at 1/2 speed put me in a trancelike state. I'm texting from mars right now lol

  • @elviraelvira5736
    @elviraelvira5736 2 ปีที่แล้ว

    Did it!!! Happy dance 😃

  • @xnick_uy
    @xnick_uy 8 ปีที่แล้ว +24

    I've been looking at the previous challenges, and this time the video failed to deliver. The final product looks kind of decent, but the road to get here was all messed up.
    For this kind of "lengthy" object oriented implementations, you should start by writing down in the whiteboard or somewhere else the classes you want to use, their main properties and methods you want for them. After you have your initial design, then you go coding and maybe later you can add more properties and methods in the written version first, then to the code. This would actually shorten the duration of the video and make the logic behind everything more clear.
    Also, adding some comments to the code is always welcomed.

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว +11

      Thanks for this feedback, it's very helpful.

    • @xnick_uy
      @xnick_uy 8 ปีที่แล้ว +4

      Daniel Shiffman I'm really enjoying the channel :-)

    • @grauntgront3478
      @grauntgront3478 7 ปีที่แล้ว +2

      Yes! This was frustrating for me too. (at 16:50 or so)

  • @Jimanator
    @Jimanator 8 ปีที่แล้ว +14

    if you add another function for things to be avoided, then you will essential have made computer slime mold.

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว +5

      +James Butler (Jim) heh, thanks for the tip!

  • @prabhjot1984
    @prabhjot1984 5 ปีที่แล้ว

    quite interesting, but can use a very simple software called IFStile to create same fractals , but with not requirement for learning java

  • @kennyPAGC
    @kennyPAGC 8 ปีที่แล้ว

    what I don't understand is why we break the branches look in the grow function if we find a branch that is closer to the minimum distance. Ok, we ignore that branch because it's too close to the current leaf, same as we do when it's too far away, but why break the loop? Why don't we look for other branches and see if they're at an acceptable distance from the leaf?

  • @subarukun8001
    @subarukun8001 4 ปีที่แล้ว

    You are crazy bro

  • @soundcore183
    @soundcore183 7 ปีที่แล้ว

    You could implement a class for dots, so they are object oriented. After the lines have been drawn point objects could be deleted.

  • @kevnar
    @kevnar 4 ปีที่แล้ว

    I once made a solitaire simulator. It would shuffle the cards, deal a layout, and then play an optimal strategy for winning. The goal was to compute by brute force what the odds of winning. Wikipedia said the odds of winning were like 1 in 13. But I was running through literally five billion games and not winning once. Something was wrong.
    After stepping through my code for like two hours, checking the algorithm for all the move AI 200 times, I realized that I was not reshuffling the cards after every game. So if the computer lost the first deal, it would lose every deal. D'uh!
    It was such a stupid bug, I laughed for ten minutes, picturing the AI playing 5 billion games of solitaire against itself with the exact same deal and wondering why it wasn't winning.

  • @aleph618
    @aleph618 2 ปีที่แล้ว

    Is there any way of seeing the Processing version of this?

  • @diegoruiz553
    @diegoruiz553 3 ปีที่แล้ว

    ¿How I can scan a fractal in the nature, like the veins in the leaves?

  • @ElPanetone
    @ElPanetone 5 ปีที่แล้ว +8

    Why don't you use some of the js Array functions like forEach, map, reduce, filter, etc. There are very useful and make the code so much readable. Nice vid btw.

    • @bopbipp9896
      @bopbipp9896 4 ปีที่แล้ว

      Those are ES6 concepts, the way he did it was better because it's more common (ES5)

  • @ZoaMaj
    @ZoaMaj 7 ปีที่แล้ว

    Hey Daniel! Great series.
    I was wondering how do I export a DXF or a PDF of the final result of a tree?

  • @trixyztech6158
    @trixyztech6158 8 ปีที่แล้ว

    Hi Daniel, thank you for these amazing tutorials.. please keep making them!
    I was wondering, how can we recognize the main set of lines and make the next gen of lines a child of the first ones? The parent allways points to the previous point in the line, but I can't find a way to make groups out of them... I would like to connect the open "dots" between them so first I need to recognize the second or third gen branches.. Thank you for your time!

  • @ttk519
    @ttk519 4 ปีที่แล้ว

    wich programs this dude using?

  • @glhf8756
    @glhf8756 8 ปีที่แล้ว +3

    that's crazy, I'm not even subbed, it's on my recommended.

  • @VLAHECO
    @VLAHECO 8 ปีที่แล้ว

    🤓🤓Watching Daniel's videos I do not need to go to school 😎... so smarth guy

  • @DashieDasher
    @DashieDasher 7 ปีที่แล้ว

    How do the branches split? It looked like you only ever added one branch to the end of every other branch.

  • @AlejoEremita
    @AlejoEremita 7 ปีที่แล้ว

    this was awesome and very enjoyable!

  • @ibzyronx7093
    @ibzyronx7093 8 ปีที่แล้ว +1

    Could you code a pendulum simulation (so it exhibits isochronism)?

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว

      Take a look: th-cam.com/video/9iaEqGOh5WM/w-d-xo.html

    • @ibzyronx7093
      @ibzyronx7093 8 ปีที่แล้ว

      I thought you had done something on this topic, but couldn't find it.

  • @Gabriel-cs8wo
    @Gabriel-cs8wo 8 ปีที่แล้ว

    Awesome!

  • @IoriTatsuguchi
    @IoriTatsuguchi 6 ปีที่แล้ว

    23:01 if {...} elsie {...} lol
    love how it sounds so fuzzy.

  • @jamesvic1000
    @jamesvic1000 6 ปีที่แล้ว

    Hello! Question: How can one update the branches array to reflect each direction away from the main trunk/stem?? In other words, if the leaves fall from one particular branch, could we organize the same array to remove all of the points and parents associated with that long branch?

    • @jamesvic1000
      @jamesvic1000 6 ปีที่แล้ว

      Under the if(leaves.get(j).reached) section you can find the last addition to the branch array index. That is the index of the last point on that branch that reached the leaf. With that, you can find its parent and then use a while loop to find each parent after that until you reach the root. Got to love "indexOf()" !!!

  • @tastyl2356
    @tastyl2356 4 ปีที่แล้ว

    how was this to do with team trees when it was uploaded in 2016

  • @ThePhantum
    @ThePhantum 8 ปีที่แล้ว

    hey I'm new to your channel I came here because I'm a highschool sophomore and next year I'm going to a community college for running start and I'm going to take a C's 101 class and I'm just getting into coding and although I just started watching your vids today I would appreciate it if u could post more things about understanding code and beginners stuff like the programs u use and how to pick a language and stuff, I plan on getting more into programming for fun too ik this is long and if you've read it so far it will mean just that much more to me but thank you I love the several vids of yours I've seen so far, I've subbed and I'm gonna keep watching them because it's informational for the parts I understand and entertaining but keep up the good work

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว +1

      sure thing! i recommend taking a look at my intro to Processing and p5.js videos where i discuss different languages. This playlist: th-cam.com/play/PLRqwX-V7Uu6ZYJC7L-r6rX6utt6wwJCyi.html and also: th-cam.com/video/8j0UDiN7my4/w-d-xo.html

  • @rysea9855
    @rysea9855 4 ปีที่แล้ว

    The dislike count is so low on this video! I mean, it DOES make sense because it's an amazing video

  • @aidanbenbow6682
    @aidanbenbow6682 ปีที่แล้ว

    Wouldn't it better to name root, trunk?

  • @knezivan1
    @knezivan1 6 ปีที่แล้ว

    he made it soo much more complicated than it had to be,

  • @Ozterkvlt
    @Ozterkvlt 7 ปีที่แล้ว

    it would be interesting if you had movable leaves and also movable leaves the branches avoid, then you could make a game of guiding the branches into some area in real time, or something (im sure thats been done by someone)

  • @sigmareaver680
    @sigmareaver680 6 ปีที่แล้ว

    How come you don't use the "continue" keyword in your loops? Or does JS not have that?

    • @krishanumallikthakur1311
      @krishanumallikthakur1311 6 ปีที่แล้ว

      Sigma Reaver Thing is that most people avoid using continue. But yes it can be useful sometimes!!

  • @timolenton1904
    @timolenton1904 4 ปีที่แล้ว +1

    eek.
    I really struggled to follow along this time while trying to recreate the code in Processing.

  • @joesouch6994
    @joesouch6994 8 ปีที่แล้ว

    Loving the videos Dan. Was wondering if you have a codepen account i could follow?

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว

      not yet, but maybe i should make one!

  • @dapxful
    @dapxful 8 ปีที่แล้ว

    this is great! thanks

  • @ericrovell1970
    @ericrovell1970 6 ปีที่แล้ว

    How is this working without 'this' in:
    if (parent != null)
    ?
    I have an error...

  • @IbakonFerba
    @IbakonFerba 7 ปีที่แล้ว

    How does the tree split? You let every branch just create one children, don't you? or does it happen when more than one leave pulls on the branch?

    • @IbakonFerba
      @IbakonFerba 7 ปีที่แล้ว

      ***** I think it's what I last said, but I'm not sure

    • @midnightcarsintokyo
      @midnightcarsintokyo 7 ปีที่แล้ว

      The branches are added until the 'root' reaches the leaves. The leaves in the range of the branch decide which branch is closest, and link to that branch, so more than one leaf can connect to one branch, which is how it splits. Every branch only has one parent, but that means that a parent can have multiple children, it's just that the parent doesn't know about the children, only the children know about the parent (but not each other)

    • @maverickstclare3756
      @maverickstclare3756 6 ปีที่แล้ว

      reading the paper explains better than the video: algorithmicbotany.org/papers/colonization.egwnp2007.large.pdf

  • @5daydreams
    @5daydreams 3 ปีที่แล้ว

    It's REALLY hard to follow this with the amount of zooming...
    I have to pause and go frame-by-frame in order to check how your code is written to check mine for bugs : /

  • @vincentcleaver1925
    @vincentcleaver1925 5 ปีที่แล้ว +1

    It's not a root, it's a trunk! 8-P

  • @Dong_Harvey
    @Dong_Harvey 8 ปีที่แล้ว

    newer versions of the p5.js beta-editor seem to not recognize the copy() function..
    unless i'm the one missing something..
    edit: nvm, missing dir parameter in tree.js causes bug in branch.js

  • @CodingWithUnity
    @CodingWithUnity 5 ปีที่แล้ว

    Add quad trees and make the biggest fractal tree ever

  • @toastyPredicament
    @toastyPredicament 2 ปีที่แล้ว

    Dude I'm watching these for gsmedev

  • @philippkarlkorn9504
    @philippkarlkorn9504 6 ปีที่แล้ว

    Can someone help? I'm always getting the error message that Tree is not definded... what do i have to do?

    • @philippkarlkorn9504
      @philippkarlkorn9504 6 ปีที่แล้ว

      already figured out, I had to add it as source in the html file. Did not know that haha

  • @xLoxLoLex
    @xLoxLoLex 6 ปีที่แล้ว

    dad? is this you? where have you been all this time?
    you told me you were going for a couple cigars...

  • @glhf8756
    @glhf8756 8 ปีที่แล้ว

    wow, fourth!

  • @tigarasab784512
    @tigarasab784512 7 ปีที่แล้ว

    you're fucking awesome :D

  • @aonodensetsu
    @aonodensetsu 8 ปีที่แล้ว

    Daniel, could you please make (or point me to) a video explaining how to set up the javascript programming? (I mean what's in the libraries folder, .DS_Store and index.html

    • @danjwheatley
      @danjwheatley 7 ปีที่แล้ว

      github.com/CodingTrain/Rainbow-Code/tree/master/CodingChallenges/CC_17_SpaceColonizer_p5

  • @toastyPredicament
    @toastyPredicament 2 ปีที่แล้ว

    I'm watching this for gamedev

  • @FredoCorleone
    @FredoCorleone 6 ปีที่แล้ว +1

    I've not well understood how branching in this algorithm works... I would aspect just one branch to move following the avarage distance of leaves. But that's just at first sight. You should remake the video and make clear all the points in order. This is the most confusing video of yours so far.

  • @Xnoob545
    @Xnoob545 5 ปีที่แล้ว

    21:56 brb

  • @Akbalaak
    @Akbalaak 8 ปีที่แล้ว +2

    what programs you use ? or should i say :
    this.question = what () {
    w̶h̶a̶t̶ ̶(̶x̶)̶;̶
    programs();
    you(use.?)

    • @RitobanRoyChowdhury
      @RitobanRoyChowdhury 7 ปีที่แล้ว

      p5.js, Processing (frameworks)
      sublime text, atom, and codepen (ide)
      chrome web browser

    • @zahidahmed586
      @zahidahmed586 6 ปีที่แล้ว

      Ritoban Roy Chowdhury
      Dafaq

  • @0623kaboom
    @0623kaboom 4 ปีที่แล้ว

    you would have less problems if you started your parent off as a seed ... then everything from that point onwards has a proper reference and you dont have to bodge the algorithm to make up for the fact that you start with a branch instead of the a seed ... Like a tree in Nature ... it doest start from a branch it starts from a seed ... the seed is then the parent of the complete tree ... and the seed is the child of the tree before it ... it's parent ...
    .
    you are starting past the start and making a bad assumption ... which will have a major faults further down because of the bodge job to fix the lack of a seed to start
    .
    (bodge job) making something that works with parts that dont actually go together well ...

    • @0623kaboom
      @0623kaboom 4 ปีที่แล้ว

      24m mark the logic fault ... your min max check should be anded at the start ... if not between min max ... do the nested if's for placing branches and leaves ... and break out if false ... you are checking boundaries then rejecting those boundaries to create new ones with a record and failing every time because your record doesnt fall within the min max boundry ... so it spends its time checking there and not actually progressing

    • @0623kaboom
      @0623kaboom 4 ปีที่แล้ว

      further logic fault leaves dont actually pull to themselves they push for maximum surface area of the volume ... so branches actually grow to fill in empty space with leaves .. with minimal overlap at each level of growth ... and it does this on a prime number ratio for each direction ... with one direction being one step higher than the other direction ... what you are trying to do is force chaotic behaviour into a prime sequence by factoring it down to primes essentially ... faster and less confusing to grow with primes for each layer and progress outwards then your max distance will change with the area needed to be covered and your min distance is always your lowest record and equal to the starting prime in its direction ... then scaling is always the same and growth is always random BUT following a pattern to provide maximum leaf coverage of the current volume of growth including all previous layers of growth added in ... this provides the larger trunks and branches ... to support the tree and makes for an organic growth and more natural model of a natural system ... also takes less cpu power and about 2/3rd's of the code you are currently using ... lowering overhead

  • @isalomita
    @isalomita 3 ปีที่แล้ว

    I love you but I don't understand anything.... My tree exploited :(

  • @toastyPredicament
    @toastyPredicament 2 ปีที่แล้ว

    Please help

  • @evelynwalker3754
    @evelynwalker3754 2 ปีที่แล้ว

    sry idk why i got mad if im...

  • @toastyPredicament
    @toastyPredicament 2 ปีที่แล้ว

    Huh

  • @andrewlozano88
    @andrewlozano88 8 ปีที่แล้ว

    Second()!

  • @supernaturalswampaids8083
    @supernaturalswampaids8083 8 ปีที่แล้ว

    First!😂

  • @nerdiconium1365
    @nerdiconium1365 6 ปีที่แล้ว +1

    "And in that tree..." Ohh god flashbacks...
    Reply if you know what I'm talking about.

  • @paulkerrigan9857
    @paulkerrigan9857 6 ปีที่แล้ว

    "I can also just be safe about this and set closestBranch to null", he says as he types "closestBranch = true;" into the text-editor.
    This is the first of your videos that annoyed me with its glaring mistakes. :C