Skip to content

Latest commit

 

History

History
42 lines (19 loc) · 3.24 KB

Nick Lynch - Random.md

File metadata and controls

42 lines (19 loc) · 3.24 KB

Rince and Repeat

Today we get to rinse and repeat from the last post. This means we get to explore a new concept in computing. We have been continuing our exploration into python and I have a great program to share.

Concept

The concept I decided to explore was random number generation. Computers are interesting because they can never actually generate a random number. It is mathematically impossible. However in this case they have random number generators that can get close. Close in our circumstance is good enough. Random numbers could be used for a variety of different purposes. Games where percentage of sucess is a constant relies directly on random numbers. Random numbers are also used in mathematics for Monte Carlo Simulatons. Lastly, random numbers are crucial for something like a fair die or virtual coin flip.

Project #1 (Simple)

The first project I explored was a simple loop that generates random color lights on the push of a button. Light colors are composed of three different numbers. The numbers each correspond to an intensity of red, green or blue, hence the name RGB colors. I decided to first hook up the colors to random numbers and run a loop of how the CPx goes through a cycle picking random colors. This could be used in addition to the performance which incorporated random numbers. The lights being organically random could help add substance and another layer to the randomness theme.

https://makecode.com/_7rr1kTUcVVCc

capturesdsd.png

Complex Program

Next, I explored how to make this program more difficult. I thought the only way to do that would be with more random numbers! I decided to add the sound aspect to the numbers, so while it chooses random lights it also plays a random sound. Sticking to the theme of the previous paragraph a performance could incorporate this into a performance. On a certain movement a random sound could occur.

https://makecode.com/_2RA3U8e2dJK5

capdlksdture.png

Do It Differently

I decided to tweak the design of the last program just a little bit. Instead of playing a completely random note, I decided to make it a random scale. I saved the last value in a variable then added by a random number between -10 and 20. This would mean the note is at most -10 below or 20 above. The note could also remain the same. This allows the spinning wheel to have some pattern. This sounds a little cleaner and more performance ready. I would be interest to explore the same concept using a Microbit and use different sound effects.

https://makecode.com/_euUHjfV796aUokep okepvroo.png

In conclusion, random number generation is a very interesting topic. It has many different possible applications and interestly enough are never actually random. I believe exploring these random number generators more would be an interesting topic and something I hope to build on in the future.

Here is a video I made to show the process of building the programs listed above. I hope it helps me readers actually run through the example above

https://www.useloom.com/share/761f648e0c934b748daae38f138575bc