ProgrammingJavascriptCareerProductivityGadgetsASP.NETWeb Design

Simulations Are A Powerful Thing

Written by
Published on
Modified on
Filed under
Simulations Are A Powerful Thing

One of the most beneficial (as in to humanity I guess) aspects about becoming a programmer is learning to control data, no matter what that data is, and then using that data to represent something quickly and efficiently. We can create it, manipulate it, delete it, millions of times over in a blink of an eye. It's one of the first things taught in any college programming class and one of the first things that we forget once college is over, unfortunately. Loops, iterations, state machines, etc. All of these things combine to make for a powerful computational environment. Which brings us to the topic of this post, Simulations. In real world terms, a simulations is just the imitation of a real world event over time. In the digital world, it is exactly the same thing, except that it can be performed millions of times within your life span. And, you don't necessarily have to see it. All we care about is the data really.

Here is a very cool 2D physics simulation created by Burak Kanber in his fun to read post about physics and JavaScript that I highly recommend. It uses some of the most basic physics principles and scales them down to the 500px wide canvas you see down below.


Get a better browser!

The cool part is any programmer can delve into the world of simulations using a variety of real world data or, for the more creative, their own sets of data and discover something that wasn't visible before.

Data processing on a large scale is something that's normally taught in college in any computer science curriculum. And something that I personally don't get to touch upon too often. But it's something that came to me a few days ago when Elon Musk mentioned that there is a possibility that our current perceived reality is nothing more than an advanced society's own simulation. Maybe he's right, maybe he's wrong. It's a statement that can be made about anything really. If a society is old and powerful enough, they could probably do whatever they wanted. But it got me thinking about software simulations as that is something that I played around with in college, eons ago.


Beginner Simulations


I Can Simulate Things Millions Of Times Over

I once took a class in algorithms in my junior year of college, and one of the final projects in the class was a series of card game simulations. Which is a great way to dive in because the smallest elements are essentially just cards, so only 52. You can check out my JavaScript based card deck right here. And for one of those particular card games, of which the name escapes me right now, something peculiar kept happening. It kept getting a runtime error. Not too peculiar in itself, but the main problem was that it only happened after running the script for a large number of iterations. Like 500,000 to a million iterations to be exact. I was stumped, and the professor was stumped.

I spit out all of the variables onto the screen as soon as an exception was triggered. And what I found was very interesting. It turns out that this card game has a very unique edge case, in which, roughly every 1 in 500,000 plays, both players will run out of cards and will no longer be able to continue. A draw if you will. But after much Googling on this game, no one ever mentioned that it was possible to even attain a draw. There is no way that I would ever be able to play 500,000 rounds of this game myself, jotting down the results along the way just in case there was a quirk at the 500,000 game mark.


Intermediate Simulations


We already have hundreds of real world events simulated in video games today. Skyrim for example, has its own physics engine, based on real world physics, but still custom enough that the game isn't completely boring. Otherwise it would take you hours to climb one of the many icy peaks in the game. And you'd have to set up camp at some point to avoid the temperature killing your character. And you'd probably die pretty fast. So liberties must be taken. But these world are still simulations of a possible world. NPC's still wander the land and have jobs to do, such as in the real world.

But let's also take other games like Sim City into the equation. A massive city-wide recreation that essentially runs itself based on certain rules and in game laws that characters must follow. Water flows, electricity powers and cars drive (with no real purpose).


The Complex World


There is alot of power in computerized simulations, particularly in this and age with the current speed and power of modern processors. And if you look forward 1,000 years, or even 100 years, it will be several times more powerful than that. One of the most recent examples that I can think of was the black hole simulation in the movie Interstellar. One of the films main tenets was its overall accuracy to its real counterparts and that includes the representation of the super massive black in the film. And since I'm no physicist, I will have you Google that yourself, until you find the 47 page paper on how Kip Thorne managed to bring that beast to life.

Most of the time programmers get caught up in the world of jQuery and React.js and a hundred other things, and forget that they too can also create and program. And there's no simulation framework right now that you can plug into your site and boom you're done. Data processing is still somewhat of an art form in the tech world and one that should be explored more often by today's Computer Scientists.

Walter Guevara is a software engineer, startup founder and currently teaches programming for a coding bootcamp. He is currently building things that don't yet exist.

Comments

No messages posted yet

Developer Poll

Q:

Stay up to date

Sign up for my FREE newsletter. Get informed of the latest happenings in the programming world.

Add a comment

Keep me up to date on the latest programming news
Add Comment

Stay up to date

Get informed of the latest happenings in the programming world.

No thanks