"If you've watched one of my previous videos" - well, I may or may have not binge watched all first 16 challenges after stumbling on the Snake challenge, so all of those are now a blur of Bob Ross-esque coding awesomeness which I probably gonna have to watch again to properly parse.
@TheCodingTrain8 жыл бұрын
+Wojciech Morawiec haha I love this comment!
@finnaginfrost62978 жыл бұрын
Exactly the same here
@Mattify07778 жыл бұрын
Highfive mate
@abinadiswapp76378 жыл бұрын
haha yeah that's me too!!
@ryanmatthews57717 жыл бұрын
Couldn't have said it better myself. You really are the Bob Ross of coding.
@camelcase92258 жыл бұрын
That's the most incredible thing I've ever seen. I'm learning so many different things from your channel! Never heard of the L System before.
@tanmayagarwal85134 жыл бұрын
I am still learning tree data structure and this guy made the real tree look like structure. OMG!!!!! That's pretty amazing!!! U r great man!!
@amber18626 жыл бұрын
This kind of stuff tickles my brain's g-spot. It's so incredibly satisfying.
@AryehAmitz8 жыл бұрын
One thing that has helped me with learning is to download the source code for these and add comments explaining how each part works. It helps me analyze the logic, and also helps me see any holes in my understanding. Commenting the example codes helps a lot too! Thought i would share.
@TheCodingTrain8 жыл бұрын
+Leam J indeed great tip! I always intend to add comments before I publish but pretty much never get around to it! I welcome pull requests with comments on GitHub!
@grumpyparsnip Жыл бұрын
I can't believe how simple but powerful this technique is.
@sofialpaca25634 жыл бұрын
After attending a class on formal languages, I stumbled upon a paper on computally generated botanicals and wanted to try to cook up something for the fun, and I thought of you... You never disappoint! I'm going to give this a try tomorrow!
@smonman28737 жыл бұрын
F -> F+[F-F]-F[+F] This combination looks beautiful! It creates real leafs!
@Megasterik6 жыл бұрын
What's the axiom and angle? I used 'F' and 45 degrees and it creates a plant/weed but not real leafs.
@rukna37753 жыл бұрын
@@Megasterik is it creating marijuana?
@pelayne797 жыл бұрын
WOW! I can't believe you implemented LOGO! I used that language as a kid. Congratulations on finding a use for it along with javascript.
@BeatsByVossy8 жыл бұрын
So glad I found this channel. This is a nice break from my ReactJS adventures!
@CJThomps5 ай бұрын
3:50 simply amazing - and excellent presentation ❤
@eyewarsx8 жыл бұрын
This is like when you ask your perants for something. "Mom can I have this?" "Go ask dad" "Dad can I have this?" "Go ask mom"
@Zooey1055 жыл бұрын
DAN you are what got me into *really* coding, love your book too!!
@spongebobseyelashes85486 ай бұрын
I remember using grammars and lexers/parsers in Ocaml last year for college, was great to see it visualized like this!
@CristiNeagu7 жыл бұрын
Fun fact about Logo. Even though it was designed to teach kids how to program, it had some very advanced features. A very interesting one which you don't come across all that often is that it had the capability of executing the contents of variables. Like, you could define two variables x=5 and y="2*x+3" and you could interpret y and it would output 13. I used it to make a function plotter when i was a kid. You'd give it a function and it would plot it out for you.
@iamstickfigure7 жыл бұрын
That's so cool. I learned to code way back in middle school using LOGO. This is the first video where I've ever heard anyone mention it. I haven't met anyone else who's heard of it either.
@renatokuurstra59578 жыл бұрын
You channel is simply fantastic! Please continue to give us this wonderful material! ;)
@darthtorus93418 жыл бұрын
PI/6 = 30 degrees, so a 5-degree difference might not be noticeable
@TheCodingTrain8 жыл бұрын
indeed, good point.
@alvisez.64538 жыл бұрын
I'm learning so much thanks to you Daniel, thanks a lot! I'm so curious to play around with L-systems myself now :)
@lachlancatto97168 жыл бұрын
I love your coding videos, keep making them!
@matthewniles28177 жыл бұрын
I made something so stupid with this For every letter that is in the P, i transform it to its phonetic pronunciation Ex: "XD" becomes "ECKS DEE", which then becomes "EE SEE KAY ESS DEE EE EE" and so on (I'm sorry, planet)
@SpencerYonce6 жыл бұрын
this is wonderful
@baldebaldemord95884 жыл бұрын
You Could use this for cryptograpy if you reverse this example. PEE AY ESS ESS WEE OH AR DEE is Password (W is a bit wierd in english). If you do this like 3 to four times with random rules you have a great crypograthy.
@Ixion1254 жыл бұрын
Now, that's ABSOLUTELY GENIOUS
@t-h7877 жыл бұрын
I genuinely have no idea how i'd pass my uni course without your guidance!!
@michalbotor6 жыл бұрын
just a suggestion, but a code seems to become a lot more concise and clear (at least to my eyes) if one defines a function rule accepting a letter as an input with a switch statement inside to make it respond accordingly. no need for conditionals in the generate function then. anyways, i love the idea of l-systems, i find them to be genius and intriguing, and i'm grateful to you dan for introducing them to me in such a simple, clear and exciting way. i'm looking forward to creating lots and lots of interesting and somewhat unpredictable, surprising, unexpected artwork designs using this very idea.
@RainFlyAnimation3 жыл бұрын
Brilliant! So simple yet so beautiful
@Gridfen8 жыл бұрын
In js it's currently performance better to use array and then join it into string. Also for rules you could use object that describes what becomes what like { "A":"AB", "B":"A"}. That will be much easier to understand and operate.
@glenneric13 жыл бұрын
It's a little wordy if you don't use the map/dictionary to your advantage. Here it is in python. result = 'A' Lsystem = {'A':'AB','B':'A'} for loop in range(5): newresult = '' for char in result: newresult += Lsystem[char] print(newresult) result = newresult
@creeperave37688 жыл бұрын
This is actually one of my favorite time passers!! 1 11 21 1211 111221 312211 13112221 1113213211 31131211131221 13211311123113112211 Etc.... I had never found a name for it before!
@ajthemagi29138 жыл бұрын
CreepeRave those are Conway's look and say numbers. It's a cute little sequence.
@Texplanations8 жыл бұрын
121 1331
@matthewniles28177 жыл бұрын
I believe it's called the look-and-say sequence (or something like that) by some famous mathematician.
@evanparsons1234 жыл бұрын
I didnt know this was common knowledge (which is always a good feeling when you stumble upon something like this that you thought you invented and other people are into it)
@hairnetart7 жыл бұрын
oh my god, this is so beautiful
@xnick_uy8 жыл бұрын
I was trying yo figure out why this time the fractal tree turns out to be non symmetrical, as we see in the previous challenges. It turns out that the rule in this video is "skewed" instead of symmetric. That's because the first rotation, indicated by a +, appears before the first bracket [. We then find a - after the closing bracket ], but that - just returns the orientation to the one just before the +. For a symmetric rule, it should read as F goes into FF+[+F-F-F]--[-F+F+F]+ Note that there appear two consecutive - in the middle and a final + at the end, because just in case we want to end up with the orientation that we started with.
@markusnilssen52407 жыл бұрын
You're an amazing human being
@annmariebartholomew25912 жыл бұрын
Thank you, thank you, yes and thank you
@odddiabetic8 жыл бұрын
I got really excited at 21:00
@alejandraecheverrygiraldo92826 жыл бұрын
Excelente video. Claridad y calidad bastante alta.
@cwlindWX7 жыл бұрын
This is also how the X chromosome is passed down. If you invert your tree and look at it as ancestors instead of next generations, and swap X for A, and Y for B, you can see how the X chromosome is passed down. Females (X) get an X from her parents (X and Y [mother & father]). Father (Y) gets an X only from his mother (essentially, Y becomes X). etc etc.
@stefanvanderheijden44967 жыл бұрын
As said before, the Bob Ross of coding
@DodaGarcia2 жыл бұрын
Wow I hadn't seen LOGO in almost 30 years 🥲 This was remarkable
@dorpeled47687 жыл бұрын
Beautiful algorithm.
@beyondcatastrophe_7 жыл бұрын
13:12 The wordwrapping now works because '-' indicates a break, if there is none, css doesn't know where to break the word...
@isabelmorel22252 жыл бұрын
Wow!!!! This is soo cool!!!!!!!!! THANKS!!!!!!!!!!!!!!!!
@michaeldere28928 жыл бұрын
this is cool!!! I think I would've had more fun with my CSE courses if you were my instructor lol
@dimashishkov29098 жыл бұрын
Mindblowing!
@TheCodingTrain8 жыл бұрын
thanks for watching!
@1anya7d8 жыл бұрын
Beautiful video! I wonder if that popular game "no man's sky" used that thing to generate planets (or plants)
@iaincarson62934 жыл бұрын
It would be great if they did, but actually the plants themselves are fixed models and its only their placement which is basically random. The planets themselves appear to be generated using something more like Perlin noise mesh generation. Check out Sebastian Lague's channel on procedural planet and terrain generation!
@cheesiestmaster8792 жыл бұрын
I made a python version of the L-System using 2 lists to store an arbitrary number of rules. The code that builds the next generation is `future+=(rules2[rules1.index(i)])` where i is from a for loop of `for i in current:`
@kevnar2 жыл бұрын
I wonder what happens when you apply rules randomly from a pre-defined set, just so it's not so perfectly self-similar.
@sukhresswarun2 жыл бұрын
20:22 , on line 51 he missed semicolon .
@TheCodingTrain2 жыл бұрын
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
@lealemtaye6 жыл бұрын
i really really need your help... you just reawakened my curiosity
@carolinepace55115 жыл бұрын
FANTASTIC video ... can you please tell me how to apply such a concept to create a 3d plant based on the L system ?
@beaverjoe91716 жыл бұрын
How did you first time know the L-system can make the art tree like this. I mean how do you combine the math and coding with the final art. Thats perfect
@blasttrash5 жыл бұрын
exactly lol. first of all how did the scientist back in the day think about l-system and then how did people including dan think about using it to make fractal trees?
@DilanDeSilva8 жыл бұрын
great channel. keep it up!
@Holobrine6 жыл бұрын
You could have one rules object with each rule as an attribute, and use the indexer to replace each letter with its rule. That way you don’t have to iterate through the rules and the program is much quicker.
@TheCodingTrain6 жыл бұрын
Thanks for the tip!
@kamoroso948 жыл бұрын
The generate function kind of reminds me of a Turing Machine. It has an alphabet (Σ), a set of rules (δ), and an axiom (q₀).
@TheCodingTrain8 жыл бұрын
indeed!
@Dong_Harvey8 жыл бұрын
it reminded me of "Godel, Escher, Bach" by Douglas Hofstatdler. an amazing book for computer scientists..
@jdyerjdyer8 жыл бұрын
A nice tweak adding leaves: function turtle() { background(51); translate(width/2,height); stroke(255, 100); for (var i=0; i < sentence.length; i++) { var current = sentence.charAt(i); if (current == "F") { line(0, 0, 0, -len); translate(0, -len); } else if (current == "+") { rotate(angle); } else if (current == "-") { rotate(-angle); } else if (current == "[") { push(); } else if (current == "]") { createLeaf(); //Added This Line pop(); } } } //Added These two variables var leafW = len/10; var leafH = 2*len/10; //Added This Function function createLeaf() { fill(0,255,50); ellipse(0,0,leafW, leafH); noFill(); }
@robgrainger53142 жыл бұрын
Lindenmeyer used a letter ('L' by convention) to represent leaves, that way they could arise naturally within the L-System itself. Similarly for flowers. He also allowed using identifiers rather than letters, giving more readable strings.
@erdemozverenn7 жыл бұрын
Rendering letters as a tree, this is the "new kind of sexy"
@ajnovember5 жыл бұрын
did the video theorized in the outro about applying physics to sets of branch objects using L systems ever get made, by chance?
@ifinit54286 жыл бұрын
Omg this is very creative
@Armageddonas78 жыл бұрын
Awesome! How comes you didn t mess with the variables this time? It s always fun seeing different results
@mishikookropiridze8 жыл бұрын
Hey I'm coding in python turtle graphics . but I found push and pop functions questionable. like I searched and I know that push adds object to array while pop is removing object from array but how it really works in your code is bit frustrating for me to understand any help ?I created code and sucessfully draw sierpenski triangle using l-system that's because those l systems doesn't use [ ]
@gespinozpaerez6 жыл бұрын
that is awesome
@iOverThoughtThis8 жыл бұрын
Hey! love your videos. I just wanted to mention you could have clarified your rules from the beginning and avoided some complexity. Since you're rules match characters to strings you could just have the characters as keys in a dictionary and the strings as values. Then you can use .hasOwnProperty to check if a character matches a rule and don't need to use a loop to find the matching rule. e.g. ... var rules = { A: 'AB', B: 'A" }; ... var current = sentence.charAt(i); if (rules.hasOwnProperty(current)) { nextSentence += rules[current]; } else { nextSentence += current; } ... Thanks for the awesome videos!
@TheCodingTrain8 жыл бұрын
thanks for the suggestions!
@katiehannah14833 жыл бұрын
how would I hide the F system displayed underneath the generate button?
@majesteit27628 жыл бұрын
Hey, I think it wasn't wrapping because it sees a bunch of letters next to eachother as one word. Your other rule had special characters, which html doesn't define as a word. That what I think atleast.
@xnick_uy8 жыл бұрын
We're gonna be rich!
@majesteit27628 жыл бұрын
:D
@janknoblich41298 жыл бұрын
NiP Supermeat Thats what the card in Hearthstone which is Shown on his picture says when played
@mishikookropiridze8 жыл бұрын
p5
@RupertBruce3 жыл бұрын
@18:22 surely that 'translate' should be in the setup only...
@OOO-CM-Saiteja3 ай бұрын
how to use the rule where rule.a has more than one variable?
@blasttrash5 жыл бұрын
Is there a way to combine this with mandelbrot or julia sets? Are there any papers that combine this with mandelbrot or julia sets?
@FredoCorleone6 жыл бұрын
const ruleset = { "A": "AB", "B": "A" } function generate(sentence, ruleset) { let next = "" for (const char of sentence) { if (ruleset.hasOwnProperty(char)) { next += ruleset[char] } else { next += char } } return next }
@Tin98Tin7 жыл бұрын
PLEASE do the animated OOP tree with springs and stuff
@ryanadytia4987 жыл бұрын
can you make L-systems code using php language ? i really confused to change your code from javascript to php awesome video btw i loved the way you explain it, keep it up :) Thanks
@kim157426 жыл бұрын
You could make an object-oriented tree and make the leaves be an L-System
@keitaidrissa3127 жыл бұрын
good one
@rostislav_rus6 жыл бұрын
In C#(wpf) it will be something like this: class State { public double size; public double angle; public double x; public double y; public double dir; public State Clone() { return (State)this.MemberwiseClone(); } } struct Rules { static internal Char[] syms; static internal String[] to; public Rules(Char[] symbols, String[] rules) { to = new String[rules.Length]; for (int i = 0; i < rules.Length; i++) { syms[i] = symbols[i]; to[i] = rules[i]; } } } private StringBuilder Generate() { Rules.syms = new[] {'F'}; Rules.to = new[] {"FF+[+F-F-F]-[-F+F+F]"}; StringBuilder nextSentence = new StringBuilder(); for (int i = 0; i < sentence.Length; i++) { var current=sentence[i]; var found = false; for (int j = 0; j < Rules.to.Length; j++) { if (current== Rules.syms[j]) { found = true; nextSentence.Append(Rules.to[j]); break; } } if (!found) { nextSentence.Append(current); } } sentence = new StringBuilder(); sentence.Append(nextSentence); txtBlc.Text = sentence.ToString(); return sentence; } private void GenerateImage(StringBuilder s) { var state = new State() { x = 250, y = 500, dir = 270, angle = 15, size = 15 }; for (int i = 0; i < s.Length; i++) { var current = s[i]; if (current=='F') { double newX = state.x + state.size * Math.Cos(state.dir * Math.PI / 180); double newY = state.y + state.size * Math.Sin(state.dir * Math.PI / 180); Line l = new Line { Stroke = System.Windows.Media.Brushes.Black, X1 = state.x, Y1 = state.y, X2 = newX, Y2 = newY }; cnvs.Children.Add(l); state.x = newX; state.y = newY; } else if (current == '+') { state.dir += state.angle; } else if (current == '-') { state.dir -= state.angle; } else if (current == '[') { states.Push(state.Clone()); } else if (current == ']') { state=states.Pop(); } } }
@jesus.castaneda8 жыл бұрын
How can I add this kind of programs to another programs?
@florijanratz5208 жыл бұрын
Why did you use particular this rule to translate "F"? Is it the best Rule to design a tree or could i use any other rules as long as they contain [ ] + F ? How do I know which rules make sense?
@Gridfen8 жыл бұрын
Florijan RÄtz you either define rules and what to do with sentences created by that rules yourself or find ready rule sets and program them.
@danielhetrick6778 жыл бұрын
"ABAAB." Daniel Shiffman 2016
@Klarpimier5 жыл бұрын
You know you could've used a JavaScript object to hold the rules, right? They would make your code a lot easier
@hamids45507 жыл бұрын
Hello, i am using the p5.js 3.3.6 and it is not generating anything. it only open a blank page. What is causing this problem? i have no error given in the p5.js!
@ashishmaurya32464 жыл бұрын
How can i make bar code through python
@varunmalik71095 жыл бұрын
Why isn't the tree symmetric about the axiom , I coded it and as per the rule both branches are symmetric .
@The_Foreman5 жыл бұрын
PI/6 is sliiiiiightly wider than Radians(25)
@framegrace18 жыл бұрын
if (j==rules.length) will avoid the use of the "found" variable. (If you are past the lenght of the rule array, is that you didn't found any)
@TheCodingTrain8 жыл бұрын
thanks for this tip!
@xnick_uy8 жыл бұрын
Also since there's a (very ugly) break after the something has been found, the if statement is not even necessary. Just make sentence += current without any if and it should come only to that point if no break has occurred. But I should advice against this sloppy coding approach...
@Diego612010pd6 жыл бұрын
CHALLENGE/PROBLEM: I was programming on Khan Acadamy and I couldn't figure out how to shear an image just using javascript and no DOM elements, CSS, or HTML. How do you manage to do this efficiently and fast? Also, how can you warp an image so that it fits in a quadrilateral fast and efficiently? Please make a tutorial on how to do this. I would appreciate it a lot.
@qualle9871235 ай бұрын
Awesome and really helpful video once again, but I think, it would have been way more simple and quicker to have a single object containing all rules and then replace the key with the value. let sentence = "A"; let newSentence = ""; const rules = { A: "AB", B: "A" } for(let i = 0; i
@mango_water1695 жыл бұрын
This guy is bob ross of coding xD
@AryehAmitz8 жыл бұрын
thanks.
@sethbracken8 жыл бұрын
Check out @LSystemBot on Twitter for more sets of rules to play with.
@TheCodingTrain8 жыл бұрын
nice one!
@peterumdog3 жыл бұрын
LOL at reading it like poetry
@Das_Mojo3 жыл бұрын
i liked the A , AB Song
@Das_Mojo3 жыл бұрын
very talented
@Kapthos8 жыл бұрын
That L-System rule (A becomes AB and B becomes A), the growth is the golden number, isnt it? 1,2,3,5,8,13,21....
@ismaelcebrianmarco72887 жыл бұрын
Good catch! Actually the Fibonacci sequence appeared first in history as a maths problem enunciated with rabbits. The letters in the L-System behave exactly as the rabbits in the problem (In the problem, each pair of adult rabbits (A) have a pair of baby rabbits (B) every month (So A becomes AB) ; and baby rabbits become adults after one month (So B becomes A)
@MichaelDavydoff6 жыл бұрын
This is how trees on Half-Life 2, Crysis and Skyrim were created?
@CRBarchager8 жыл бұрын
How come this even worked since you're missing a simicolon at line 51 like the entire time, when current == "-"?
@TheCodingTrain8 жыл бұрын
JavaScript is quite flexible and often doesn't mind a missing semi-colon.
@CRBarchager8 жыл бұрын
+Daniel Shiffman okay. Thanks for clearing that up. They should implement that i c, c++ and c# 😁
@ngodingnyantai69307 жыл бұрын
genius..!
@molesox7 жыл бұрын
I don't really understand the push and pop function...
@TheCodingTrain7 жыл бұрын
Try this video! kzbin.info/www/bejne/pWrWmJ2rnZJ2eK8
@amitojsinghahuja43307 жыл бұрын
Any one know the channel which do these kind of things in c++ or python
@mtgmage9246 жыл бұрын
Missed a semicolon at line 52 :D
@meysam.mousavi8 жыл бұрын
Hey Daniel! Thank you so much for the great videos. Been a fan of your work for a long time now. By the way, seems I can't subscribe to your 'Live Stream Updates' with my new email address. I tried a few weeks back and again today with no luck. It says 'To complete the subscription process, please click the link in the email we just sent you.' but I get no confirmation email. And I just missed your last live stream.
@TheCodingTrain8 жыл бұрын
send me your e-mail shiffman.net/about/ and i'll add you
@meysam.mousavi8 жыл бұрын
Thanks. You're awesome!
@yesveryprofesionalnameyes60555 жыл бұрын
The smallest l-system? Axiom: t Rule 1: T = t *mindblown*
@deadroxis19078 жыл бұрын
What is the easiest language to learn?
@komolunanole86978 жыл бұрын
Esperanto...
@blacklistnr18 жыл бұрын
I assume that you're asking for the best language to start with(because objectively the easiest language would be something like hq9+): C# or Java(both are powerful object oriented languages). Short resume of other languages: C/C++ - I feel like I have to do everything myself, Javascript - lacks the structure you need when first learning a language with its "everything is an object" mindset, Python - heard a lot of nice things about it but never tried it. By the way once you learn an oop like C# and play with pointers in pure C, I believe that there's no practical language that you can't tackle.
@komolunanole86978 жыл бұрын
blacklistnr1 I'm sure everyone has his own ideas about the "easiest" language, but I agree with your last statement. Once you learn the basics of telling computers what you want to do, its not that hard to do that in another language.
@deadroxis19078 жыл бұрын
blacklistnr1 Thank you!
@TheCodingTrain8 жыл бұрын
i agree!
@theodorep.55018 жыл бұрын
wow!
@TheCodingTrain8 жыл бұрын
thanks for watching!
@sl4yd8 жыл бұрын
Charlie Day as a programmer
@xBDCFF7 жыл бұрын
that's a bit similar to the conway's game of life
@thisisloop5 жыл бұрын
damn if he will apply for a job someday he can just point to his channel as a portfolio and he will get the job immediately.