We’re off to see the wizard…
This is a continuation of my previous post “Hit Me?” Whats changed since the last post? Well since then I added support for playing Blackjack the optimal way outlined on the website wizard of odds. It touts statistically proven blackjack play (and advice for many other luck based games). You can see more info on their site here here and you can see the guide I followed exactly here, since I only used a deck comprising of 52 cards and I allowed the dealer to soft hit at 17, this was the exact guide I needed. Lastly you can check my code on my github here and see the exact results on this google doc. Now onto the results
My findings, made using gnuplot.
Using the wizard of odds exact methods showed a clear gain in percentage of wins over the maximum I had using just basic “stop at this number” logic. However whats really interesting to me is that it isnt a huge percent gain over the competition. The best number to either soft hit or stay on is 14, with that its a 42.05% win-rate generally, however using Wizard of Odds technique only resulted in a 43.43% win-rate, leaving only a 1.38% percent difference between both. It proved to me just how much of an advantage the house has that even using statistically proven methods at giving you the best odds you still lost more often than you won. Which makes sense if there was some way you could win at blackjack greater than 50% (not counting cards) the casinos and other gambling halls would simply not have blackjack anymore. No ones going to let that cut into the profit margins.
I was busy daydreaming about optimal poker play one day and was wondering if theres an easy way to quantify it using code. Well I’m sure since its so much a game that cannot just be looked at on paper (with bluffs, counter bluffs, fake bluffs, etc.) its not something really feasible to do it to that game in particular. I then realized I could quantify optimal blackjack play far easier since the dealer has to adhere to strict rules and the player can decide where they decide to hit or not.
A code excerpt.
So I built some code (code you can find here.) to test it out and I found my results very interesting. For anyone who may be reading this that doesnt understand the rules of blackjack I’ll attempt to explain it as simple as possible. The object of the game is to get as close to 21 as possible without going over, any face cards (Jack, Queen King) are equivalent to 10, while the Ace is special as it can be a value of 11 or 1 depending upon whether or not being 11 would cause your current count to go over. You are playing a long with your fellow players against the dealer. At almost any casino the dealer is not allowed to hit after he reaches 17 or above, he is allowed what is called a “soft” hit if he has an Ace and any other cards that equal to 18. Becuase of this rigid rule structure he was easy to program since he doesnt really have to do anything beyond hit before a set limit.
This graph showcases the win amount percentage of the entire range numbers to stay on in Blackjack
After I ran the game about 10 million times checking for each number the AI isnt allowed to hit past I found some very interesting results. For one thing I found that no longer hitting after 14 (or having the same “soft” hit rules mentioned before) was the highest amount of wins per player. Not hitting in the range of 13-15 had very similar amounts but its clear that 14 is the “ideal” number to not hit past.
This graph is more indepth showing how seemingly superior staying between 13 to 15 really is.
This was very eye opening to me because I had always assumed it was 17 simply because thats what the dealers were forced to do but it turns out no you have the best odds by staying at a number between 13-15. While at the end of this write up I’d like to leave you with a fun fact, while the player at 14 won about 4.2 million games at best the house beat 4 other players all stopping at 14 over 24.7 million times, which translates to roughly 3.7 million more wins over the players. Which perfectly illustrates why the house always wins.
P.S. You can see the exact data I used for the graphs above here.
I should probably hit here.
UPDATE: I have since implemented a way for people to play Blackjack in terminal in my code with a hit limit of 5.
A render of the watch modeled on the unreleased Pebble Time 2
Post Update: Since its release it has been downloaded over 18,000 times in over 100 countries (current as of 4/12/18)! I am genuinely so ecstatic to think something I worked on was seen by 18,000 unique people and installed on their respective devices.
I woke up one day and decided I wanted a new smartwatch face, not just any smartwatch face mind you one from a game I was addicted to playing and could not stop thinking about for any reasonable length of time. The game was the newest installment in the Resident Evil series. In it you play as Ethan Winters, a character looking for his missing wife which leads him to a farm owned by the Bakers in Dulvey, Louisiana. To make things short he has a generally bad time in the house with a lot of nasty things happening to him. In the beginning sequence of the game he gets a watch, the watch from then on acts as a health meter, in it you can tell if your fine (green), a bit roughed up (yellow), or on death’s door itself (red).
Since I was so excited from the game I decided to go out and get a watchface for my Gear S2. After searching the web a bit I could only find ones that weren’t for my device or watch faces that only had a static background and didnt look as nice or professional as one that I knew I could make. After doing some initial research on what tools to use I settled on Samsung’s very own Gear Watch Designer, a simple easy to use program to make watch faces for Samsung devices. I then went on began my initial work in Photoshop, taking a screenshot from gameplay footage to really see the same design and aesthetics that it had and that I wanted to translate to a round screen rather than the square one in the game.
Humble Photoshop Beginnings
Once I got the initial designs I had originally thought that would be it. I made a simple background and once I actually implemented it I realized it wouldnt be something I would want on my wrist. I mean it came out fine, it was a nice homage to the game but it wasnt really anything special beyond that. It was basically a image with the time on it and I wasnt happy with leaving it at that. So then I began working on animating it just like it does in-game. I once again used my Photoshop talents to get a solid animation. I did have to work around the fact that the number of frames per second on the watch was only 15, because of that I made my animation last 60 frames total for 4 seconds loop time. Long enough for it to not feel too fast while looking smooth in action but short enough to where it doesnt seem too slow.
First Animation Test
Now that I finished animating it I felt my project was complete. Well it did at least up until an epiphany came to me. I could make three separate animations for battery life. One when its relatively fine (25% or higher), one when its in trouble and could use some charging (16-25%), and one when it (like Ethan) was on death’s door (15% or lower). An obvious idea in hindsight, but the thought to do three animations didnt hit me right up until that moment. I then redid the animations, changing the colors and using the dev tools given by the watch designer application I made it so at certain battery life the animations would change.
Showing off how battery affects the display using Samsung’s built in emulator.
After I got that working I decided to start working on multiple animations like in the game itself rather than the same animation with the color changed, I once again opened up Photoshop and got to work and the results looked amazing. I promptly loaded it onto my device to check and lo and behold it was just as nice as it looked on the emulator. The final seperate animations are shown below. If your interested in downloading it for your own Gear S2 or S3 its available under the name “Biohazard 7″ from the Samsung App Store.
The final animations.