title
Random Walker in p5.js (Coding Challenge 52)

description
In this coding challenge, I simulate a "random walk" with the p5.js library. This video is part of the course Nature of Code at ITP, Tisch, NYU. Code: https://thecodingtrain.com/challenges/52-random-walker πŸ•ΉοΈ p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/sketches/N-qqe1ExZ πŸŽ₯ Previous video: https://youtu.be/aKYlikFAV4k?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH πŸŽ₯ Next video: https://youtu.be/bqF9w9TTfeo?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH πŸŽ₯ All videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH References: πŸšΆπŸ½β€β™€οΈ Random walk Wikipedia article: https://en.wikipedia.org/wiki/Random_walk 5️⃣ random Function Reference Page: https://p5js.org/reference/#/p5/random 5️⃣ floor Function Reference Page: https://p5js.org/reference/#/p5/floor πŸ“• The Nature of Code GitHub (Spring 2017): https://github.com/nature-of-code/NOC-S17-1-Physics-Animation Live Stream Archive: πŸ”΄ Live Stream #73: https://youtu.be/RDULjRLn3pk Related Coding Challenges: πŸš‚ #53 Random Walker with Vectors and LΓ©vy Flight: https://youtu.be/bqF9w9TTfeo πŸš‚ #162 Self Avoiding Walk: https://youtu.be/m6-cm6GZ1iw Timestamps: 0:00 Introduction to the Random Walker Coding Challenge 1:56 Whiteboard explanation of a random walk 6:48 Into the code...drawing a point! 7:30 Picking a random number between 0 and 4 using p5.js's 'random' and 'floor' functions 9:58 Setting up the code to use the random number 12:26 First run! The point...it wibbles...it wobbles 12:48 Stop clearing the background every frame so that we can see the point's path 13:10 Discussion of the possibilities of the random walker Editing by Mathieu Blanchette Animations by Jason Heglund Music from Epidemic Sound πŸš‚ Website: http://thecodingtrain.com/ πŸ‘Ύ Share Your Creation! https://thecodingtrain.com/guides/passenger-showcase-guide 🚩 Suggest Topics: https://github.com/CodingTrain/Suggestion-Box πŸ’‘ GitHub: https://github.com/CodingTrain πŸ’¬ Discord: https://discord.gg/hPuGy2g πŸ’– Membership: http://youtube.com/thecodingtrain/join πŸ›’ Store: https://standard.tv/codingtrain πŸ–‹οΈ Twitter: https://twitter.com/thecodingtrain πŸ“Έ Instagram: https://www.instagram.com/the.coding.train/ πŸŽ₯ Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH πŸŽ₯ Intro to Programming: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA πŸ”— p5.js: https://p5js.org πŸ”— p5.js Web Editor: https://editor.p5js.org/ πŸ”— Processing: https://processing.org πŸ“„ Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecodingtrain.com/issues/new #random #floor #randomwalker #p5js #javascript #processing #java

