I passed my time in lockdown creating an Event Sourced version of the classic game Minesweeper! Be sure to try out the slider after a few moves, or if you click on mine.
This just made me realise that the way chess games are written down (move after move, using the strict minimum amount of information) actually is Event Sourced.
I was playing a quick game, clicked a mine and it was impossible for it to be a mine based on the numbers. I was about to screenshot and post it here when I realized that I had scrolled to perfectly hide the bottom row of the game, which changed everything.
There's another HN post right now about a UI problem costing Citibank $500M. It seems like this is somewhat related in my mind. If the application had made clear to me somehow that I wasn't seeing all of the information I needed to see, I wouldn't have failed. Not that it matters in this case. Just an example of how common these sorts of problems are, and how hard it would be to find and prevent all of them.
The perils of hiding the scrollbar by default (and also using a fixed:bottom element). I feel the modern push for clean design sometimes goes too far - removing the scrollbar definitely being one of those instances.
Really nice implementation!
I did tried to make simple game using JavaScript ES6 2 years back. It was really fun and learned JavaScript concepts to implement this.
https://magnetomax.github.io/MineSweeper/
Oh, it's in Elm. Cool! I'll definitely read the code later today and hopefully learn something. Did writing this reveal any interesting pros/cons regarding event sourcing in contrast to a stateful implementation?
Minesweeper is such a cool exercise when learning new stuff. A co-worker challenged me to write this crude implementation on a flight from Heathrow to NYC while I was learning Go: https://gitlab.com/joyey/kakkamiina
I may have found a little bug. Sometimes when you win the last mines don't get a flag: https://imgur.com/a/xLcNZ0X. My last move was to right-click on the 2 in the bottom left.
Also, right clicking on borders sometimes pops up a context menu.
One of the fun side games I've been playing is to try to beat the game with the fewest possible events, which means not flagging squares - it's definitely much harder!
That's definitely the crux of the problem! Although it would be cool to see the clock go backwards when you drag the slider, it's probably more accurate to keep the clock counting up so it reflects the overall time it takes to complete the game.
Check out the code here: https://github.com/dfarr/minesweeper
I also wrote a blog post: https://dfarr.medium.com/event-sourcing-minesweeper-65f0d497...