4 ms·
Show HN: An Event Sourced Minesweeper
- david-farr 6y agoI 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. Check out the code here: https://github.com/dfarr/minesweeper https://github.com/dfarr/minesweeper I also wrote a blog post: https://dfarr.medium.com/event-sourcing-minesweeper-65f0d497e6a7 https://dfarr.medium.com/event-sourcing-minesweeper-65f0d497...
- minitoar 6y agoProbably the blog post should be the linked article?
- stanislavb 6y agohey mate, a bit random question, but did you edit your post to add the links?
- david-farr 6y agoyes
- usmannk 6y agoReally fun to finish and draw the slider backwards. Revealed a spiral pattern I didn't realize I was doing!
- adamhearn 6y agoThis is really awesome! Very fun to play. UI Looks good as well.
- cyode 6y agoNice, I love Minesweeper. By the way, the link to your blog post is incorrect in your README.
- david-farr 6y agoWhoops, fixed! Thank you
- justsomeuser 6y agoFeedback: You should add one notch on the progress bar for every step so you can visually see that every move adds another step you can move back to.
- mkl 6y agoI may have found a little bug. Sometimes when you win the last mines don't get a flag: https://imgur.com/a/xLcNZ0X 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.
- tlamponi 6y agoThat's no bug, flags are strictly placed by the player.
- david-farr 6y agoOne 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!
- yichijin 6y agoAwesome! Love the look and the blog post. But a feature request: a timer!
- jtbayly 6y agoI imagine there are a variety of ways to implement a timer where you can go back in time...
- david-farr 6y agoThat'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.
- deleted 6y ago[deleted]
- ElFitz 6y agoThis 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. Quite funny. So, thank you!
- david-farr 6y agoIndeed! That would be a really fun project to create as well, though much more involved.
- magnetomax 6y agoReally 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/ https://magnetomax.github.io/MineSweeper/
- david-farr 6y agoThis is awesome! I love the use of emojis right in the source code - I did the same
- tlamponi 6y agoYours is a bit more fun to play as it allows right-clicking on the flags to uncover surrounding fields. Both are cool stuff and nice learning experiments though!
- jtbayly 6y agoI 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.
- david-farr 6y agoThe 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.
- swayvil 6y agoI just played it. Works smoothly.
- meekins 6y agoOh, 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 https://gitlab.com/joyey/kakkamiina