detail
{'title': 'Random Walker in p5.js (Coding Challenge 52)', 'heatmap': [{'end': 448.805, 'start': 425.854, 'weight': 0.737}, {'end': 758.702, 'start': 732.181, 'weight': 0.782}, {'end': 797.829, 'start': 758.982, 'weight': 0.709}], 'summary': 'Presents a coding challenge on random walk visualization, explaining the concept in 2d space and pseudo-random number generation. it explores creating a random walker in p5.js, using the floor function, and javascript switch statement, showcasing potential applications in art, music, and computer graphics.', 'chapters': [{'end': 290.006, 'segs': [{'end': 48.231, 'src': 'embed', 'start': 22.988, 'weight': 0, 'content': [{'end': 28.051, 'text': "But what I'm going to do periodically is do some coding challenges that fit with the material for that course week to week.", 'start': 22.988, 'duration': 5.063}, {'end': 31.174, 'text': "And what I'm going to start with today is this thing called a random walk.", 'start': 28.111, 'duration': 3.063}, {'end': 35.398, 'text': "What is a random walk? I'm going to diagram it for you on the whiteboard in a moment.", 'start': 31.554, 'duration': 3.844}, {'end': 40.763, 'text': 'But ultimately, a random walk, as you can see here, is visualized as this thing that moves around randomly.', 'start': 35.618, 'duration': 5.145}, {'end': 41.945, 'text': "It's a random walk.", 'start': 41.244, 'duration': 0.701}, {'end': 48.231, 'text': "And so I actually already have the program running here that I made in the coding challenge because I'm recording this after it.", 'start': 42.225, 'duration': 6.006}], 'summary': 'Periodic coding challenges aligned with course material, starting with random walk concept.', 'duration': 25.243, 'max_score': 22.988, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY22988.jpg'}, {'end': 98.49, 'src': 'embed', 'start': 58.917, 'weight': 1, 'content': [{'end': 63.839, 'text': 'A little dot moving around the screen, every frame of animation picking a random direction to move.', 'start': 58.917, 'duration': 4.922}, {'end': 65.299, 'text': 'From there.', 'start': 64.739, 'duration': 0.56}, {'end': 68.601, 'text': "it's up to you to do something more creative with this, to think about this.", 'start': 65.299, 'duration': 3.302}, {'end': 72.762, 'text': 'what kinds of behaviors and ideas from nature or the world can you simulate with this?', 'start': 68.601, 'duration': 4.161}, {'end': 74.723, 'text': 'What types of visual outcomes can you get with this?', 'start': 73.002, 'duration': 1.721}, {'end': 78.224, 'text': "At the end of the video, I'll give you some context and ideas about that.", 'start': 74.943, 'duration': 3.281}, {'end': 83.048, 'text': 'And this is just the first in a series of short experiments about random walks.', 'start': 78.564, 'duration': 4.484}, {'end': 89.794, 'text': "And I'll do some variations on it in terms of moving this from 2D to 3D, thinking about the step size, thinking about vectors,", 'start': 83.148, 'duration': 6.646}, {'end': 90.815, 'text': 'object-oriented programming.', 'start': 89.794, 'duration': 1.021}, {'end': 98.49, 'text': "But this video is going to be the most basic, simple drop I don't, drop, drop singing.", 'start': 91.015, 'duration': 7.475}], 'summary': 'Experimenting with random walks for creative visual outcomes.', 'duration': 39.573, 'max_score': 58.917, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY58917.jpg'}, {'end': 163.908, 'src': 'embed', 'start': 141.576, 'weight': 2, 'content': [{'end': 150.301, 'text': 'And this is the kind of thing that can be used to model the way an animal forges for food or the stock price fluctuates, perhaps,', 'start': 141.576, 'duration': 8.725}, {'end': 153.983, 'text': 'or kind of way a gambler makes decisions playing blackjack.', 'start': 150.301, 'duration': 3.682}, {'end': 160.106, 'text': 'There are a lot of processes by which this idea of a random walk and a random walk could be in one dimension or two dimensions,', 'start': 154.003, 'duration': 6.103}, {'end': 163.908, 'text': 'or three dimensions are used in various kinds of scientific simulations.', 'start': 160.106, 'duration': 3.802}], 'summary': 'Random walk is used in scientific simulations for modeling animal foraging, stock price fluctuation, and gambler decision-making.', 'duration': 22.332, 'max_score': 141.576, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY141576.jpg'}, {'end': 272.173, 'src': 'embed', 'start': 251.245, 'weight': 4, 'content': [{'end': 260.468, 'text': "meaning there's a mathematical formula that's operating behind the scenes that generates a sequence of numbers that, when looked at over time,", 'start': 251.245, 'duration': 9.223}, {'end': 262.649, 'text': 'have an essentially random probability.', 'start': 260.468, 'duration': 2.181}, {'end': 267.091, 'text': "Now, these are pseudo-random because it's not like we're actually measuring it.", 'start': 262.989, 'duration': 4.102}, {'end': 272.173, 'text': 'And incidentally, a random walk is also related to measuring movements of particles moving around in a gas.', 'start': 267.171, 'duration': 5.002}], 'summary': 'Mathematical formula generates a pseudo-random sequence of numbers related to particles in a gas.', 'duration': 20.928, 'max_score': 251.245, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY251245.jpg'}], 'start': 3.272, 'title': 'Random walk and its visualization', 'summary': 'Introduces a coding challenge on random walk with a focus on visualizing a simple random walk, encouraging creative exploration. it also explains the concept of random walk in 2d space, used to model phenomena such as animal foraging and stock price fluctuation, and discusses the generation of pseudo-random numbers for this purpose.', 'chapters': [{'end': 121.235, 'start': 3.272, 'title': 'Coding challenge: random walk', 'summary': 'Introduces a coding challenge on random walk as part of the nature of code course, with a focus on visualizing a simple random walk and encouraging creative exploration, with plans for future variations and experiments.', 'duration': 117.963, 'highlights': ['The coding challenge is part of the spring 2017 Nature of Code course at New York University, with most materials available online through videos.', 'The challenge introduces the concept of a random walk and visualizes it as a movement that occurs randomly, with a basic program demonstrating a simple random walk.', 'The chapter encourages creative exploration by prompting viewers to think about simulating behaviors and ideas from nature or the world using random walks and to consider various visual outcomes.', 'The presenter plans to expand the challenge by exploring variations such as moving from 2D to 3D, adjusting step size, and incorporating vectors and object-oriented programming.', 'The coding challenge is intended to serve as the first in a series of short experiments about random walks, with the presenter seeking creative outcomes and feedback from the audience.']}, {'end': 290.006, 'start': 121.475, 'title': 'Understanding random walk in 2d space', 'summary': 'Explains the concept of random walk as a stochastic process used to model various phenomena such as animal foraging, stock price fluctuation, and scientific simulations, and discusses the generation of pseudo-random numbers for this purpose.', 'duration': 168.531, 'highlights': ['Random walk is a stochastic process used to model various phenomena such as animal foraging, stock price fluctuation, and scientific simulations. The random walk is used to model the way an animal forges for food, stock price fluctuation, and various scientific simulations.', 'Computers can produce pseudo-random numbers using a mathematical formula, which have an essentially random probability over time. Computers can produce pseudo-random numbers using a mathematical formula, with an essentially random probability over time.', 'Random walk is related to measuring movements of particles moving around in a gas. Random walk is related to measuring movements of particles moving around in a gas.']}], 'duration': 286.734, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY3272.jpg', 'highlights': ['The coding challenge introduces the concept of a random walk and visualizes it as a movement that occurs randomly, with a basic program demonstrating a simple random walk.', 'The chapter encourages creative exploration by prompting viewers to think about simulating behaviors and ideas from nature or the world using random walks and to consider various visual outcomes.', 'Random walk is a stochastic process used to model various phenomena such as animal foraging, stock price fluctuation, and scientific simulations.', 'The presenter plans to expand the challenge by exploring variations such as moving from 2D to 3D, adjusting step size, and incorporating vectors and object-oriented programming.', 'Computers can produce pseudo-random numbers using a mathematical formula, which have an essentially random probability over time.']}, {'end': 512.489, 'segs': [{'end': 320.054, 'src': 'embed', 'start': 290.006, 'weight': 1, 'content': [{'end': 296.751, 'text': 'random numbers themselves is something that lots of people study a lifetime of study or write PhD dissertations about getting a really good random number generator.', 'start': 290.006, 'duration': 6.745}, {'end': 305.959, 'text': 'The way that I can get random numbers with this pseudo random number generator is with function in p5 called random,', 'start': 297.132, 'duration': 8.827}, {'end': 312.967, 'text': 'and the key thing about this function is well, first of all, it takes a minimum and a maximum as arguments.', 'start': 305.959, 'duration': 7.008}, {'end': 320.054, 'text': 'so I want to get random numbers between 4 and 10 or 0 and 5, or negative 5 and positive 5.', 'start': 312.967, 'duration': 7.087}], 'summary': 'Using the p5 random function to generate random numbers within specified ranges.', 'duration': 30.048, 'max_score': 290.006, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY290006.jpg'}, {'end': 359.72, 'src': 'embed', 'start': 333.066, 'weight': 0, 'content': [{'end': 341.333, 'text': 'And one thing I really want to look at as part of this little series about random walks is what happens when I want a different distribution.', 'start': 333.066, 'duration': 8.267}, {'end': 344.897, 'text': 'What if I want to move down more often than I want to move up?', 'start': 341.533, 'duration': 3.364}, {'end': 347.139, 'text': 'Or what if I want to move towards the mouse?', 'start': 345.277, 'duration': 1.862}, {'end': 352.505, 'text': 'I want to have a 50% chance of moving towards the mouse and a 50% chance of picking something else random.', 'start': 348.1, 'duration': 4.405}, {'end': 359.72, 'text': 'Or what if I want to have a distribution of random numbers that follows something called the bell curve,', 'start': 352.805, 'duration': 6.915}], 'summary': 'Analyzing random walks with different distributions and probabilities.', 'duration': 26.654, 'max_score': 333.066, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY333066.jpg'}, {'end': 404.55, 'src': 'embed', 'start': 377.37, 'weight': 4, 'content': [{'end': 380.693, 'text': 'And really, my random function is not going to pick 1, 2, 3, or 4.', 'start': 377.37, 'duration': 3.323}, {'end': 384.856, 'text': "I could make it do that, but that's not really how numbers are ever picked on a computer.", 'start': 380.693, 'duration': 4.163}, {'end': 391.682, 'text': "So I'm going to pick 0, 1, 2, or 3 because I'm going to look for a range starting with 0.", 'start': 385.056, 'duration': 6.626}, {'end': 399.348, 'text': "And then whichever one of those I pick, I'm going to adjust the x or the y position and move my random walker around on the screen.", 'start': 391.682, 'duration': 7.666}, {'end': 402.069, 'text': 'OK, so come over here with me.', 'start': 399.648, 'duration': 2.421}, {'end': 404.55, 'text': "Let's take the train over to the computer.", 'start': 402.249, 'duration': 2.301}], 'summary': 'Random function picks from 0-3 to move walker on screen.', 'duration': 27.18, 'max_score': 377.37, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY377370.jpg'}, {'end': 448.805, 'src': 'heatmap', 'start': 425.854, 'weight': 3, 'content': [{'end': 433.198, 'text': "y equals 200, and I am going to, I'm going to just draw a point at x and y.", 'start': 425.854, 'duration': 7.344}, {'end': 439.541, 'text': "I'm going to say stroke 255, and I'm also going to say stroke weight two, just so it's a little bit more visible.", 'start': 433.198, 'duration': 6.343}, {'end': 445.103, 'text': "And if I now refresh the page, we can see, there it is, there's my random walker.", 'start': 440.241, 'duration': 4.862}, {'end': 446.484, 'text': "It hasn't gone anywhere yet.", 'start': 445.223, 'duration': 1.261}, {'end': 448.805, 'text': 'So now I need to pick a random number.', 'start': 446.784, 'duration': 2.021}], 'summary': 'Drawing a point at x and y with y=200, stroke 255, and stroke weight 2.', 'duration': 22.951, 'max_score': 425.854, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY425854.jpg'}], 'start': 290.006, 'title': 'Random number generation and p5', 'summary': 'Delves into random number generation using pseudo random number generator and explores uniform distribution, bell curve, and gaussian distribution along with creating a random walker in p5.js with each step as a random number between 0 and 4.', 'chapters': [{'end': 424.758, 'start': 290.006, 'title': 'Understanding random number generation', 'summary': 'Discusses the generation of random numbers using a pseudo random number generator, exploring the uniform distribution, and the potential for different distributions, including the bell curve and gaussian distribution, in the context of random walks.', 'duration': 134.752, 'highlights': ["The function 'random' in p5 generates random numbers with a uniform distribution, ensuring each number has an equal likelihood of being picked.", 'Exploring the possibility of different distributions for random numbers, such as moving down more often, moving towards the mouse with a 50% chance, and following a bell curve or Gaussian distribution.', 'Implementing a non-object-oriented program to adjust the x or y position based on randomly picked numbers, with the potential for future addition of objects.', 'Emphasizing the need for a good random number generator, with a focus on the uniform distribution and the potential for non-uniform distributions in the context of random walks.']}, {'end': 512.489, 'start': 425.854, 'title': 'Random walker in p5', 'summary': 'Demonstrates creating a random walker in p5.js, starting at point (x, 200), with each step being a random number between 0 and 4, and discusses the issue with the random function generating decimal numbers up to 3.9999999...', 'duration': 86.635, 'highlights': ['The random walker starts at point (x, 200) and each step is a random number between 0 and 4.', 'The random function in p5 generates decimal numbers up to 3.9999999, causing issues in the intended range.']}], 'duration': 222.483, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY290006.jpg', 'highlights': ['Exploring different distributions for random numbers, such as moving down more often, moving towards the mouse with a 50% chance, and following a bell curve or Gaussian distribution.', "The function 'random' in p5 generates random numbers with a uniform distribution, ensuring each number has an equal likelihood of being picked.", 'Emphasizing the need for a good random number generator, with a focus on the uniform distribution and the potential for non-uniform distributions in the context of random walks.', 'The random walker starts at point (x, 200) and each step is a random number between 0 and 4.', 'Implementing a non-object-oriented program to adjust the x or y position based on randomly picked numbers, with the potential for future addition of objects.']}, {'end': 941.011, 'segs': [{'end': 573.193, 'src': 'embed', 'start': 512.489, 'weight': 2, 'content': [{'end': 515.511, 'text': 'which is I can put this function floor around it.', 'start': 512.489, 'duration': 3.022}, {'end': 520.836, 'text': 'And what the floor function does, there are a bunch of functions that I can use.', 'start': 516.111, 'duration': 4.725}, {'end': 522.577, 'text': "Where's my marker? Here it is.", 'start': 521.356, 'duration': 1.221}, {'end': 523.477, 'text': 'In P5.', 'start': 523.278, 'duration': 0.199}, {'end': 531.782, 'text': 'to take a floating point number like 3.4 and convert it to an integer.', 'start': 525.637, 'duration': 6.145}, {'end': 538.828, 'text': 'If I use the floor function, it will make that number 3.', 'start': 532.403, 'duration': 6.425}, {'end': 544.974, 'text': 'If I use the ceiling function, CEIL, it will make that number four.', 'start': 538.828, 'duration': 6.146}, {'end': 549.921, 'text': 'If I use the round function, it will make that number three.', 'start': 545.574, 'duration': 4.347}, {'end': 554.187, 'text': "So floor, even if it's 3.9999999, just lops off the decimal place and makes it three.", 'start': 550.441, 'duration': 3.746}, {'end': 565.108, 'text': "If ceiling, no matter what it is, whether it's 3.9 or 3.1 or 3.2, goes up to the nearest integer.", 'start': 560.264, 'duration': 4.844}, {'end': 570.631, 'text': 'so floor goes down to the nearest integer, seal goes up to the nearest integer and then round rounds it.', 'start': 565.108, 'duration': 5.523}, {'end': 573.193, 'text': 'So 3.4 becomes three, 3.6 becomes four.', 'start': 570.651, 'duration': 2.542}], 'summary': 'The floor function converts floating point numbers to integers, rounding down to the nearest integer, while the ceiling function rounds up, and the round function rounds to the nearest integer.', 'duration': 60.704, 'max_score': 512.489, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY512489.jpg'}, {'end': 662.011, 'src': 'embed', 'start': 635.583, 'weight': 0, 'content': [{'end': 640.31, 'text': "So I'm going to have to look up this syntax, because I can freely admit that I can never remember this.", 'start': 635.583, 'duration': 4.727}, {'end': 642.894, 'text': 'Case statement JavaScript.', 'start': 640.711, 'duration': 2.183}, {'end': 644.842, 'text': "Let's see where we get.", 'start': 643.962, 'duration': 0.88}, {'end': 647.684, 'text': "Let's go to switch here.", 'start': 645.863, 'duration': 1.821}, {'end': 650.926, 'text': 'So you can see here, this is the statement.', 'start': 647.884, 'duration': 3.042}, {'end': 652.066, 'text': 'This is the syntax.', 'start': 651.146, 'duration': 0.92}, {'end': 654.908, 'text': 'Switch expression.', 'start': 652.446, 'duration': 2.462}, {'end': 658.129, 'text': 'Expression meaning a particular, in this case, a particular variable.', 'start': 655.068, 'duration': 3.061}, {'end': 662.011, 'text': 'The case of when this variable has this value, do this stuff.', 'start': 658.469, 'duration': 3.542}], 'summary': 'Exploring javascript switch statement syntax and functionality.', 'duration': 26.428, 'max_score': 635.583, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY635583.jpg'}, {'end': 766.807, 'src': 'heatmap', 'start': 732.181, 'weight': 0.782, 'content': [{'end': 735.325, 'text': 'And to move up is y equals y minus one.', 'start': 732.181, 'duration': 3.144}, {'end': 742.412, 'text': "Okay, so we now have this switch statement where I'm picking one of these four options.", 'start': 736.646, 'duration': 5.766}, {'end': 743.313, 'text': 'And here we go.', 'start': 742.753, 'duration': 0.56}, {'end': 747.355, 'text': "Let's go back to our code, run it, and look at that.", 'start': 744.673, 'duration': 2.682}, {'end': 748.696, 'text': "There's our random walk.", 'start': 747.675, 'duration': 1.021}, {'end': 757.481, 'text': "Now, interestingly enough, this doesn't look like some of the images I showed you in the intro to this video that I haven't actually made yet,", 'start': 748.916, 'duration': 8.565}, {'end': 758.702, 'text': "because that's going to happen after.", 'start': 757.481, 'duration': 1.221}, {'end': 766.807, 'text': 'What I want to do is I want to see the path of this random walker just in terms of the sort of classic way to visualize the random walk in a 2D space.', 'start': 758.982, 'duration': 7.825}], 'summary': 'Code generates a random walk in 2d space.', 'duration': 34.626, 'max_score': 732.181, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY732181.jpg'}, {'end': 797.829, 'src': 'heatmap', 'start': 758.982, 'weight': 0.709, 'content': [{'end': 766.807, 'text': 'What I want to do is I want to see the path of this random walker just in terms of the sort of classic way to visualize the random walk in a 2D space.', 'start': 758.982, 'duration': 7.825}, {'end': 773.692, 'text': 'And the easiest way I can do that is just take is take the background function and move that into setup.', 'start': 767.088, 'duration': 6.604}, {'end': 784.621, 'text': "So I'm drawing the background just once at the beginning and then I'm drawing the background just once at the beginning so that when the dot moves I'm not erasing the previous dots.", 'start': 773.912, 'duration': 10.709}, {'end': 789.385, 'text': "And now if I do this again, we can see, look at this, there's our random walker.", 'start': 784.801, 'duration': 4.584}, {'end': 797.829, 'text': "So I now propose to you, at the end, I'm going to do a couple more videos with some variations on this theme, but this is a really simple concept.", 'start': 789.685, 'duration': 8.144}], 'summary': 'Visualizing a random walk in 2d space using processing.js', 'duration': 38.847, 'max_score': 758.982, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY758982.jpg'}, {'end': 890.812, 'src': 'embed', 'start': 860.504, 'weight': 1, 'content': [{'end': 862.885, 'text': "I think I said 3D already, so there's a lot of things.", 'start': 860.504, 'duration': 2.381}, {'end': 864.525, 'text': "Oh, and here's the thing that's even more important.", 'start': 862.945, 'duration': 1.58}, {'end': 869.506, 'text': 'This is just a pure visual example of the random walk.', 'start': 864.885, 'duration': 4.621}, {'end': 876.228, 'text': "But what if you don't think about the outcome of the random walk being just a dot moving in a 2D space?", 'start': 870.146, 'duration': 6.082}, {'end': 880.509, 'text': "What if it's a random walk that's actually changing notes in a melody?", 'start': 876.528, 'duration': 3.981}, {'end': 884.31, 'text': 'What if a musical composition or a dance performance?', 'start': 880.809, 'duration': 3.501}, {'end': 890.812, 'text': 'What are some other ways you can take this random walk idea and make it into a project that has some kind of creative expression associated with it?', 'start': 884.59, 'duration': 6.222}], 'summary': 'Exploring the concept of random walk in creative projects.', 'duration': 30.308, 'max_score': 860.504, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY860504.jpg'}], 'start': 512.489, 'title': 'Using floor function, javascript switch statement', 'summary': 'Explains using the floor function to convert floating point numbers to integers in p5, discusses the ceiling and round functions with examples, and introduces the switch statement in javascript as an alternative to if-else statements, demonstrating its use in creating a random walk program with potential creative applications in art, music, and computer graphics.', 'chapters': [{'end': 591.143, 'start': 512.489, 'title': 'Using floor function and understanding rounding', 'summary': 'Explains the use of the floor function to convert floating point numbers to integers in p5, and also discusses the ceiling and round functions with examples. it also mentions the potential use of a switch statement.', 'duration': 78.654, 'highlights': ['The floor function in P5 converts a floating point number like 3.4 to an integer, making it 3, while the ceiling function makes it four.', 'The round function rounds the number to the nearest integer, making 3.4 become three and 3.6 become four.', 'The chapter briefly mentions the potential use of a switch statement, addressing the common query from viewers.', 'The explanation distinguishes between the floor, ceiling, and round functions, providing a clear understanding of their respective behaviors.']}, {'end': 941.011, 'start': 591.263, 'title': 'Javascript switch statement', 'summary': 'Introduces the switch statement in javascript as an alternative to if-else statements, demonstrating how to use it to create a random walk program, while also highlighting potential creative applications of random walk concepts in art, music, and computer graphics.', 'duration': 349.748, 'highlights': ['The chapter introduces the switch statement in JavaScript as an alternative to if-else statements It demonstrates using the switch statement to create a random walk program, providing a practical example of its application.', 'The speaker discusses potential creative applications of random walk concepts in art, music, and computer graphics Examples include creating random walk art, exploring random walks in 2D and 3D, employing random walks in musical composition, dance performances, and computer graphics, as well as experimenting with different variations of random walks such as the Levy Flight and self-avoiding walks.', 'Encouragement for the audience to share their random walk examples The speaker invites the audience to share their random walk examples via Twitter, Slack, or comments, expressing a willingness to showcase community-made random walk projects in future videos.']}], 'duration': 428.522, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/l__fEY1xanY/pics/l__fEY1xanY512489.jpg', 'highlights': ['The chapter introduces the switch statement in JavaScript as an alternative to if-else statements, demonstrating its use in creating a random walk program with potential creative applications in art, music, and computer graphics.', 'The speaker discusses potential creative applications of random walk concepts in art, music, and computer graphics, including creating random walk art, exploring random walks in 2D and 3D, employing random walks in musical composition, dance performances, and computer graphics, as well as experimenting with different variations of random walks such as the Levy Flight and self-avoiding walks.', 'The floor function in P5 converts a floating point number like 3.4 to an integer, making it 3, while the ceiling function makes it four.', 'The round function rounds the number to the nearest integer, making 3.4 become three and 3.6 become four.']}], 'highlights': ['Random walk is a stochastic process used to model various phenomena such as animal foraging, stock price fluctuation, and scientific simulations.', 'The presenter plans to expand the challenge by exploring variations such as moving from 2D to 3D, adjusting step size, and incorporating vectors and object-oriented programming.', 'Computers can produce pseudo-random numbers using a mathematical formula, which have an essentially random probability over time.', 'Exploring different distributions for random numbers, such as moving down more often, moving towards the mouse with a 50% chance, and following a bell curve or Gaussian distribution.', "The function 'random' in p5 generates random numbers with a uniform distribution, ensuring each number has an equal likelihood of being picked.", 'Emphasizing the need for a good random number generator, with a focus on the uniform distribution and the potential for non-uniform distributions in the context of random walks.', 'The chapter introduces the switch statement in JavaScript as an alternative to if-else statements, demonstrating its use in creating a random walk program with potential creative applications in art, music, and computer graphics.', 'The speaker discusses potential creative applications of random walk concepts in art, music, and computer graphics, including creating random walk art, exploring random walks in 2D and 3D, employing random walks in musical composition, dance performances, and computer graphics, as well as experimenting with different variations of random walks such as the Levy Flight and self-avoiding walks.']}