Tag Archives: programming

Getting to Legendary in Hearthstone

Hearthstone

Hearthstone is a curious game. It’s an online card game that has attracted a huge following of casual and competitive players. There are over 40 million world-wide players and the World Championships this weekend had a $1 million prize pool. The game is kind of like poker and chess combined, with a lot of strategy around trading pieces and a bit of luck with card draws and other random effects. I like it because the games only lasts 5-15 minutes and there is a lot of strategy and thinking involved. Most online games require fast reaction times, but Hearthstone is turn-based and you get 75 seconds each turn to plot your moves.

There are a few game modes, but the most popular is the ranked ladder. You start the game at Rank 25 and play against other players with the same rank. As you win games, your rank improves, lose games and your rank gets worse. The ultimate goal is to progress beyond Rank 1 to Legendary status. Every month the ranks reset. I’ve never gotten beyond Rank 5 and I had to play a lot of games to get that high.

Getting to Legend status is about consistently playing well (above 50% win rate) and grinding out a lot of games. How many? That depends on the deck win rate. I wrote a script (below) to simulate how many games it would take to reach Legendary depending on your win rate.

If you’re only winning  50% of your games you play, you can make it to Legendary but be prepared to play around 1440 games. With a 55% win rate, a pretty good result in competitive Hearthstone, it would take on average 483 games to reach Legendary status (at least 15 games a day). Even if you could consistently win 60% of the games you played, an impressive feat, it would take 287 games a month to reach Legendary. I thought I played a lot of Hearthstone, but I don’t have that kind of time.

hearthstone_legendary

Code:

Riddler Revisited

I’m taking a second crack at FiveThirtyEight’s Riddler problem. I thought I solved the problem two weeks ago, but my answer wasn’t quite right.

Here is this week’s problem:

There’s an airplane with 100 seats, and there are 100 ticketed passengers each with an assigned seat. They line up to board in some random order. However, the first person to board is the worst person alive, and just sits in a random seat, without even looking at his boarding pass. Each subsequent passenger sits in his or her own assigned seat if it’s empty, but sits in a random open seat if the assigned seat is occupied. What is the probability that you, the hundredth passenger to board, finds your seat unoccupied

I’m not even going to try and figure out the math for this puzzle. My statistics skills aren’t nearly strong enough. But my coding skills are. This is an easy problem to solve with a Monte Carlo simulation.

Here’s my python solution.

And the output charted.

nth_passengerThe last passenger has a 50% chance of getting their assigned seat.

passengers_in_assigned

The number of passengers who get their assigned seats is distributed around 95, with a 1% chance of everyone getting their assigned seat (in the event the first passenger randomly chooses his/her own seat).

Interestingly, it doesn’t matter how many seats are on the plane. If there are 10 or 200 seats, the last passenger still has a 50% chance of getting their assigned seat. The second last passenger has  67% chance, and the 3rd last passenger has a 75% chance.

It’s easy to derive the equation for the Xth last passenger from this, even though I can’t figure out the math to prove it. The Xth last passenger has a X/X+1 chance of getting their assigned seat. So the 5th last passenger, has a 5/6 = 83.3% chance of getting their seat.

Cleanweb Hackathon – Epic Energy III

Hacking Away
On Saturday I participated in my first hackathon – the Vancouver Cleanweb Hackathon. It was a 12-hour coding marathon, or at least it was for our team from Pulse Energy. While most participants spent the first 2 hours brainstorming, pitching ideas, and recruiting team members, we locked ourselves in a board room and started coding with barely any breaks for eating or peeing. We weren’t necessarily serious or competitive. We just had an ambitious plan and only 12 hours to make it work, so there was no time for socializing.

Earlier in the week, we spent two lunches brainstorming about ideas and planning how we would build our favourite idea, a building manager sim game. We knew we were in over our heads, but we hoped the extra prep work would make up for our lack of game development experience.

Below you can see the evolution of our game as we slowly added functionality, content, and graphics. I’m impressed with how polished it looked after only 12 hours. A lot of the credit goes to our graphic designer, Tyler.

This slideshow requires JavaScript.

Our biggest challenges were making the game realistic (we used real data as much as possible), fitting in all the functionality we wanted (sadly, a lot of cool features got cut), and hardest of all, keeping it fun. At 6 pm, with 2 hours left, we stopped coding and did a play-through of our game and realized it was horribly boring. At that point, we stopped adding new features and prioritized fun. We added quirky comments from grumpy tenants, a scoring system, a tweet button, and animations to make it seem more like a game and less like a budgeting exercise.

I encourage everyone to check out and play Epic Energy III, and tweet your high score. The goal is to save as much energy as possible while keeping your tenants happy (which should be explained on an intro screen, but that feature got cut). So far, my best score is 20,308. If you’re interested in the code, you can see all the commits on GitHub. Don’t worry, even if you can read the code, it’s not obvious what the best strategy is to get a high score.

We’re still planning on making some improvements to the game in the coming weeks even though the Hackathon is over. It’s good marketing for Pulse Energy and fun to work on.
Continue reading Cleanweb Hackathon – Epic Energy III