News for hackers. Stuff that matters.
Re:Show HN: An Event Sourced Minesweeper by david-farr on Wednesday February 17, 2021 @09:28AM (#26166596)
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.

Check out the code here: https://github.com/dfarr/minesweeper

I also wrote a blog post: https://dfarr.medium.com/event-sourcing-minesweeper-65f0d497...

Re:Show HN: An Event Sourced Minesweeper by minitoar on Wednesday February 17, 2021 @07:20PM (#26173760)
Probably the blog post should be the linked article?
Re:Show HN: An Event Sourced Minesweeper by stanislavb on Thursday February 18, 2021 @02:02AM (#26176851)
hey mate, a bit random question, but did you edit your post to add the links?
Re:Show HN: An Event Sourced Minesweeper by david-farr on Thursday February 18, 2021 @08:52AM (#26179773)
yes
Re:Show HN: An Event Sourced Minesweeper by ElFitz on Thursday February 18, 2021 @04:28AM (#26177746)
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.

Quite funny. So, thank you!

Re:Show HN: An Event Sourced Minesweeper by david-farr on Thursday February 18, 2021 @08:55AM (#26179808)
Indeed! That would be a really fun project to create as well, though much more involved.
Re:Show HN: An Event Sourced Minesweeper by usmannk on Wednesday February 17, 2021 @05:56PM (#26172948)
Really fun to finish and draw the slider backwards. Revealed a spiral pattern I didn't realize I was doing!
Re:Show HN: An Event Sourced Minesweeper by jtbayly on Thursday February 18, 2021 @11:12AM (#26181609)
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.

Re:Show HN: An Event Sourced Minesweeper by david-farr on Thursday February 18, 2021 @11:18AM (#26181710)
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.
Re:Show HN: An Event Sourced Minesweeper by justsomeuser on Wednesday February 17, 2021 @08:09PM (#26174164)
Feedback: 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.
Re:Show HN: An Event Sourced Minesweeper by magnetomax on Thursday February 18, 2021 @06:31AM (#26178612)
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/
Re:Show HN: An Event Sourced Minesweeper by david-farr on Thursday February 18, 2021 @09:07AM (#26179929)
This is awesome! I love the use of emojis right in the source code - I did the same
Re:Show HN: An Event Sourced Minesweeper by tlamponi on Thursday February 18, 2021 @10:14AM (#26180710)
Yours 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!

Re:Show HN: An Event Sourced Minesweeper by meekins on Friday February 19, 2021 @03:27AM (#26190851)
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

Re:Show HN: An Event Sourced Minesweeper by mkl on Thursday February 18, 2021 @05:05AM (#26178041)
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.

Re:Show HN: An Event Sourced Minesweeper by tlamponi on Thursday February 18, 2021 @10:12AM (#26180683)
That's no bug, flags are strictly placed by the player.
Re:Show HN: An Event Sourced Minesweeper by david-farr on Thursday February 18, 2021 @01:00PM (#26183206)
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!
Re:Show HN: An Event Sourced Minesweeper by cyode on Wednesday February 17, 2021 @08:03PM (#26174121)
Nice, I love Minesweeper. By the way, the link to your blog post is incorrect in your README.
Re:Show HN: An Event Sourced Minesweeper by david-farr on Wednesday February 17, 2021 @08:05PM (#26174138)
Whoops, fixed! Thank you
Re:Show HN: An Event Sourced Minesweeper by yichijin on Thursday February 18, 2021 @02:28AM (#26177009)
Awesome! Love the look and the blog post. But a feature request: a timer!
Re:Show HN: An Event Sourced Minesweeper by jtbayly on Thursday February 18, 2021 @11:13AM (#26181631)
I imagine there are a variety of ways to implement a timer where you can go back in time...
Re:Show HN: An Event Sourced Minesweeper by david-farr on Thursday February 18, 2021 @12:50PM (#26183064)
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.
Re:Show HN: An Event Sourced Minesweeper by adamhearn on Wednesday February 17, 2021 @07:35PM (#26173900)
This is really awesome! Very fun to play. UI Looks good as well.
Re:Show HN: An Event Sourced Minesweeper by swayvil on Thursday February 18, 2021 @12:38PM (#26182894)
I just played it. Works smoothly.