Street Code – Weather of Bluff Street: Part 1

Please Note:  This article is free, The “Street Code” series of articles is reserved for Bluff Street Lab patrons.   If this article is of interest to you please join Bluff Street Lab and you will be notified and gain access to new  “Street Code” articles when they are posted.

 

When drafting up the idea of Bluff Street, one of my visions and far fetched goals was to have it so  no matter the game a player is playing, the in game weather was the same.  This idea forced me  to be creative as to how will I program weather.

Program reality is not realistic.

Usually game developers would create an algorithm or purchase a third party tool that generate the in-game weather from a predefined list of weather conditions,  using their RNG, Random Number Generator,  would select the weather to use.   You find this type of weather algorithm in many of the sports games for example.

This algorithm as I stated above doesn’t meet my objective.   After a while testing various weather algorithms out there I wasn’t impressed.  It didn’t feel “real” enough.  It was either a thunderstorm or clear sky, that is not how mother nature actually works.  There is a lot of grey area (lame pun intended)

One of the lessons game developers quickly learn is programming an algorithm that matches the behavior of reality is extremely hard and extremely complex.  Mother Nature is a complex women.  It was this life lesson that got me to thinking, instead of trying to program an algorithm why don’t I simply capture it and use it.

Capturing mother nature. 

Using an open source tool, Open Weather Map. I can pass it a  particular geocode and it will return the current weather condition for that location on earth. I selected 5 or 6 different locations and wrote a script that will fetch the weather conditions of those locations and store the results in the Bluff Street Database. The script runs every hour of every day.

The script has been running since December 2016.  The goal is capture a year’s worth of hourly weather conditions from these locations.

Fetching data is easy, calculate data is harder

in 1981 a 5 MB hard drive cost over $2,000.

There is an old saying about computers that still ring true today.  Computers can really only do two things,  Fetch something and compare something.  Fetching something requires space (Hard drive,memory),  compare something requires brains (CPU,GPU).   In the early days of computers both tasks were costly in terms of resources and time. Soon computers started to advance their brains at a faster pace then advance their storage, So programs heavy loaded the CPU to drive down the resources.   But a funny thing happened in the late 2000’s.   Technology for storage started to outpace the  advancements of the brains so now you are starting to see developers heavy load the Fetching.

With the weather algorithm for Bluff Street I am doing just that. Instead of having the CPU come up with a random weather conditions, I am simply fetching a weather condition from the database and using it.   The beauty of this is I know that the values are legit because, because well the condition actually happened in real life.  I am using Mother Nature as my algorithm.

Make it global

Now comes the tricky part.   How can I make each game fetch the exact same weather condition.  I need some global index or something.   The best global index is time itself  and as such I use time as my index and enables each game to fetch the same weather condition.

Step #1  – Take the date and time …ie 7/14/2017  6:00 am
Step #2 – Generate fetchIndex

 

fetchindex = ( DayOfYear * 1000) +  (HourOfDay * 100) = 195000 + 600 = 195600

Step #3 –  Take the fetchindex and fetch a Dice Hex (DiceHex is a subset of hex values that have various Dice values embedded

dicehex = DiceHex.FromIndex(fetchindex)

Step #4 –  Pull the D16 value of the dicehex, this is our locationIndex.   Keep in mind that these values aren’t random but calculated using math expressions.   6:00 am on 7/14/2017 will always return the same fetchIndex and in turn will always return the same DiceHex and locationIndex.

locationindex = dicehex.GetD16

Step #5  – Finally let’s get the weather information

weather = WeatherTable.Get(locationindex,fetchindex)

To be continue

The next part I will discuss just how I store the weather conditions and embed it in each Bluff Street game.   Hint: I hope you like hex numbers and number converting.

Thanks for being a Patron of Bluff Street Lab, please provide feedback regarding this article.   What did you like about it what didn’t you like.   Let’s have a conservation, let’s learn together.

The Hedron Cup is approaching

After visiting with Pip today  I feel the need to remind everyone that The Hedron Cup is fast approaching.   If you haven’t already started on designing your own dice I strongly suggest you start. While the final set of dice games hasn’t been finalized,  I can happily confirm that “Shut the Box”   will make […]