Flash0ver / F0.Minesweeper

Source of truth for a Blazor implementation of Minesweeper.
MIT License
6 stars 0 forks source link

feat(logic): add RandomOrderLocationShuffler and FisherYatesLocationShuffler #93

Closed thomas-pemsel closed 2 years ago

thomas-pemsel commented 3 years ago

Here it is, a quick little Pull Request for other Shuffler algorithms 😉 I create this as a draft Pull Request as I would like to test out if I can pre-seed the randomness in these algorithms so that I can write unit tests for them. But you can have a look over the structure and how it fits into the code. Closes #65

Flash0ver commented 3 years ago

Don't forget to Linking a pull request to an issue using a keyword 😉

Flash0ver commented 3 years ago

X-L-ent start! Hmmm, how do we test random 🤔? I start thinking out loud ... well ... silent ... I press some keys on my board: Do we need an IRandom interface with the Random methods currently in use, and implement a production SystemRandom or DefaultRandom which proxies a System.Random, and then a TestRandom or FixedRandom, where we put in an array, or collection of numbers serving as the predefined sequence of next random numbers 🤔. Or, we derive directly from Random.

thomas-pemsel commented 3 years ago

So, I implemented the things that @Flash0ver mentioned, so I guess this PR is now official-ly ready to review ;) I even went through the Fisher Yates shuffle algorithm manually to construct two of the test cases. Here's a screenshot of my notes for this: 😅 grafik