Placeholder Image

字幕列表 影片播放

  • Okay.

  • Okay, Okay.

  • Okay.

  • Okay.

  • Now you can hear me, right?

  • It's never a coding train without I know.

  • I just gotta wait till the chat.

  • I gotta wait till the chat catches up and realizes that I am talking about You can hear me now.

  • Ah, Still talking to himself.

  • No joke.

  • Okay.

  • Oh, I just gotta wait for this.

  • All right.

  • Um all right, let's Let's let's let's begin again.

  • Hello.

  • Good morning.

  • Welcome.

  • My name is Dan, and this is the coding train.

  • Oh, I said so many interesting and important and funny and loose, illuminating and exciting and magnificent things that cannot possibly remember.

  • It's not a coating train.

  • If I don't start with my Mike muted by accident every once in a while anyway.

  • So why am I here?

  • What's going on?

  • It's Monday.

  • I'm wearing a T shirt.

  • This couldn't possibly be the coding train.

  • It's like cold outside.

  • And what?

  • The T shirt.

  • I had a whole thing.

  • Good morning.

  • And welcome to a very special edition of the coating train on a Monday.

  • So it's been a while since I've been here.

  • I haven't done a live stream for several weeks now.

  • I was at this wonderful event that was really fun.

  • Exciting, called thinker con.

  • I'm wearing the thinker con T shirt.

  • And so I was not able to live stream on that Friday and then this past Friday, it was a holiday here in the United States, otherwise known as a Thanksgiving.

  • So I was not able Thio Lifestream on Friday, and I just can't stay away.

  • I have to come back to you.

  • I just I felt the the sort of need to put some ideas to typing onto screen to Internet.

  • So welcome.

  • So I'm here.

  • Uh, this, by the way, is actually life.

  • I noticed there was some confusion at the beginning of the check.

  • We're asking, Is this the premier or is this life what the world we live in?

  • It's okay for us egg.

  • You can have something recorded that is premiered live that you can chat with, or you could actually be live or I could be live.

  • But I'm actually 30 seconds in the past by the time you see it and then you could be watching this.

  • It's a point in the future recorded.

  • There's so many possibility that so confusing, but right now, at this very moment, I am live here on.

  • I am going to program some stuff.

  • Um, so, uh, I'm checking out the chat, eh?

  • So I'm not gonna be here for a super long.

  • I will go back to my usual Friday schedule.

  • Um, I do.

  • I am here, though, to talk about a few things for least an hour.

  • Let me open up a web browser.

  • And, um, let me first go to something which I'm very excited about.

  • So you might have recently remember that I did a challenge.

  • A coding challenge where I attempted to create a logo interpreter logo being the programming language invented in 1967 where you can control this little turtle that moves around the screen and make graphics.

  • And I did my cruddy little version of it.

  • I put with my best attempt on my channel.

  • And then you the people created something.

  • Unbelievable.

  • So I'm gonna go to get hub dot com slash coating train slash, uh, logo.

  • So this is the, uh no, I'm not signed in, but that's fine.

  • This is the community version.

  • I'm gonna go here to contributors.

  • All of these people have contributed code to this version of the logo project.

  • And if I go here and click on, uh, this live Web demo link, I will be here and you'll see.

  • Look at this.

  • This is unbelievable.

  • There's like a design.

  • There's looking the actual syntax, highlighting.

  • There's a little menu here where I can like pick.

  • Look at it supports color it, Hexi decimal with repeat and syntax highlighting.

  • And I could look at these different.

  • And I could look at these different things that are here, and I could take my own Look at this.

  • The coating trade logo is here.

  • This is unbelievable.

  • I don't know what this is, but it's re center.

  • Oh, that's crazy.

  • I can like moving around.

  • Uh, this is just unbelievable.

  • Look at that.

  • That was like an animation.

  • How do people know how to do all that stuff?

  • It's unbelievable to me.

  • So thank you, everyone and really excited about the future possibilities of what we could do in this channel.

  • I'm using it.

  • So So I will try to do this periodically, where a particular coding challenge is put into a separate depository that people could contribute.

  • Thio, I do have difficulty managing all of this stuff on.

  • I'm figuring out new and interesting ways of doing that, for example, and sometimes someone just emerges The tasteful, toasty on get hub is now the has permissions to this repositories to review and merge poor requests.

  • So that's what exciting.

  • I do also want to mention then, though, that if you go to the coding train dot com on dhe, these are the two.

  • These are the two part coding challenges that for any of these challenges, you can also submit.

  • You can also So, in addition to contributing to maybe a community version, if you've made your own version that's hosted somewhere on your own, you can submit that as well.

  • So I don't know.

  • Yeah, you can see.

  • Look at this here.

  • I think I showed these already, but there is a three D logo experiment that was submitted here, which, actually look at this.

  • This is amazing.

  • That submitted by Dave be soft dot com, which implements a version of logo where you can run it, run it with a three D render.

  • Oh, my goodness.

  • So, so much amazing stuff.

  • Okay.

  • Um, so I wanted to mention that um what else is coming?

  • Coming.

  • So I am going to It is almost December, and I am planning to do a holiday extravaganza, but planning me and I have no plan yet on that will be a fundraiser for the prostate foundation.

  • So I just want to mention that you don't need to wait for the fundraiser.

  • Crossing Foundation is a, um none for profit foundation in the United States That supports a variety of initiatives.

  • You can see all the information here on the website on.

  • If you go here to support, you can find a way to sport.

  • So I will do a fundraiser at some point for processing.

  • I think tomorrow is giving Tuesday.

  • So pre giving Tuesday announcement.

  • There you go.

  • Okay.

  • So the next thing that I'm going to do is the chaos game.

  • Okay, let's do this.

  • So many possibilities here.

  • Who?

  • I like this.

  • We can make this one.

  • Look at this boy.

  • Boy, boy.

  • So many.

  • Oh, so excited.

  • Okay, So the reason why I'm doing this is at the finger cut.

  • Let me let me thank a few people We open up a thinker con here.

  • Um, so I want to thank in particular, the organizer's a thinker con smarter, everyday destine.

  • If you're not familiar with the smarter everyday channel, you probably would enjoy it.

  • Sabrina, Emily and Ah, Henry from minute physics.

  • I don't know why I don't see Henry here.

  • And Robert Cole, Rich from radio Lab, where the organizers of this conference was really fun.

  • I got to see the festival to spoken nerd, which was mind blowing the awesome.

  • I have the target audience for that job.

  • It was really fun.

  • And I was lucky enough to get to do a short 10 minute demo.

  • I did this demo with, um James Schloss.

  • Let's see.

  • Author of the I think it's the algorithm archive.

  • I think that's the name of his project.

  • Um, I'm pretty sure I'm pretty sure this is a project.

  • Uh, has a project like this.

  • It's got to be the algorithm work, right?

  • Okay.

  • Okay.

  • On his YouTube channel is Li IOS.

  • So s and I've mentioned I mentioned his channel before because I used his video on the hyper Cube to create my hyper cube challenge.

  • He also has a twitch channel where he does a lot of live streaming So, um so I'm gonna mention these things.

  • Um ah, over the archive, thinker con.

  • So we did a kind of coding competition.

  • We had 15 minutes and each program the chaos game next to each other.

  • He was using, like, Julia.

  • Some kind of crazy v I or something with text editor.

  • And I was just using my usual people, huh?

  • Js Web editor, which I'm also going to use right now.

  • Um, no, don't just do this.

  • Um, okay.

  • And don't call this chaos game Chaos Game number file.

  • There is also a a number file, video video, which I will reference.

  • Okay.

  • All right.

  • So this is what I'm going to do today.

  • So Johnny Joe stahr asks, um, is this not supposed to go on twitch to know?

  • So I do not live stream to twitch.

  • At one point, I was live streaming t multiple platforms.

  • And for better or worse, I have sort of landed on YouTube as my primary platform for both live streaming and shorter edited versions of things that happen in the life street.

  • So let's just get started here, playing the chaos game.

  • Oh, before I forget, How do I find this.

  • Okay, A doctor circuit.

  • I think twitter dot com Doctor Circuit.

  • Dr.

  • Circuit s B s been Sunday.

  • Larson is a coding trained viewer musician programmer from Norway Has his own YouTube channel that you could find created for me the most amazing piece of music ever.

  • That I will premiere at this moment.

  • I will later.

  • No.

  • Okay.

  • Thank you.

  • Um, s bend for this.

  • Amazing to know how quite that was loud, super loud or super quiet.

  • But I definitely plan on using that off.

  • Okay.

  • Uh, all right, let's cast game coding challenge.

  • This is, I think gonna be Finally I'm gonna do this in two parts because I'm gonna do a really simple version with just a triangle first, and then I'm gonna do another version with, um, uh, more of a variety.

  • Okay.

  • I'm looking for my train whistle.

  • Here.

  • This All right, let me reset.

  • Almost wanna have a timer here, but nothing ever.

  • Nothing good ever comes from the timer.

  • Okay.

  • The volume was pretty good.

  • I wouldn't change it.

  • Okay.

  • All right.

  • Hello.

  • Welcome to a coat.

  • That's OK.

  • That's OK.

  • That's good.

  • Well, uh cool.

  • Okay.

  • Me, me, me, me me, me, me, me By All right.

  • Hello.

  • Welcome to a coating coding challenge.

  • Last last dry last year, everybody Hello and welcome to a coding challenge.

  • The Chaos Game doll.

  • All right, so why am I doing this coding challenge?

  • I recently was lucky enough to attend this amazing event.

  • Thinker con in Huntsville, Alabama.

  • Thank you to Smarter every day.

  • And the other organizers of thinker con.

  • This was mind blowing event.

  • And at this event, I was I had the chance to do a live demo of some coding in front of people underneath a rock.

  • It was that was Saturday.

  • Rocket.

  • Look, kind of like this on Guy did this with James Schloss, who is the author of the algorithm archive.

  • Has a YouTube channel is.

  • Well, you might remember references to his YouTube channel in the I should have his YouTube channel up.

  • Leo S O s.

  • No.

  • What is Ah, hyper cube.

  • Come on.

  • Seriously.

  • Seriously.

  • What happened to you?

  • It was always the 1st 1 Look, here's mine.

  • How come I don't have my view to premium on any to sign in?

  • I think this is Oh, boy, Oh boy.

  • If you race don't you to Premium.

  • Uh, okay.

  • Ah, everybody just take a moment.

  • Here we go.

  • Uh, here we go.

  • There you go.

  • Learning is something I've always enjoyed.

  • Okay.

  • Oh, yeah.

  • Hold on a sec.

  • I want to thank the right people here.

  • Don't worry.

  • This is this is all gonna happen in a moment.

  • Um, but if I have a little Okay, so, Dustin, uh, assistants murder every day.

  • Sandlin Distance and Lynn Henry Henry.

  • Minute physics.

  • I got to get everybody's name that I want to thank Henry Reich.

  • Uh, Emily Grassley Family.

  • Grassley, Sabrina Cruise.

  • Robert Crow.

  • Which, Okay, yes, I'm using an invisible computers.

  • That amazing this'll is my my script Over here.

  • Have a script.

  • Okay.

  • How can I hold on?

  • I just gonna add Let me let me do this.

  • You've got to realize that half the time on the coding train live is just me taking care of suffering to take care of.

  • So I'm over here, and, um, let's have YouTube.

  • Where do I find my YouTube premium that I'm logging over here and then I have, like, family sharing.

  • So family premium family.

  • I have this manage.

  • So, um, how do I Yeah.

  • Family sharing settings.

  • 123456 You can share with up to six members.

  • So I just need to share Look, Tito delete at a family member.

  • So my family member now have a new family member.

  • It's coding train dot choo choo Cody trained, not shoot you at gmail dot com and send join my family.

  • Now, I have no idea what's gonna happen here, So I am going thio now.

  • I'm going to, um just I'm gonna do this for a second.

  • I forgot to have a key for a shortcut for this.

  • There we go.

  • I am going to go into the email.

  • I don't just want to I don't know what's in the email of that account of never logged into it.

  • You're invited to join a Google family group.

  • Accept invitation get started.

  • Joined family, family looks welcome to the family.

  • Everybody s Now if I go here and refresh learning their ago always.

  • All right.

  • No more ads.

  • Thank you.

  • Okay.

  • Uh, now, remember how he was about to do a coding challenge?

  • It's like 10.

  • 50.

  • I don't have any water.

  • Okay, here we go.

  • Everyone back to select channel shat?

  • Yes.

  • Okay, so where's my all right?

  • Okay, here we go.

  • Actually, maybe what I should do ISS No.

  • Sorry, everybody here.

  • Hold on.

  • This is the actual code from thinker con, which might make sense for me to start, but this just get rid of some, um and of course I made some Silliere counter's not to find.

  • All right?

  • Okay.

  • James schluss And what is the name?

  • Leo's Li IOS os Lee I O S o s.

  • Okay, here we go.

  • Well, job, You will exercise you go.

  • Hello and welcome to a coding challenge.

  • The chaos game.

  • Okay, this is exactly what I'm going to make in this coding challenge.

  • Thank you.

  • Press son Kumar for Super chat.

  • No more super chats.

  • Please trust me.

  • Hello and welcome to a coding challenge.

  • The Chaos game.

  • This is exactly what I'm going to make in this coding challenge.

  • Why am I going to make it so recently?

  • I was very lucky to attend this amazing event called thinker con.

  • I'm wearing my T shirt from bigger con Thank you to the organizers of Thinker con Destin Sandlin from Smarter every day, and Henry Reich and Emily Grassley and Sabrina Cruise and Robert Coleridge.

  • Event was mind blowingly awesome and amazing.

  • I met so many wonderful people links to finger con and various other YouTube samples related in the video's description.

  • So while I was there, I met for the first time in person James Schloss, who is the author of the algorithm archive.

  • A wonderful website with many sorts of algorithms in it.

  • Read more about it also from the YouTube channel that I have no idea how to pronounce.

  • Still, But Lee I O S O.

  • S, um, when I've used a lot of his videos before as inspiration and ideas.

  • Okay, so James and I did a live coating demo in person at thinker con creating this the chaos game.

  • So what is the casket?

  • What?

  • The cast game?

  • Chaos game.

  • I have to explain what it is now.

  • No, that was That was pretty good.

  • That was pretty good.

  • Cath game.

  • Pretty good originally.

  • Wait.

  • Oh, yeah.

  • Then I have the number.

  • File Video?

  • Yeah.

  • The cast game is a I'm I said I wasn't gonna cry.

  • Who's no crying encoding?

  • All right.

  • The cast game refers to a method of picking random points and interest really moving point the previous point You pick to the next point.

  • And you know what?

  • There's not really a good way for me to explain it to you other than diagramming it and actually just reading a code for it for more background on the cast game and certainly would suggest this particular video from a number file.

  • So what's amazing to be about the cast game, is it?

  • There's a very, very, very simple idea.

  • So the way we're gonna play the Chaos game is we are going to have a two dimensional space.

  • That two dimensional space is going to start with a set of seed points.

  • Now I'm going to, for the moment, just create three sort of fixed seed points in the form of a triangle.

  • Of course, heading three points or basic gonna make a triangle, let's roll on one line.

  • But that's another topic for another day.

  • And then what I'm going to do is I am just going to pick a random point anywhere that was such a fail.

  • What third try is the charm Third charms the third.

  • Okay, I kind of random point, and now I'm gonna start with this rain a point then.

  • If I were somebody who didn't code what I would fit you.

  • Really?

  • I I'm having trouble isn't the problem, but I don't live stream often enough.

  • I have a lot of trouble.

  • Um, I'm just going to start.

  • What?

  • I want to do this with no edits whatsoever.

  • So you the viewing audience, it's just gonna have to bear with me.

  • I promise that I am not going to stop again.

  • I just needed a little warm up.

  • I just needed to kind of get myself going for the day.

  • And now here we go.

  • This will all be over soon in more ways than one.

  • Hello.

  • Welcome to a coding challenge.

  • Close game.

  • So this is the chaos game playing out right behind me.

  • This is actually code that I wrote at this wonderful event that I recently got the chance to attend called Thinker Khan.

  • Thank you to the organizers of bigger con Destin Sandlin, Henry Reich, Emily Grassley, Sabrina Cruise and Robert Krulwich links to their information and Web sites.

  • In this video description, this is like a mind blowingly awesome event on Dhe.

  • While I was there I programmed in front of people underneath a rocket.

  • A Saturn rocket depicted here with James Schloss.

  • Now he never met James loss in person before.

  • But you might remember that I've used James Schloss is YouTube channel as inspiration for other videos like the Tesseract over here.

  • So James and I think he used like Julia like V I.

  • But I programmed this chaos game algorithm in the P five Web editor.

  • And that's exactly what I'm doing right now.

  • In homage to the wonderful time I had a finger cut.

  • So what is the Cascade?

  • So first of all, I would recommend this number file video about the chaos game for background.

  • It is inter process of picking random points and doing some math with those points and seeing what happens afterwards.

  • So rather than try to define it, you could, of course, always read the Wikipedia page, very tempted to do a dramatic reading of it.

  • I'm just going to describe to you how it works over here on the white board.

  • So let's say we have a two dimensional plane.

  • This is a two dimensional plane, and what I'm gonna do is I'm gonna start with a set of seed points.

  • So and maybe I'm gonna put those points in a zoo equilateral triangle.

  • But as you'll see eventually, at some point, I could have four seed points.

  • Five points.

  • I could put them anywhere.

  • And then what I'm gonna do is I'm going to play the chaos game, and the first thing I wanna do is pick a random point on the wall.

  • Here we go.

  • Who work?

  • The first try earlier today.

  • Earlier I was doing another take, and I had to do that, like six times.

  • Very lucky.

  • Now.

  • Okay, so So this is my first random point.

  • Now, what I'm going to do is I need to pick a random number 12 or three A B or C 01 or two.

  • How do I do that?

  • I have.

  • Ah, I know.

  • I just pick one from I have a book of random numbers.

  • 54157 So why don't we do seven module list three.

  • Right?

  • Seven divided by three is too.

  • Remainder one.

  • So I picked a 1012 So if this was zero, this was one.

  • This was to what I'm going to do now is move halfway to this point, and now I have another point.

  • Okay.

  • Now pick another father and a number 98818 low.

  • So I just used the last digit eight modules.

  • Three is, uh uh.

  • A divided by three is too remainder, too.

  • 01 too.

  • So now I'm gonna go halfway to this point, and I could keep doing this over and over again.

  • And if you watch the number file video, you'll see somebody do this actually, physically, with rulers and pens and all sorts of artistic talent.

  • I have none of those things.

  • So But I do know a little bit about programming, and so this is something I can program.

  • So let's actually go program this and then see what happens.

  • All right?

  • So I'm gonna use the p five gs Web editor.

  • That's is, I think, a simple enough project.

  • Um, I'm gonna go here.

  • Uh, I'm just gonna go to the editor home page here, and I'm going Thio name this chaos.

  • Game one safe.

  • All right, so let's start this off.

  • So I've got my two dimensional canvas.

  • What I need first are those seed points, so I'm going to do this in a very simple way.

  • And then Well, all right.

  • Thank you.

  • By the way, To Espen Larson, doctor circuit on Twitter, who created the ALR a factor This later song, which is, like my favorite thing in the whole world links to more about ESPN's music in this video's description.

  • Okay, so I'm creating these three points, you know?

  • You don't You know what?

  • I'm gonna put them in a random spot.

  • I'm gonna make the seed points themselves.

  • Actually, random.

  • Why not?

  • Right, so I'm gonna have it.

  • A point.

  • A point B on a point C.

  • So I need three points a X, my standing in front of the code, I kind of am.

  • So let me move this over and let me move this over.

  • Let me give myself Let me just use ah window with and window height.

  • So I cover the whole thing, and then I would make it a black background a little bit over.

  • I think we're good.

  • All right.

  • So what I want to do now is let me draw those points, so I'm gonna say stroke to 55 stroke.

  • Wait eight.

  • So I just want to see those points X.

  • I just want to see them.

  • So, um, we should see three points.

  • Now, how come I don't see any points because I am drawing the background over and over and draw.

  • So let's do this year, Okay?

  • So every time I run this sketch, I am going to now have three new points.

  • All right, so now let's play the chaos game.

  • So what I am then I need a kind of global X y We need a global X y.

  • And what I'm gonna do with that is I'm gonna also going to have X y be some other random point, and what I'm going to do in draw is say, stroke.

  • Let's make it like a nice RGB color on.

  • I'm gonna draw appointed X y, and we could see Okay, there it is.

  • So this is right.

  • Every time I run this, I have my three seed points and I have this new pink dot, which is the X y.

  • So now what do I need to do?

  • What I need to do is, I need to say, let me pick one of those three points and move halfway there, so The first thing I need to do here is just pick a random number 12 or three, Right?

  • But this is going to give me a floating point number.

  • So what I want to say now, actually is give me floor, that which will take off the decimal place.

  • And then if I get a zero, I'm gonna do one thing.

  • Otherwise, if I get a one, I'm gonna do another thing.

  • And and I know, I know there's all this, remember?

  • I know I'm over using the sound effect right now, but it's the first day I have to use this.

  • It's just it makes me so happy.

  • So if I pick zero, what I want to do is move halfway.

  • I want to move halfway right to this point.

  • Guess what?

  • I could do some math, right?

  • I could take the exodus.

  • The ex of this, divided by two, have got a new X, but there is actually a function in p five called lurk lurk stands for linear interpretation, meaning interpret late from one number two, the other in a linear fashion by some amount.

  • So if I want to linearly e want to linear interpret If I wanna learn from this point to this point by 0.0.0.5 watch when I get to Dio 50% that's halfway there.

  • So I'm gonna say X equals blerp x a x 0.5 and I would do the same thing for why, And then I'm going to do.

  • Ah, here.

  • I'm gonna do it with B X.

  • Look, it's already happening.

  • The cast game is already happening over here.

  • Look, now I only have two points so you could see all the points end up just on that one line.

  • Right?

  • Every time I restart this, all the points end up going between point a 10.0.0 and one.

  • But now let's make some magic happen.

  • Let's do the last possibility.

  • Let's plug in the sea and see what happens.

  • Okay, here we go.

  • What's going on?

  • Do I see some pattern emerging here?

  • Well, I am playing the chaos game.

  • This looks like it could be kind of familiar.

  • Let's be a little bit more methodical about this.

  • Let me actually start with unequal, a perfect equal lateral triangle.

  • I don't know what I mean by perfect, but then what?

  • I'm going to do what I need to do an equilateral triangle.

  • Boy, this is unequal.

  • Lateral triangle has an angle of 60 degrees.

  • So if I want to figure out from this top point how far down and how far over to go, I just need to use the angle 60 degrees and co sign and sign.

  • I probably got some video where I explained that.

  • Right.

  • Um, so I need to go.

  • You know what I should just do?

  • Forget the eagle.

  • I know I said I wasn't gonna do any edits.

  • I feel like the equilateral triangle is a bit of a di aggression that I don't need to have in this.

  • That's a nice one.

  • So let's let me go back.

  • So, actually, this won't be an equilateral triangle, but it will be simpler.

  • Let me just put thes see points at the corners on Dhe.

  • Then I So, uh, so I'm gonna put these see points at the corners, and then we're going to see what happens then let's so we could start to see something emerging here.

  • This pattern that's emerging, it's happening kind of slowly.

  • So what?

  • I might like to do a couple things I might like to D'oh.

  • First of all, I think it's I'm going to make the point a little less thick.

  • Then I'm also going to give them a little bit of Alfa again.

  • I have no artistic town, so I shouldn't do what I'm doing.

  • And then I'm going to draw 100 of them each time through draw.

  • There we go.

  • There we go.

  • Look what's happened.

  • So pretty, so beautiful.

  • Let's forget about the Alfa, all right?

  • And you know we could do which is fun.

  • Why not?

  • What happens if I give it different colors like here?

  • If I pick zero, let's try this one color.

  • If I pick one, let's try a different color and we can sort it and we can see.

  • Now we can see there are actually three different sections in a way of this.

  • What is that called?

  • Say it with me.

  • Serpent City Triangle.

  • So this is what's amazing.

  • The Cascade.

  • This very simple algorithm will produce a perfect rendering of a fractal pattern.

  • This one, very famously is known as the Serpent Ski triangle.

  • Very little code.

  • I've got this propensity triangle right there, so this code and challenges actually complete, but it's not over.

  • I mean, the video is gonna end at some point when I stop rambling.

  • But let's think about some things that we could do.

  • For example, anytime you make something like this, you might think to yourself water some parameters that I could start tweaking.

  • Well, why should I bother?

  • Why should I start with only three seed points?

  • Why should I only have why should only go 50% of the way each time there.

  • Why should I have an equal probability of going to each one?

  • Aren't there some other things we could apply to this?

  • So this is now your exercise.

  • Create your own version of this.

  • Could you make an array of C points?

  • Could you very the distance that the percentage distance you go to each point could you vary the probabilities of how you pick each point?

  • What else could you do with color?

  • How could you render this?

  • Could you connect the lines?

  • Could you use different shapes?

  • What if you did this without a name?

  • Actual race?

  • The backgrounds were actually like piling up all the points in this big array.

  • There's so many possibilities.

  • I'm gonna come back in a second part and at least do the part.

  • I'm gonna react to this later, but not too much later where, I mean, at least make this an array of seed points and play around with that 50% value.

  • So I'm gonna do that much.

  • Don't watch that video yet.

  • If it exists, it doesn't exist.

  • You can't watch it.

  • Try this on your own and then share with me your results.

  • And then you'll see my extra little step with this.

  • And that will be that.

  • Okay.

  • Oh, if you're looking for the code, by the way, especially when I do something in the p five Web editor, you could just go to this particular you're out, which will also be in the video's description.

  • And I do have ah, page about this challenge.

  • Also in the coding train dot com.

  • Okay, Thanks.

  • And see you next time.

  • All right.

  • Okay.

  • Who?

  • All right.

  • That was number one.

  • I'm just gonna move right on, Dr.

  • Circuit.

  • All right.

  • All right.

  • So let me d'oh duplicate.

  • Ooh, I like this.

  • That's crazy.

  • Um, okay.

  • All right.

  • Hello and welcome to coding Challenge The Chaos Game, Pop do electric boogaloo Thank you.

  • Thio.

  • Espen Larson, Doctor Circuit on Twitter for creating the Iowa over factor this later song This coding challenge is in honor of that song because guess what later is now.

  • I will re factor this now.

  • So what?

  • I'm gonna do it.

  • This coding challenge is expand this idea of the Chaos game.

  • Instead of merely creating these Sir Pinsky triangle, I'm going to make a version of this where there could be more than three points seed points and that as the points move, as the newly random point move moves from point to point to point, um, I might move by different percentage than 50%.

  • So if you didn't watch the previous coding challenge where I made this, you could pause down.

  • Go watch that.

  • Or you could just stay here with me right now.

  • Let's be together.

  • Let's be friends on the Internet programming stuff.

  • Okay, so the first thing that I want to do to re factor this would play that song again, But I'm not gonna overdo it.

  • Use it sparingly.

  • Otherwise, people will get irritated and annoyed, and I'm sure we'll hear about it.

  • The first thing I don't want to do is I am going to make any array called seed symmetrical, etc.

  • Points.

  • Let's just call it points.

  • I don't know.

  • Let's call it points.

  • And instead of having a x A why, what I'm going to do in this array?

  • Let's get rid of this first.

  • I just want to recreate this.

  • Exactly.

  • I am going to, uh, say I'm gonna have three points and I'm gonna create a new point, which is a vector.

  • I'm gonna use vector create factor function to make a new point anywhere, randomly in the canvas.

  • I know.

  • I've run a little bit of space here.

  • That's fine.

  • Um, looping over Paris by semi colon on.

  • And then I'm going to say points, push V okay.

  • And then I am going to have a point called current, which is also going to be Ah, a vector, a random vector.

  • Good.

  • There we go.

  • There we go.

  • So now what I can do is again I have just re factored this to instead of having separate X Y variables for all four points, I have an array that keeps my three seed points and I have my current point in its current points and separate variable.

  • And both of those are P five vectors, a vector being an object that can hold on X, y and Z But I'm not gonna use a Z right now.

  • Although you could do this in three D.

  • You should You should do this in three D But I'm not going to.

  • All right, So then I'm going to say four let p of points and I'm going to say point p dot x p dot y So we should see their ago.

  • Those air, my 1st 3 c points.

  • And then what I'm going to do here is random, uh, the length.

  • And this is actually now.

  • Oh, you know what?

  • I don't even need to do this.

  • Guess what?

  • The random function in p five, I must say, like, next, equal to random function, and P five will give me a random object out of that array.

  • Now, if I want to pick them with a different probability that have to do something different.

  • But hear this next is now going to be one of those three points randomly and then all I need to do is say stroke.

  • I'm gonna still give it this color.

  • Um And then I'm going to say, uh next dot x equals alert this so I'm lurking.

  • But I'm gonna lurk between next and, uh, and the current Oh, and current is the result of that.

  • The current is the thing that's moving, and it really doesn't matter.

  • But I like to think of it in this order.

  • Current is moving, and I think there's a ll actually learn vector function So I could do this in one line of code.

  • That's another we factor this later.

  • Uh, so there we go and, uh, then all I need to d'oh is draw the point.

  • Let's give all you do is draw that point and here we go.

  • Look at this.

  • Not now.

  • One thing I should probably do is also reset it.

  • Let's write a It's actually all of this stuff here, um is kind of the process of let's write a function of resetting like I want right now.

  • It's like resetting every time he changed the code because the P five editors configured to, like, relaunch the sketch.

  • But I think what I would prefer to do here is write my own function called resets.

  • The nice re factoring.

  • And, uh, I need to empty the array.

  • And I'm to say points equals here.

  • So this function reset will just sort of received the environment.

  • And I could do something.

  • I could do it whenever I click the mouse.

  • But just for right now, I can't say if frame count module ist like 100 equals zero, then reset.

  • So what that's gonna do is every 100 frames, right?

  • Because modulates of the number 100 equal zero any time frame count is divisible by 100 with remainder of zero, so you can see over and over again.

  • This is gonna know I'm I'm here.

  • I have really factored this.

  • But now that I have re factored this exciting, Okay, So for example, I just do this.

  • No.

  • Oh, yeah.

  • Look, now, interestingly enough, I don't really get a pattern.

  • Nets Super interesting to look at with four points, kind of accidentally.

  • I sometimes am, um and so what happens if I have eight points?

  • Who's crazy now?

  • Probably what I would want to do.

  • What might make sense for me to do is place these points around a circle.

  • Just it's interesting to have them randomly.

  • But I think I would prefer just sort of figuring out what I want to do with this toe.

  • Have all those points around a circle, right?

  • So you can think about actually this was a way of getting my equilateral triangle that I was looking for.

  • So what if I have eight points on Then I get some kind of like ex con octagon SEPTA gone.

  • Whatever.

  • The number of sides is based on the number of points for three points in the triangle.

  • So you could you could sort of do the math there.

  • What's gonna be if I increase the number of points?

  • So let's actually not reset them randomly.

  • Um, but let's reset them.

  • And in that sense, I don't need to This can actually just being set up, but always keep the same seed points.

  • And what I'm going to do is say, I'm gonna have an angle which is going to equal to pi divided by eight.

  • So let's make a use Const.

  • For a constant just to be, have fun.

  • I mean, call that end.

  • Oh!

  • Oh, I didn't Did I not switch back?

  • Uh, all right, don't worry.

  • Everybody I have figured it out.

  • Camera, camera, camera.

  • I know.

  • So, hold on.

  • I'm gonna go back.

  • All right.

  • Um, all right, here we go.

  • All right.

  • All right.

  • So what I'm gonna do here, actually is, uh I'm gonna have a fixed set of points, right?

  • So the points are I'm just gonna do once in set up, and what I'm gonna do is I'm gonna use that.

  • Constitute constant n equals eight.

  • I know.

  • I could be using Contin, other places, the code If you want to know more about concert.

  • I made a video about it where I got a bunch of things wrong.

  • You could watch.

  • Do you find a different resource for that?

  • But so I just not making any points.

  • And what I'm going to do is say the angle is to pi divided by I.

  • That's a bad idea, because I don't want to divide by zero.

  • Um, so All right, well, say, um oh, it's I know what it is.

  • It's I times two pi divided my end.

  • That's what it is, right?

  • Because I want to have I'm looking for.

  • And if if Ennis four, for example, I want zero degrees 90 degrees, 1 80 degrees to 70 degrees.

  • It's probably go the other way because the screens flipped.

  • But that's the idea.

  • So now what I'm going to do is they create vector at, um, some number like Let's just do 200 times co sign of the angle.

  • Oh, you know what?

  • I think there's p five vector from p five dot vector from angle, I think is a function angle that's gonna make a vector from that angle.

  • And then I can say v dot um uh v dot multiply 100 and that's working.

  • But I need thio translate to with divided by two height divided by two.

  • And now we have these points in the center.

  • Of course, I also if I want, I need to do that here.

  • Okay, so there we go.

  • We can see now I've created eight points around and let's actually use um Let's make that a little.

  • Why's this down here?

  • 00 there's a weird mistake goofy mistake happening, because when I reset, this is this is kind of you know what?

  • I'm gonna D'oh The translate is fine, but it's bothering me.

  • I'm just gonna make life easier on myself and say ad with divided by two divided by two.

  • Right.

  • I'm just gonna move that to the center manually by adding that to the vector.

  • Okay, Now what I want to do is multiplied by like, with divided by two or something.

  • Okay, great.

  • So now you see, those are all my points were still playing the chaos game.

  • Now what I want to do is I am going to have a variable called percent.

  • And also, I just want to make, like, a lot more points really quickly, so I can just see the pattern.

  • And what I'm going to do now is I am going to try.

  • I'm going to when I ll ERP I'm gonna learn by that percent and let's try different values.

  • So let's try.

  • So let's go back to 0.5.

  • And this is what I get.

  • Let's dry 0.25 Interesting tried 0.1 with tried and a four 0.25 six Do I need like we get something more interesting.

  • Ice could have sworn when I thought about this earlier.

  • I'd get more interesting patterns.

  • Time out for a second.

  • Um, all right, let me think about this sworn when I was looking at this page here side of Pentagon.

  • Oh, but the current cannot be the same.

  • What's droid?

  • Pentagon.

  • They just should've picked five.

  • All right, I'm back.

  • Um, Nico Monsoon in the chat said Try three just to see if you didn't break anything.

  • So I made the point and equals.

  • I made an equal three with a percentage 30.5 and we could see I have this Rypinski triangle.

  • Actually, if you look on the Wikipedia page for chaos game, you'll start to see ah, bunch of these.

  • Ah, point inside A square repeatedly jumps half the distance towards a randomly chosen vertex.

  • But the currently chosen Vertex cannot be two places away from the previously chosen for text.

  • So this is interesting, right?

  • So I could actually start to create some of these patterns by modifying how I pick a particular point.

  • So this one actually would be nice.

  • Let's do The Pentagon won a point inside of Pentagon repeatedly jumps half of the distance, But the current treasure verdicts cannot be to say this is gonna be an easy one for us to implement.

  • We just need to get a new random number.

  • That's not the same as the previous one.

  • So, um, so let's go back here.

  • Let's first make this five.

  • Okay?

  • So we could see even with five.

  • A Pentagon were kind of getting a somewhat of an interesting pattern here.

  • And I'm like, I don't know why I obsess over this sort of stuff, but I kind of feel like, let's give this just like a little bit of Alfa and make the stroke Wait one and do, like 1000 points.

  • All right, so we just sort of see this pattern more quickly.

  • Okay, Now, what was I doing?

  • So what I want to do now is not allow the next point to be the same as what was previously chosen.

  • And so there's a variety of ways I could do this, but actually, I could just create a way of I could just create a way of ignoring it if it happens to be the same one.

  • So let's say previous to create a variable called previous and right here.

  • When I pick previous equals next and I'm going to say as long as next is not equal to previous, then I could do this stuff.

  • So now look a thistle.

  • There we go.

  • The chaos game Pentagon with one slight modification.

  • And you know what?

  • I don't want it to keep resetting.

  • I just wanted to, um I want to tell it not to reset.

  • And I want to go to share full screen.

  • And I'm gonna put this in a different window and we're gonna bring this up here and we're just going to enjoy this now.

  • Okay, here we go.

  • You're done.

  • Chaos game.

  • Thank you very much.

  • Look at this.

  • It's so beautiful, intricate and amazing.

  • So I now encouraging Now you've really got something right?

  • You can start to make a variety off patterns.

  • And here's the thing. 01:00:28

Okay.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

直播#161:混沌遊戲和快速抽獎!API (Live Stream #161: Chaos Game & Quick, Draw! API)

  • 1 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字