Steering Behaviors: I got Flee and Evade wrong!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Music] so [Music] do [Music] [Music] aha test one two oh my goodness everything was breaking but i believe you should be able to hear me now and i am just about to begin um there's probably a loud hum because it's very hot to have a fan going let me know how how irritating that fan [Music] is [Music] so do [Music] do [Music] hello happy coding train live stream day it is me your host daniel shiffman with very very dirty glasses let me see if i can clean these it's very unlikely that this is going to do any good it's a miracle that i am here broadcasting to you live at this very moment it's a miracle if this is actually working and you are hearing and seeing me um i'm checking out the discord chat uh simon says i don't even hear the fan that's good news um and in the youtube chat i see frank says hello and dara zee says hello and radesh says hello and alex says hello okay um i i was in a panic for like the last uh 20 minutes trying to get this uh stream together i've upgraded my laptop which is right here uh my monitor is over here which is why i keep looking over here unfortunately my arm is cut off because my layout is all wonky i'm in a transition phase for the coding train and i have some announcements and information to impart um and um i also have some work to do on today's live stream which is very important and involves coding let me briefly before i forget um come over here and say a thank you too and i totally messed this up today's sponsor brilliant brilliant is a website and app um one of the things i'm gonna come and look at some of their new lessons there's a new there's a redesign of their course algorithm fundamentals which is really exciting and i want to try some of it but what they're really emphasizing and have done a lot of redesign of their courses is interactivity and interactive lessons it's really fun you know i don't have my um uh mug that i usually like to use my geometry mug that you like to use to demonstrate static learning versus interactive learning this is a brooklyn cyclones mug the minor league team here in the coney plays out of coney island um but you can sign up for free check out brilliant brilliant.org codingtrain um you can sign up for free if you want to unlock all of the courses i'm going to show you some of them later the first 200 people to sign up through that link will get 20 off all right so what are my announcements i really meant to make a list so i'm just going to have to rely on my own memory and widths which has not been very reliable if i'm being perfectly frank these days um but i have some things to discuss number one i think if i come back here um i have to press this button manually because i've messed up my stream deck where all my buttons work number one are you familiar with the coding train website it's where i collect all of the content that i have created over the years on the coding train youtube channel it is categorized into various uh a navigation bar one of the things that's super important to me is to have this beginners tab where you can see like these are three uh tutorial sequences that you can start with with no experience whatsoever for total beginners there's a bunch of things organized here under learning there are the coding challenges which tend to be the more sort of popular videos of mine where i work on an individual project this website is undergoing a complete and total redesign and i am looking for you the viewer of the coding train to help with this redesign in fact we're looking for a few volunteers to do some alpha or beta testing and month on says it's the best website ever oh boy it's gonna get so much better um but i'm looking for um some volunteers in particular with a range like somebody who's totally new to coding maybe new to the coding train somebody who's maybe been watching the videos for years and maybe has a um a lot of experience coding anyway i'll be doing this recruiting if you want to participate in the sort of testing and feedback for the new website design in discord um so what's discord you ask um let me just switch over to this camera um and um i'm over here and i'm switching now to here um and aha okay so let me make this a little bit bigger before i show it to you and close this okay now this is discord it is a chat um system that you you're likely familiar with if you spend any time in participating in online communities started discord started i believe my understanding for gaming communities but um you know i'm a member of different discords for some podcasts i listen to and there's a coding train discord there's a uh ml5.js discord anyway uh this us join the discord uh follow the instructions in the readme um sign up for getting the notifications role and soon um kobe who is our discord manager the coding trained discord manager i haven't actually let kobe know about this email is forthcoming later today we'll be making some announcements for how you can get involved in helping with the new website design okay so i wanted to make that announcement the goal is to have the new website by the end of the summer i've the other thing i want to talk about and this you might not realize this i don't even know if i realized this this is something of a bit of a momentous occasion joseph asked me here in the chat are you in new york city now i saw some pretty scary videos of the hurricane hope everything's okay so thank you joseph i am fine i am in new york city i'm in brooklyn um the hurricane which was by the time it sort of uh uh wafted over the city was i think downgraded to a tropical storm um it um it hit around like 5 a.m this morning i was sleeping i sort of woke up it was actually quite nice to have the sound of the rain because it wasn't that extreme of a storm at least from what i could tell um and everything seems fine here there was quite a bit of flooding but i didn't i didn't really experience that where i am and i i hadn't really been going anywhere other than in my immediate neighborhood so but i uh brought i have been i think for about the last year i can't remember when i moved into the attic in an attic if i if i um let's see let's see if i can get this to work hold on a second i'm going to show you what's going on and why i'm a little sad to report that there might be some light um let's see if this works elgato camera what's it called the epoc cam uh let me see if i can add that add a video capture device add existing epoc cam there we go okay hi so now i'm just live streaming from my phone and i'm going to give you a little behind the scenes look here let's see if i can flip this over and in fact um uh okay let me put this down for a second this is my stream deck that i was fighting with uh there's no reason for you to have to uh okay hold on ah what could what do i do here this is impossible okay there here's a little scene for you this is live producing the show as i am recording the show uh here we go let me move this over to the side this is me here where am i um i am uh this should go down i guess so it's behind me at some point it'll get behind me there we go so now i'm in front of it i don't know i don't know how i feel about this let's move this over here better better much better okay so oh but now i can't point to it i'm really obsessed with it all right it's fine uh all right so what you're seeing here is my uh console which has discord open uh the youtube chat uh open broadcast studio there's my random number book um i sort of keep track of uh like some stats on youtube like you see there's 174 people watching my numbers have been way down by the way which i i you know i think is mostly the fact that i'm completely inconsistent in my schedule and content here's my laptop over here but i was going to show you very quickly you can see this giant pile of boxes also some lego that i need to get working on over here i am moving and um it is not necessarily a permanent move uh but it is um it involves not being in this attic anymore for the time being i think this is my last stream from this attic so i'm attempting to move uh and broadcast from uh a different location which i will talk about in the future once it's sort of set up but i am um going to try to broadcast from a garage up in upstate uh further upstate in new york it's probably gonna take me several weeks to get that set up so i have a lot of content still that i'm working on in terms of video tutorials and things that will come out i don't know why i still got this camera here um and i will be back to brooklyn also at some point uh in the in the nearest future i think it's all very complicated if you wanna i i maybe this could be like a member bonus i can i can do a member q a in the discord about my complicated life planning for the next year but it's just all very unsettled and it's a puzzle and the schedule is off so i i have to apologize in advance for what will probably be a period of no live streams however if all goes according to plan and i've said this before and with various moves and changes i've been shuffling around over the last few years but if all goes according to plan i'm gonna have a very large space with new equipment i mean a lot of the existing equipment but i'm also going to get some new equipment um and hopefully be able to have a more a better experience for you of both video tutorials that are published on the coding train as well as regular live stream events my holy grail what i am trying to achieve and gareth asks is that a millennium falcon wait um was that the lego you're asking about oh no it is the death star it's lego 75159 the death star um uh and um i have other questions to answer here these are good questions from abe and david i will get to those questions um my my goal my holy grail is to have a regular weekly time with an organized structured schedule for my live streams and we're gonna see if i can make that happen i have a feeling there's a good chance i'm gonna be able to make that happen starting january 2022 but if i can make that happen starting in september 2021 i will be very happy uh abe asks why do i always wear the same hat well first of all i really need to get a new orioles hat this is a baltimore orioles i grew up in baltimore as a kid going to see the orioles play at memorial stadium i like to call that i like to call camden yards in baltimore the new stadium and recently even a few years ago someone pointed out it's not really the new stadium because it's been there for over 20 years but when i was a kid i was a big baseball fan multiple orioles were my team they're still my team i wear their hat i like the color i like the cartoon character i like everything about it um so that's why i wear this hat oh i did pronounce ah by uh i i'm not good i'm so i i apologize it's very important to me to learn to pronounce people's names correctly i feel like it's uh um it's it's i don't know rude or i was disrespectful it's it's not very nice to like mispronounce people's names especially if you've been corrected and i try to really like learn my students names and my nyu courses and pronounce their names correctly and i really struggle with it and i got it wrong again so if i could get a reminder in the chat with the phonetic spelling uh mark boots says we'll see which is right um ah so david says so i know you're having external people upgrade the site but will it be open source eventually so david i let's be so the idea is for the site to remain open source and for it to continue to be a community maintained uh website um and actually um david we can talk about this um ah bye thank you ah bye bye thank you abbay abbay is who asked about the hat um but david let's uh chat let's have a chat about it because i would love to loop you into more of the stuff because i know you've been such a kind and generous contributor to the coding train um adriel oliveira is in the chat uh adriel is a member of the coding train i see mark boots um if anybody who uh is a member who hasn't gotten their stickers uh the train whistles are there's gonna be lots more to come about that boy am i just a broken record about the things that are to come they really are they really it's really happening and the progress is happening every week make sure that you're in touch that you filled out the google form and that you're in the discord member's channel if you haven't okay um peter says thank you for everything you share since all these years amazingly um thank you peter i'm wondering it's very unlikely but i met a viewer in uh i was getting my car serviced actually the air conditioning wasn't working i had to get it repaired and i met somebody in the waiting area at the uh at the car repair place who said oh i watch your videos and that was kind of amazing um all right so core asks would you want to go into p5 plus bluetooth like the arduino um there is a um a bluetooth library for p5 i would recommend that you check it out maybe i can pull that up and take a look at it alright so what i'm trying to think if there's any other um um news um mark uh why don't you uh hopefully somebody can help you with that but just um tag me in a message after the stream is over and i will help onboard you with the google form craig asks any coding in this video yes so um i have been slowly but surely working on and i'm going to pull it up right here whoops if you've been watching any of my videos as of late if i go to the coding train on youtube and i go here to videos you'll probably see that what's been released most recently are 5.1 autonomous steering agents in introduction 5.2 seeking a target and 5.3 flee pursue and evade the next video to come out is arrive then i have a video that was recorded on the wander steering behavior and a video that uh was recorded on path following so i i i make reference to this incessantly but this quest that i'm on uh to complete a p5.js version of every single one of these steering behaviors and to stay as faithful as i can to the original implementation of these steering behaviors now what i want to show you that's very exciting and it's going to take me a minute to get this up and running here uh great i'm already here is that i have yeah um i was able to get an older version of java working and running on my computer so that i can run the original craig reynolds applets now i wonder what year these were created the paper was published i believe in 99 1999 um i hadn't even really like no i i didn't know anything about coding then really at all i mean maybe i'd done a little bit here and there uh i was an adult i'm apparently quite old to be on youtube live streaming although i i hope to be doing this for the long haul i'm not going anywhere people this is this is my life's work i don't you know i keep thinking like what do i what what do i want to do with my life as a 47 year old human who's 48 year old 48th birthday is coming up by the way in 20 days not that i'm asking anybody to get me anything or wish me a happy birthday just noting that you know in case anybody wants to keep track um so what was i talking about ah so um i'm really you know one of my passions um is uh kind of computer graphics history um it's why i like to focus on kind of topics like perlin noise uh particle systems and looking at the origins and early implementations of some of these uh algorithms and techniques that we take for granted and steering behaviors to me is probably um you know where i you know learning to to program steering behaviors is probably where i really like fell in love with creative coding um anyway so um so you know i have a whole chapter on this in the nature of code book i implemented a bunch in processing i'm redoing them i'm updating what i have learned what i have really learned is that a lot of the assumptions that i made even by even reading the paper and trying to follow it and make um and make um what was i saying i lost my train of thought haha because i'm also reading the chat while i'm speaking which no one should ever do um completely forgot what i'm saying but i'm talking about steering behaviors oh um you know i i i um i diverged from quite a few of the uh techniques i diverged and altered my implementations away from some of the the way it's described in craig reynolds original paper so um and some things i did that you could you know perhaps make an argument as an improvement or a kind of way to simplify the algorithm to make it more approachable but some you could also argue are like kind of egregious mistakes and this last video that i published flee pursue and evade uh pursue is fine but the way that i implemented flee and evade was quite off base and one of the things that i really am trying to do more on the live stream is address feedback and comments who's whose birthday is it today fox the bomb oh your birthday was yesterday um um ronald writes i've been working on craig reynolds boyd simulation vanilla js oh that's cool i would love to uh follow your work there um so and i meant to a practice that i want to get into is compiling a list of comments that i want to address and respond to uh from recent videos and i did a good job of doing that last live stream and i couldn't get it together for today but i know in fact that there are some excellent comments here and mostly i replied to them i think if i wanted to address them so let's take a look at some of these um how do i find the comments if i zoom in here is it below all this yes okay first of all uh oh mark boots upgraded the membership to conductors mark thank you for upgrading your membership to the coding train to conductors i forget which level that is i think that's the highest level oh my goodness well this means that you will be receiving your very own custom laser etched train whistle with a random walk pattern on it stay tuned we'll chat about in the discord okay uh getting back to these comments um all right getting in early congratulations on finally finishing every steering behavior and happy new year's 2033. okay let's see 2033 how many years from now is that not too far away if i'm being perfectly honest uh will i have completed place your bets now i don't know if you know you can if they're taking what the line is in las vegas at the moment engineer is the highest conductors is great though in the middle i can never remember thank you bye bye um um i'm reading the chat is fascinating and i really shouldn't read it while i'm talking i want to address and participate in the conversation um and brennan says you should check out david fulmer's comment uh hopefully i will we'll see what i get to but um anyway we'll see i don't know what the line is in las vegas while i get to all the behaviors by 2033 place your bets all right that was my uh joke that i was in the middle of that i completely uh botched because i started reading the chat all right so let's look at this first comment from nick combs pursuit should probably check further ahead of the target's velocity based on the distance the longer it takes you to catch up to something the further it will have traveled all right so let's go look at the code and let's um let's see if we can actually make this improvement um so by the way the main topic for today um you know i'll be here for until about 2 p.m eastern hopefully i'll finish a little bit early i have tickets to see black widow later i'm very excited about that hopefully taking the kids we're big marvel fans um in this household um so um i have my issues with marvel i don't we don't need to get into that this is not a this is not uh your uh cinema essay uh youtube channel it never will be but um um but um i'm going here nature of code sleep pursue evade so every uh video on the coding train has a webpage that goes along with it where you can find the video and you can find all the various code examples uh the ones that i code in the video as well as additional exercises that i often refer to or demonstrate and so um let's just look here at the pursue i think i actually want to look at the pursue bouncing ball one to make this point so what this is is it is oops this vehicle is pursuing that uh pink dot and when it reaches the pink dot the pink dot disappears and reappears in another location and the cycle repeats so the target that it is pursuing um let's make a duplicate version of this excuse me um let's call this live i'm just gonna um i don't know what to call this i should whatever uh um live stream variation i'll think of something better later um if i look at the vehicle and i think i would like to see the debug information so let's put that in so and that's uh very hard to see i don't know why i did it that way okay so we can see that what the vehicle is actually pursuing is the target the green dot because the idea of pursuit is what it's seeking it's pursuing the um the pink dot and why does it get stuck on the edge sometime that's another thing i need to fix it's pursuing the pink dot which means it's seeking seeking the green dot which is a predicted future location and the comment is check further ahead based of the target's velocity based on the distance wait this is actually not what i thought this comment was i i i my understanding of this comment i think some other people wrote this as well um and i'm just peeking through the comments to see afraid of the target yes this is what i'm looking for uh tmc posted this pursuit should derive its estimated target position based on the distance the pursuer is from the target oh oh this is even different than what i was saying wow this is so interesting so in my brain what these comments that i was imagining i was going to find were that the uh this the distance the distance of the green dot from the pink dot should be mapped to the speed of the uh the pink dot right if it's moving faster we might want to try to look further ahead to head it off if it's moving slower um we could seek i don't know what i'm saying we is the vehicle could seek more the actual location of the dot so but now also oh boy is coding garden streaming so i uh um i didn't you know i wish that i i had known that and planned better because i definitely don't like to uh conflict with coding garden but let me just give a plug to go to garden on twitch everybody feel free to go watch the coding garden stream uh you really want to that's that's going to be much more productive and useful than this one so i don't know if both comments are the same but there are two things that there's there are several things at play here um one is um the vlog so let's just look at what i was thinking which is what if well first i want to fix this issue where it's getting stuck so the target ah okay this is why the target is reversing its position when it gets to the edge but sometimes with you know a rounding error or whatever it might not make its way all the way back on and um it should um we might have to slide it back to make sure it is exactly at the position it should be so let's make this correction [Music] and then we can do exactly the same but with a y and height and exactly the same but with y and to be consistent i will put the position so this is very long-winded i'm sure this could be consolidated or written in a more elegant way i always am saying that the prediction could also take the bounces into account yeah now that that is far too sophisticated for my little brain to handle right now so one step at a time but fw that is an excellent comment i love that that i would love for somebody to go off and implement and tweet at me at jiffman or like share your own share your own community contribution to this um um if you implement that where it can actually like predict the bounces oh i would love to see that that's really a cool idea um so uh every time it hits the edge in addition to reversing its velocity it also um it also makes sure that it doesn't move past the edge so that should fix that issue um all right so now what i wanted to do was map a couple things one let's see how crazy we can get about this so in where is the pursue function here it is so right now this is this number 12 is just hard coded so that is the look ahead value like for example if i say let look ahead equal 12 let's make it equal to 50 and then i put it in here we can see it's looking ahead 50 pixels now wait that seems way more than 50 pixels oh it is taking in so it's already so first of all way to read your code shiffman uh it is already taking into account the vehicle's velocity because it is not the fixed look ahead it's not a fixed look ahead distance it's a look ahead factor really based on the velocity how how many frames should look ahead so now i'm realizing and maybe i addressed that in the video and i just didn't realize that i did that right so let's put that back to 10. so i'm fine with that i'm keeping that now i think there's another interesting aspect that was um was pointed out and chris is writing this in the chat right now uh green dot location should change based on both the pink velocity and the distance between your vessel and pink thank you chris for putting that so eloquently so let's look at another value here now in the pursuit it's too bad i'm gonna i i wanna what i wanted to say was somewhere in here i'm probably getting that distance but let's just look at it again it's not that much math it's not something for me to really worry about in this case if i had a hundred thousand vehicles and a hundred 000 targets i might start to really need to think about optimizing but i think i'm okay in the clear here so distance is a p5 vector.distance between the target and uh i'm so confused oh i'm pursuing the vehicle and this dot position so that is that particular distance so what if i just um actually added that to um oh what if i i have an idea what if i said let so if i said prediction set mag that distance and let's make the look ahead factor one so right now you can see that it's actually kind of cool to watch uh the the chat is saying target.pause but it's actually just the target because the target is already a copy of the vehicle's position but you can see now this is kind of cool i really like this as as it gets closer something's wrong here though i mean it really it really should also have to do with a comparison of i guess that's gym or maybe that's just too much um so what if i then said this was zero point like just 20 percent of that okay that's 50 of that and the problem is when it's behind i guess it's fine when it's behind it because it's going yeah this actually makes sense and then what if i then had a look ahead factor also um or do i want it based on the speed so maybe what i don't want is do i want to multiply it by the i don't know yeah ah a buy was um a buy has a um a great comment which is why did you make the target bounce off the edges why don't you add wrap around yeah this is totally arbitrary i just picked like i was just in the video i'm showing like a bunch of different things you could try and so the bouncing here is definitely creating a bit of an odd behavior um mark writes the green dot represents how far the pink dot can look ahead the pursuer can see much farther that doesn't seem fair interesting yeah so again i i what i'm trying to emphasize here and i think i can i can stop is that there's no right or wrong answer to this question um the idea of these steering behaviors is to creatively design the system according to what you feel makes sense for whatever it is you're building or to just explore a bunch of different ways of trying it so i could try multiplying these things together i could add them together i could take into account a velocity velocity of the of the vehicle of the target you know all sorts of things um all of those things could be great things to add to the look ahead factor but it's interesting to see i just i like this behavior of seeing it kind of like shrink down as the vehicle gets closer okay um let's see i do want to um take a look uh ah oh look at this and right here uh julio [Music] made a community contribution and this is the time on the coding train where i share the versions you made which improve upon and creatively twist the examples in various video tutorials and things that i'm doing here on the channel so i'm so glad that this was submitted let's take a look at it better pursue algorithm prediction based on distance and speed of both target and pursuer it's everything that i was just talking about i hope this link works ah oh my goodness this is wild oh this is so fantastic so we can see here it's really like this very intelligent understanding of when exactly to meet it oh my goodness this is so good oh i thank you internet world of people watching the coding train that i can just plant the seeds and this can flower oh amazing let's take a look at the code um so first of all we can see there's a nice little draw arrow function which is cool to be able to see these things as arrows not just as lines this looks like it's the same uh pretty similar technique to what i'm doing um yep this is all based on the code that i've written so we should be able to just pop down here and look at this okay here we go this is the brilliance right here there's a lot of stuff here i'm going to try to make this wider so we can see the full code okay speed ratio let's try to unpack and understand this ah and and this is a great comment from chris who's talking about we could use an evolutionary technique to optimize uh which is a really really wonderful idea okay speed ratio i'm gonna try to understand this vehicle's uh speed divided by max speed ah okay so how fast is it moving from zero to one according to its maximum speed that's great to always normalize your values so that you it's going to help you tune the parameters such a smart thing oh thank you uh the coding by the way i have now i have resigned from my position as host of the coding train uh julio if i'm pronouncing your name correctly uh um wherever you are uh you're welcome to take over i'm done this is so good uh yeah target angle right this is taking this is what i'm saying is taking into account the angle of the approach the angle between uh the vehicle's position and the target's position wow the pursuers and the targets position then uh take the sine of that angle times the speed ratio and then i'm lost now so i'm going to need help with this one i'm going to need i need a white board which i don't have and i also don't want to get two i'm going to have to i'm going to look at this a little more later maybe somebody um can uh ex uh david please give my regards to uh coding garden um so um what's going on here take the sign of the angle which would be the um value of the adjacent um the length of the adjacent side so that's like the d that's the distance okay that's actually not so bad the distance then um shrink it by the speed ratio and then get the angle back so basically it's oh it's the amount it's like the arc length i actually i i read it i think i understand it um what's a good i i don't i really need a whiteboarding solution for when i'm live streaming my the place where i'm um where i'm moving my studio to i'm gonna have i hope a very good uh diagramming system and i just don't have that right now um i don't know if anybody followed my sort of like talking through me reading this code understanding but i have a picture of what it's like in my head i guess i could hook up a tablet or something and draw with my finger but i'm going to move on then i'm then we get the distance and the prediction is oh now i'm lost again the distance times sine of that angle uh divided by uh sine of my pi minus my angle okay um yeah okay so i now i uh uh i definitely i need my white board i need my diagram but you can see here that what this is doing is it's taking into account multiple factors let's just look at it again because it's really quite beautiful to watch like that distance is not just related to like where it's supposed to seek is not it you know is really relevant like if it is if it is moving uh in parallel to it from behind or in front versus at a perpendicular angle like where it's going to meet it is based on their relative locations uh as well as the speed that they're traveling so and chris sears like uh sine is opposite over hypotenuse yeah why did i say adjacent i don't know why i said to jason because i'm panicking and trying to do math in my head without drawing it while live streaming sorry to get that wrong we'll edit this out of the live stream later dub uh we'll dub this over um yeah chris saying this looks like the law of signs so let's see if we can find a nice diagram of this speaking of why you should subscribe to um oh shoot my button's not working brilliant i have a feeling there's an interactive lesson to help understand this but um the law of sines uh is a sine rule relating the length of sides of triangles to the sines of its angles yeah so uh we can see we i can imagine here that we've got kind of this big triangle where we have the vehicle's location the pursuer's location and we're trying to find and then their velocity vectors right uh we're trying to find what it's where where where the two shall meet the seeking target so that that totally makes this totally makes sense that you would use the law of signs right what if this is where the vehicle is this is where the the target is and the target is moving in this direction well based on its speed uh you know we want to figure out what's the triangle uh that's going to where they would meet and based on its velocity and its velocity and so if it was moving at a certain speed um and the vehicle was moving at a certain speed with a certain steering force we could imagine that this could be the part it would want to steer towards here to meet this vehicle at the moment where it gets down here so it makes a lot of sense that the law of signs would be um happening here and i would love to implement this in a video i kind of almost want to like try to code it myself but i have other things to cover today i'm almost at the halfway point and we have this beautiful wonderful example what a surprise to find this today um a train whistle for giulio a bell for giulio i mean julio should get a random number here for sure for this wonderful uh this random number is in honor this extra special random number is in honor of julio in this amazing contribution to the pursuit uh steering behavior and the random number is on page 211 row 10515 column zero one two three and it is thirty four thousand or sorry it's not a number it's a sequence it's a random sequence of five digits three four seven six four there you go wonderful work thank you ah beautiful all right we're moving along now back to uh the comments um all right fixed multiplier we're looking at this now i want to see i want to find the correction that simon pointed out to me and so let's see i'm just going to scroll through these comments here uh so it's about flea i'm pretty sure somebody pointed it out i thought i kai replied to it oh yeah why doesn't he have the target evade the pursuer ah yes why didn't i do that so i'm definitely gonna i'm gonna fix evade and then i'm gonna do that that'll be great let's do that uh okay um i'm looking for the i'm looking for the comment that i'm looking forward i made a really big mistake in flea and evade interesting i don't see the comment uh i'm looking for it by the way this is amazing to me i found your channel through nebula um not not a sponsor for today's uh um uh video um but a sponsor of the coding train wow where does anybody see a comment that has the correction i really don't think anybody would want to listen to a coding train podcast although i appreciate the comment julian uh i don't see it looking at the chat i pointed out i know simon you pointed out in discord but it was brought up i i saw um some youtube comments about it for sure uh ah yes here it is from trevor long time listener first time caller love that love this and you thank you always nice to have an i have a nitpick question i would say not a nitpick this is a pretty significant error and you could see that my reply is even incorrect which i will unfold and show you how i got it wrong in the move from seek to flee and pursue to evade does it matter that it's the steering force that's being negated rather than the desired velocity i don't have the paper in front of me but i feel like the order of operations is not quite correct you're absolutely right so i want to correct this let's fir let's go look at the paper let's see if we can find and confirm and and again i'm sorry that i don't have a diagram maybe i could share simon's diagram which is i will just super helpful i will pull that up in a moment um let's look for flea yeah so look at this actually simon's diagram is like this type so first of all i can even just see right now from the diagram i did it incorrectly and i it it's so uh it upsets me so deeply because it also goes against the sort of core principle that i was emphasizing in these videos where everything is derived from the desired velocity and if you think about it the desired velocity you can't just the desired velocity for fleeing is to move in the opposite direction and what i did is i just took right if this is the desired velocity right this is the current velocity so the seek steering behavior is desired the desired vector minus the velocity vector and you can see that here and that makes sense it's a vector that's going to push this triangle cause it to steer and seek along the path to the target so what i did for flee in a very lazy way is i just said negate that so the steering behavior is this way and in truth it's not so horrible it's definitely going to move away from the target because instead of turning this way it's going to turn this way but in truth um it's it's the actual flee uh steering vapor should be this one because i should be looking at its desired velocity first and then taking desired minus the current velocity which gives this red vector so the steering the flea steering path you can see is this red line my guess if i could if i could draw on it like maybe i could do it with my finger slightly um would be like no i can't because i'm tiny in the chord i have to make myself really big and i don't have an easy way of doing that but i'll just do it with the mouse arrow my guess is that if i do it my way the path would be something like this a mirror image of this path which this is not a mirror image it's a more extreme term and then um brennan is saying this multiple times that um there's a comment from and i uh david fulmer and so i i'm going to go on yes so uh here it is uh let me just heart this um so let's read this comment it's a long one i don't know if i'm i usually don't but let's i believe the argument by trevor sargent is correct the desired velocity not the force should be flipped thank you and it does make a big difference um so uh let's i assume uh upon further investigation during my live stream it is most definitely not the same and this is such an error that i plan to record a separate video about this correction i'll do it on my tick tock i don't have a tick tock there's no tick tock by the way if anybody wants to be hired by the coding train to just make shorts out of my videos you can figure out a way to do that i'm i'm i would be open to that i i keep youtube just sends me a message after message like try our shorts try our shorts try our shorts we're pushing shorts shorts are great you should make shorts make shorts shorts short shorts i don't know i can't do it i can't do it i can't do it um so where where do i have my live stream open let's just put a link to it for future reference um i will get this video url uh if someone can reply with the time code after it's published that would be great okay so i'm replying here and then david uh thank you for this excellent i i i'm i haven't read over the whole thing i'm kind of going on faith here but i conceive uh and actually right now i just jump to the middle it's why i don't like steering behaviors because of how it should be done is so ambiguous that mistakes like this can be made easily so it's interesting i'm gonna flip what you say maybe i'm just like the glasses half full eternal optimist but to me your reasoning is exactly why i love steering behaviors because i you know i am saying this is a mistake and it's a mistaken that i didn't follow reynolds instructions so to speak but i think there's no right or wrong answers here it's about creatively exploring the possibility space uh all right so i'm just replying there that's really terrific um so let's take a look at correcting that right now and let me see if i can pull up simon's diagram which will also be super helpful so i'm just going to go into the discord the reason why i'm just going to my camera here is i don't like to show people's messages without their sort of permission so um i'm just going to open the image and then come back here so this is a diagram that simon made for me which we can see basically if this is the current velocity um and this is the and this should say that these this is the seek desired and this is the flee desire so this is not the seek force this is not the flee force this is the seek desired velocity this is the flee desired velocity then this would this is the seek steering behavior and mine did this red thing which is obviously different than this particular now it looks like it's so extremely different because of the length of this vector but you have to remember that the length is capped at maximum force so most likely it's not going to be as extreme of a difference but it is significant um okay so this is and and k is writing i just wanna it's so lovely that dan replies to comments on his videos i don't know maybe you're referring to me typing the comments but to me this is the greatest discovery ever of being able to use the live streams as reading through and going over and issuing corrections and seeing the the creative um i mean the whole point of what i'm doing is to build a community of people uh making this stuff uh and as you can see i'm not particularly you know i am not the expert or i'm not the the i i i'm trying to even use the the words that i'm trying to say but um i'm not i was just like i i always say i'm not so good at this but i don't want to say that because i don't want you to say that about yourself so so i don't want to model that paper we're all learning and figuring this out um and can't do it on your own it's what i'm trying to emphasize um all right so um let me just go back to here so let's um let me fix this and then i'll take a break i'm just closing um back the discord um if anybody i will post some links here if anybody wants a link to this um diagram i will put that in the i'm in the um so if you're in the discord under live schedule is where i try to keep people updated on the schedule links is where i post links to things because the youtube chat is too ephemeral so simon's simon's diagram and then code uh um playing uh let me just actually put yeah code playing around with pursue prediction uh distance so that was [Music] um oh no this is this is uh julia julio's sorry my watch is calling me uh where is this here we go uh so i'll post this here so people can find it and um this is uh let me go back here this is um [Music] amazing law of sines version okay so those are all there for you in the discord in the live uh in the links channel under the live category uh please come and say hi there all right now what's next so i want to do um i want to eva where was that one evade wait no well i don't remember where the comment is stop calling me um turn on my do not disturb do not disturb on okay um where was the comment about the target uh ah there here we go okay so i'm gonna come back to this why doesn't he have the target evade the pursuer ah that's my reaction upon reading this comment why why didn't i do that why didn't i do that such a good idea let's do that okay so is this the oh this is uh the amazing version well do i dare no this is my verb this is not the amazing version i'll use my crappy version and then i should do it with and i gotta um i'm blocking the code here um i'll do it with my version i should really do it with julia julio's because that would be cool to see um but let's let's just leave it at at this so um all right so i've got a pursuer and i've got a target and just for where is the target class vehicle oh no they're both i didn't use i thought this was where i used um okay i need to go to a vape oh i gotta fix it i'm i'm all turned around uh let's go to uh this page pursue and let's look at evade evade so this is true for both flea and evade oh boy so evade its desired velocity is to move away from the it's future location yeah i don't know oh boy oh this is freaking me out here um i think mine is more realistic yeah uh evading evasion um hi dracula dracula is here i'm a little bit terrified to be honest dracula has a check mark which i read as this is the verified real life dracula in the chat right now [Music] uh let's start with flea i'll be working on wander when i come back for my break flea corrected [Music] so this is flea but [Music] okay so where's fleet i you know i'm realizing why i did this because it was so nice and easy and why is there like a big what's this qr code oh that's like because i had i forgot about my life by polls oh no i'm so disorganized i really do a terrible job at this it's the worst um all right please please please please please please please go away okay uh what's the font size here it looks a little small i guess it'll be fine so you can see here my motivation for doing it this way because i was able to just call seek and multiply it by negative one and now i think what i want to do is the following i'm going to do it the same way i it you haven't seen this yet because i haven't published it but i'm going to use a technique that i implemented with the arrive behavior so i'm going to add a particular a second optional argument with a default value of false so this is the desired velocity the the vector that points between the target and the position at maximum speed if flee force multiply negative one so and and if i'm calling it force the whole way through because that's ultimately what it is but at this moment it's the desired velocity and then i subtract the velocity because i'm trying to use fewer vectors um i think i cover this in the videos and then flee is just return seek the target true so this is now very simple correction but because i want to reuse the seek the seek function and i'm i reuse the seek function for when i do arrive what if i were to do what if i were to do this oh no whoops because i'm realizing when i do arrive i have a second modification hmm right and harry points out which is exactly what i'm trying to emphasize here it depends on what you're going for but i i'm right now i'm trying to think of what's the clearest and least prone to error way i probably should have some kind of like constant and innumerable or something like that that's a coding thing right but we can see here you know it's just obviously moving away from the target in a more extreme way okay great so that fixed that that's flixing fixing flea i don't think julio would mind let's go to i want to see it with this creative version i already um sorry i already have a copy of it so let me open that up this is the pursue um oh maybe i didn't maybe i didn't actually save a copy of it oh and right there in the title it says rule of signs so i know why i couldn't uh see that um oh simon has a really interesting idea why what if you make modification of function itself so i could pass in a function to calculate the desired velocity i do like that so i'm going to um i'm gonna maybe revisit that later because i want to just finish this off okay so now what i'm looking at doing is the target um is there an evade here this is pursue so in theory evade and i'm just going to totally copy paste it evade would be hmm maybe i've bit off more than i can chew here um where is the oh because it's seeking the target all right i gotta look at i gotta look at reynolds paper here please evasion pursuit is a moving character requires a prediction of the target's future position the approach here let me make it so you can see everything i'm reading a linear velocity-based predictor corresponds to the assumption that the quarry will not turn during the prediction interval t units of time in the future scaling velocity by t and adding that offset ideally t would be time until interception but that value is unknowable because the quarry can make arbitrary maneuvers to t should be assumed to be a constant which while naive would produce better pursuit than simple seek for reason whereas t should be larger when the pursuit is far from the choir all this is written in here by the way problem is like i didn't re-read the paper when re-recording these videos which is clearly a mistake here a more sophisticated estimator can be obtained by taking into account the relative headings so this is what julio did um and now evasion is analogous to pursuit except that flea is used to steer away from the predicted future position of the target character optimal techniques for pursuit and invasion exists in the field of control theory it's a reference to another paper versions here are intended to be lightweight and none excuse me non-optimal awesome that's those are my that's my love language lightweight and non-optimal in natural systems evasion is often intentionally non-optimal in order to be unpredictable allowing it to foil predictive pursuit strategies wow there is so much more to this um so i think what i'm going to do oh this actually is no big no biggie because um evade is return seek the target evade and in seek and this should really be a flea i don't like the way i'm doing this at all so let's see here so in theory i now have a a pursue algorithm and a evade algorithm and the only thing difference different is i am reversing the desired velocity not reversing not reversing the final steering behavior itself and so now what have i done here where is canvas then i should be able to go to here and i should be able to see target edges pursuer steering okay then i should be able to say target no target let steering equal target dot evade pursuer target apply force it's called evade force let's call it pursue force i spelled target wrong uh-oh do they immediately like whoa what did i do what happened oh i messed something up what did i do i totally messed up this algorithm wow this is crazy what i did it's kind of interesting i think i'm just going to go back to my own version of it let's go back to my own version um which is evade let me uh correct evade so the correction to flee was uh duplicate evade correction if modification equals flea then force multiply negative one okay so flee is c return this dot seek flee then pursue is pursue the vehicle and evade [Music] um return pursue the vehicle with the with flea so in other words oh and this is this dot pursuit so evade is pursue the vehicle but passing in flea so that when it returns seek it does the the the flea modification and flea is just doing seek with the flea modification so then um yeah so then i should be able to say why is there an error here or a warning duplicate method evade because where did i put evade oh right so instead of doing this this is my corrected evade and let's see what happens here if i run the sketch it's evading it so that's right so pursuer evade but i want pursuer to pursue okay so this is now my unsophisticated pursuer pursuing the target and what i want now is for my target to evade the pursuer why isn't the target moving around oh you know what no oh oh oh of course let evasion target dot apply force i forgot that it doesn't apply the force there we go there we go now it's actually trying to evade it there i love this [Laughter] weird okay wait a sec that was very strange that was very strange oh because of the wrap around because of the wrap around that's why i get into this weird oscillation thing maybe what to make this look better and apologies for my sort of like screen layout here which is all wonky maybe to make this look better i should have the oh the vehicle has a maximum speed of 10. and let's make it a max let's make the vehicle the let's set the maximum speed to 5 for the target yeah so the target is much slower the wrap around is really a problem what if i have them both do the edges thing maybe that'll make it less weird yeah this is kind of this is kind of cool so i i wanted to get rid of the um the debugging because it's kind of distracting it looks interesting but it is distracting and then i also would like them both to be triangles where'd they go so let's see if i can make this full screen oh is it not the um hold on this is i i'm not this is this is where i'm going to stop uh window with window height i would really like to see them as different colors though so um can i do this no this is not going to work because it says the fill there oh yeah i don't know why it did this but it works somehow one's green one's pink i don't fully understand why but i won't question it okay now almost ready to go to a break here uh file share full screen it's still doing that wonky edges thing that there we go finally seeing something kind of interesting so what's a better way of doing this without the um without the edges i guess what i should do is put an edge force so they have to turn around instead of rapping drunk paper airplanes um so i i i really kind of running out of time here i'm way over where i meant to be so i but i would love you let me post a link to this uh particular example um we exit full screen um and um let me paste this into the discord links so what i think would really really improve this um which i would suggest as an exercise to the viewer would be to have a force from the walls that keeps them within the space so instead of being able to like leave and disappear on the other side it has to figure out how to like turn around and go back on and then that might um actually like feel like we have a much more yeah the uh and then simon points out that the answer to this would be containment so uh let's take a look at containment uh this is um we can take a look at reynolds this was where is it why oh there we go um is it called containment here yeah containment.html containment.html let's see what happens here right so this is a really cool steering behaviors that keeps um vehicles contained uh within a space so this is one that i definitely need to do and then if i made the borders uh walls that they were contained in uh adding that to this would be the ultimate uh make a mental note somebody write that down remind me future live stream uh sunny uh go back to work appreciate the nice comment in the chat um i am going to take a minute now to thank today's uh sponsor which is brilliant all right i have some exciting uh information to report about brilliant which is brand new and um you know i have talked a lot many a time about brilliant and about how it helps you to learn uh stem so and the thing that i really try to emphasize which is different about brilliant from what i do on the coding train is the fact that it is try it yourself interactive lessons and uh brilliance is always sending me updates about what they're doing with their platform things that they've expanded new courses that they've updated and their update right over here talks about how interact interactivity is taken to a whole new level so i'm going to show you a clip right now of one of their interactive lessons that is about the pythagorean theorem so you might remember um from any of my videos what the formula for the pythagorean theorem is but the idea of this lesson is that by moving around triangles and actually proving that a squared plus b squared is equal to c squared um just through the interactivity of the lessons and your own manipulation stuff so um brilliant it's a website an app it's active problem solving real time um jump right into solving problems coach bit by bit and you know before you know it you're going to have learned something totally new so the other course that i really want to emphasize and show you is their algorithmic fundamentals course so look at that does that not look like code to you right so you don't need any coding experience but if you want to learn about algorithms the fundamentals of different algorithms all the types of things that i talk about in various coding challenges and videos with being able to sort of think through pseudocode and puzzle through it with interactive lessons um this is absolutely the course for you so um you can if i come back to myself here you can let's actually just go look at um i think if i go to brilliant hopefully i'll be signed in and i can go to courses and i want to go to algorithmic fundamentals um is that the one that it's called let me just look at my notes here about their course new courses pre-algebra course is another one algorithm oh computer science algorithms um is the link to it so i think it is this one that's computer science essentials i'm gonna go to computer science algorithms here it is this is not one that i've gone through yet but i'm going to hit start course and let's look i just want to see a little bit of this so about learning algo so let me move this over a little bit uh minimize uh this let's let's kind of go through the first lesson uh pseudocode um you're thinking about algorithms uh prepare some food traveling out of town instructions for your hamster sitter i could relate to this i actually had to leave instructions for our cat sitter recently no hamster um check the hamster's food bowl um look at this um all right there are four pellets in the bowl i didn't even look at the instructions check the hamster's food bowl if the food bowl is empty put five pellets in the bowl otherwise if the bowl does have some leftover food in it put three belt pellets in the pool okay there are four pellets in the pool after your cinder falls instructions you gave them and before the hamsters have a chance to nibble on anything uh they saw an empty bowl right no we can't conclude anything because they could have had an empty bowl put five in in the hamster eight one or there was some leftover food i can't conclude incorrect when the pet sitter is done the number of pellets in the bowl can be expressed as the number of pellets in the bowl and the sitter arrived and the number of pellets added to the bowl due to the instructions you can use the letter n by the way this is like the kind of problem i'm trying to help my kids with that are mad i'm working panicking doing this live i got it wrong which i i want to say i did on purpose even though i didn't but the idea is to get the stuff wrong and puzzle through it and that's the best way to learn you can use the letter n to represent the number of pellets in the bowl if n is zero there will be exactly five if n is positive there will be three plus n pellets so if there were four n is one four pellets of n is one that means the hamsters left one pellet in the ball from the night before so three more ever added that makes total sense uh okay so you can get the idea of what it is like to do these lessons um and uh you know again um just to see how they're interactive and you can start to manipulate the different elements and move them around it's really wonderful you can sign up for free at brilliant.org codingtrain i'm going to take just like a literal two-minute break because i only have 15 minutes left and i want to talk about wander so i'm going to come back and i'm going to show you the wander example and talk through it a little bit but i'm going to take a two-minute break if you have nothing else to do in the two minutes go to brilliant.org and slash coding train it's a way of supporting the coding train channel by signing up for free and then of course if you're interested in unlocking all the premium content uh the first 200 people do so will get a 20 discount i'm gonna take a two minute break to grab some water i'll be back to demonstrate the wander steering behavior in about two minutes and finish off for today see you in a [Music] moment [Music] [Music] so [Music] do [Music] [Music] do [Music] do [Music] all right everybody i took a very short break uh it is 1 42 i have to be done at 2 p.m which is about 20 minutes from now i am off to take the kids to see black widow this afternoon it is not raining outside if we can even get to the park uh the weather has broken for the day and the weekend is coming so um what is uh next in terms of like what i have time for today so what i did yesterday um and thank you again to brilliant for being the sponsor of today's coding trade what i did um yesterday so one of the benefits of signing up for a um the join button on youtube for a coding train is when i record the tutorial videos i will um kind of simulcast them to members who want to sort of like put it on in the background because it takes me a long time to repeat stuff and figure stuff out so if you want to uh get a peek into that um you can and what i did i did one of those sessions yesterday and i recorded a video tutorial about the wander steering behavior and so i'm showing to you up here in the right again this is the original java applet of craig reynolds um wander behavior it's quite a strange one i talk about this in the video but one of the things that i love about it is it really does emphasize the sort of creative thinking of these kinds of steering behaviors like this is such a made up weird system but it works quite well right the idea of wandering is to have random motion but to not have twitchy motion where you're just changing directions all the time but to sort of stay moving in one direction for a while and then move in the other direction and the way that reynolds accomplishes this by is by fixing um essentially the steering force to the um a perimeter of a circle projected out in front of the vehicle so you can see here in the diagram um this is the steering force in red and the steering force changes here and there but tends to if it's if it's fixed to this circular path it'll move to the left for a while and you get these kind of nice wandering um paths and you can see here in my implementation which i will start it over and let me actually give it a slightly i just want to be able to be able to see all the code and everything so let's just make this 600 by 600 and i think yeah there we go so you can see here this is my wandering vehicle so the nice thing about this algorithm is this is good for um scenarios and i'll go back to reynold's paper here oops if you think of something like forage so imagine you want to have a creature wandering a space but if it gets near and sort of smells a bit of food it will then seek that food and eat it and then go back to wandering so you can use kind of wandering i think in different simulations as kind of like a default behavior that a particular agent will always go back to so you can see this is the implementation i go through this whole thing in the video which will hopefully be published uh eventually in the next week or two um you might also be thinking um that another way to implement water would be to use perlin noise so again these are made-up uh techniques uh i'm encouraging people to invent their own algorithm for wandering and submit it which you'll be able to do once i publish the video but i did do something in my wander which is slightly different from reynolds technique and i'm going to point that out here it's uh this so this is this if this here if this here is the point this i'll call it the sort of wander point the steering point the point to which the steering force is calculated what i do is i look at this angle call this angle theta i move this point by a random angular displacement to the counterclockwise or clockwise and we can see this in the code and boy there's no way i'm going to be able to get this done in 15 minutes but we can see this code we can see this in the code right here whoops thank you very much for showing me my notifications that i don't want to see um right displace range is 0.3 i change that wander angle by some random amount so and let's put all the debugging information back in and oh wait hold on i'm going to duplicate this wander variation i'll just call it for right now i want to put the debugging information back in so you can see that and obviously there would be a nice a more elegant way to have a separate debug draw function or something instead of just commenting it in and out and we can see there that's all the debug information you can see how that point to which it's steering is moving through random displacement so i personally feel that um this is pretty much the same like like my admittedly my mistake in not following flee precisely was quite a significant error this are significant difference i shouldn't say error because there's different ways to approach it this to me and i think i should also just to um work this out um let's not draw the path um that by implementing it closer to how reynolds describes it will make a less significant difference but let's do that nonetheless so what's different about it so reynolds writes that the random displacement is not is a vector displacement uh constrained um steering force the sum is constrained to the surface's sphere yeah so this here i if i'm going to move this point instead of by a fixed angle i'm going to move it by any displace it to any point away at a fixed radial distance and then if i move it to here i will constrain it back to the surface he says sphere because you could do this in 3d that's actually one of the things i wanted to accomplish today was to try to make a 3d version of this clearly i do not have time for that next live stream or whenever i have some time um so i think what i want to do maybe this is not that interesting to look at in today's live stream but we've got 10 minutes left let's see how far i get i think what i want to do is instead of keeping track of this wander theta i want to keep track of the wander point and the wander point is going to be a vector and i'm just going to initialize it at zero and you know i call something wanderpoint here so i'm a little bit i feel like i need i mean it's actually fine because this is the lo but that'll be so confusing let's call this well let's call this force this is actually going to be the force all along so i'm going to change all of this this is a little bit awkward what i'm doing but i think it's going to make sense um force force force right and now actually force force okay what am i missing now v wander point is not defined where did i forget to replace it ah here force force where else uh vehicle wander ah there we go force there we go okay so i'm back to what i had before however i don't want to have this idea of an angle um i just wanna well i'm just gonna make this zero for right now okay so if it's zero it's always moving forward so the wander point i guess i need an initial wander point this is weird this dot wander point equals all right so i need uh this is yeah there's some hard-coded stuff in here like this 150 so i think i need these to be this is uh wander distance is 100 and this wander a radius is 50. so this should be this wonder distance and this should be this wonder radius uh this wonder radius this wonder radius okay i just want to get what i had before um so now this is a little bit weird what i'm doing especially because i haven't explained the full water algorithm so apologies for those of you that the video is not out yet so thank you for tuning in and kind of following this part along uh probably just trying to do it in 3d would have been the more interesting choice for my last eight minutes here but let's see i'm gonna plow forward here so the wander point should actually be uh a vector that's um uh equal to p5 vector this dot position i'm just its initial wander point is i'm adding its position oh no okay sorry the wander point let's make a copy of the velocity right it has an initial velocity normalize it and set its magnitude okay or no and set its magnitude to the wander distance and the wander radius right so the initial wander point and then this dot wonder point add its position so i just want to start the initial wander point at that green dot okay so and in that sense i don't need to figure out where it is like what if i just said for a moment force equals wander point copy this dot wander point copy because i'm starting no oh it's not um because it has to be relative it's relative to the oh this is harder than i thought but i like where i'm starting here which is that the wander point the first time is like if i just do no loop and if i take why why why is there an error here force was used before oh oh oh let me draw the debug stuff okay that's right but i'm missing the one more circle which is fine which is this one [Music] um okay there we go oh no no no the wander point is oh this is by the way i should just warn everybody this is a failure i'm not gonna be able to finish this right now and i don't even know if the way that i started this the thing is i'm trying to start with the point rather than an angle and i'm realizing that the um i missed an interim step here which is fine i really like the way that i did it it's so much easier to deal with the angle this is like a crazy thing that i'm doing here because i'm going to have to think through i don't i don't think starting with i i guess i could go with the angle then offset the point i could probably use like a gaussian distribution of changing an angular offset i think the way that i did it is just a frankly a better way of doing it somebody should prove me wrong here let's try this in 3d [Laughter] i have two minutes left let me answer your questions uh okay i'm gonna have to so i would love i would love for somebody to help contribute to this uh this is the end of the stream i obviously didn't get very far with this um trying to think of what else is coming i could use rotate to rotate it oh that's a really smart point but i don't really need to i need i need a pencil and paper here because what i need to do and um i should read some random numbers but is maybe i can i don't have my diagram i gotta go set up my new studio okay i'm gonna i'm gonna work it i'm gonna uh uh uh uh uh uh okay great i've got a great question so i'm gonna investigate this some more um the video will come out you will think about it i'll paste this into the discord because i clearly went off the rails here but if you want to start to wander variation i'll put this here into the discord maria asked a wonderful question which is hey what is a gaussian distribution i've heard it on sound design but not in animation so um good news for you um a gaussian are often referred to as normal distribution i do have a video about this let's see what happens if i search for it um it's a pretty old one from 2015 where i do go through interesting how it has like time codes i don't believe i've gone back and time-coded these so these are like automated you could look at this video but better yet i think if i go to natureofcode.com and go to the introduction um we can see here the idea of a gaussian distribution of random numbers is is not a um so boy it's been a long two hours i don't know about you but i'm exhausted and my brain is melting but i'm going to demonstrate it this way uh good news for myself is that i'm pretty sure i have oh yeah a nice so if i were this is a great visual demonstration if i were to pick a random x position every frame just using random the random function between zero and the width of a canvas i would see an even distribution i would be just as likely to pick zero as i would be likely to pick with as width divided by two as 25 as 50. this is not how numbers usually appear distributed and things you find in nature for you know human being heights are a good you know sort of like classic example of this you know there's a average height of all humans and most mo if you pick a random human from a room of humans most people will their height will be near that average or near that mean and there will be fewer outliers that's a normal or gaussian distribution it's often graphed as a bell curve so if there is um if almost everybody is the same height you can see there's a very big peak graphing that distribution you could have a wider distribution as with more outliers and um in p5 i believe um if i were to just do exactly what i just said um like if i were to say let x equals random with uh circle x 200 100 or uh 20 fill 255 10. um we would see here and let's make this 50. we would see here that i'm filling up evenly picking random numbers um it would be great for me to actually like pile them and we'd see these piles piling up evenly because if i then did it with a gaussian distribution we would see the pile up happening in the middle but i can change that by saying let x equal random i believe this is built into p5 i can give it a a mean which is width divided by two so that is now the average you could see like all of the numbers are basically right around the average like in theory any number could be picked and eventually given infinite time we would fill up some of the outliers but what we're looking for is what is the standard deviation what is on average how far things deviate from the mean and if i do a standard deviation of like 50 now we're going to start to see that there is a bit more of a spread but still that cluster is mostly around the mean so here's like a standard deviation of 10. and again this isn't the best visual i would encourage you to um think about how you might visually demonstrate this drawing a bell curve would be the sort of classic way of doing it uh paint splatter is a kind of example that i often give could you use this to create a plate scatter and carlavan is saying don't forget the kids i definitely have to go i'm going to put on my goodbye song turn the volume down a little bit see if there's any more questions this is the end of today's live stream and profit says why did i think you're moving to the east coast for your sabbatical so first of all i already live on the east coast i talked about this more during the beginning of the live stream maybe that's where you are um i will i will answer all your questions about my moving plans discord uh everybody join the discord uh don't forget um big thank you to today's sponsor brilliant you can sign up for free at brilliant.org codingtrain or to uh get a 20 discount if you want to unlock all of their courses and premium content um what else do i want to say um stay tuned so more videos are coming out there are one two three four five videos that i've recorded that are yet to be published on the channel so stuff is coming out in the next month i would be surprised if there was another live stream before august but if i can get moved get a new studio set up i'll definitely be doing some test streams for members so if you were thinking about joining now could be a time to do that um i uh hopefully i'll be back in full full steam full force in august um interesting maria talking about a bell curve over eqs um that's great thank you for this feedback that's wonderful to hear about uh rainbow skeppy is telling me that i don't need semicolons in javascript this is absolutely true i am amongst my many flaws as a human one of my i just i am a semicolons person i can't give it up ah august 20th the weekend of august 20th 20th anniversary of processing java i'm gonna do something special on the coding train that weekend stay tuned we'll see what that is i really appreciate all of your comments and uh sharing of the videos and i love it when people tell me about what they're watching and making on twitter uh please join the discord um comment in the discord come back i'm trying to reach a certain threshold where i can get discord partnership but i need to retain membership so stay tuned there's uh the discord moderation team is running some events and things here um adrian also likes semicolons thank you adrian we were one and the same but you know i no judge this is a judgment-free zone semi-colons no semicolons some semicolons some no semicolons all is welcome a lot of the coding train thanks everybody see you probably not until august but sign up for that notifications roll i will keep you all updated and posted on my schedule um and i hope to be back with you soon all right goodbye everybody always i always forget that this stop this stop it i'm gonna do this stop this stop i'm gonna do this this stop this stop get stuck i'm gonna do this stop i'm gonna stop this stop [Music] [Music] this dot [Music] never forget this dot somebody could [Music] i'm gonna say once again here [Music] song [Music] autotune and the internet will fix that for me see it with me it's the polaroid song [Music] it's [Music] unicorns and rainbows and cupcakes what else is there yes kittens thank you very much kittens and rainbows and cupcakes notice that look what i get i'm really losing my mind okay let's do [Music] it [Music] the kittens kittens and kittens and kids the kids [Music] [Music] i feel just sort of like a nice feeling of relaxation everything's gonna be okay today dream is not broken it has not frozen this is a this is a wonderful thing okay we're gonna do it i'm really getting to something i need my sound effect [Music] what else is there unicorns and rainbows and cupcakes that was invalid syntax i forgot uh there was one other thing here that i think is important that i will use continuously over and over again all sorts of text generation analysis things that i will use continuously over and over again first thing i need to do is yes [Music] and kittens kittens and kittens and kittens and kittens [Music] goodbye attic studio it was nice being here next time i'm back here i don't know i might come back here again we'll see bye everybody thanks for tuning in you
Info
Channel: The Coding Train
Views: 11,835
Rating: undefined out of 5
Keywords:
Id: zC8GcS6-kNQ
Channel Id: undefined
Length: 124min 15sec (7455 seconds)
Published: Fri Jul 09 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.