Fix bug when no uncovered neighbors are avaiable and let rewarded hints match expected value #484
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR brings a bugfix and a feature.
The bug is that currently, when using a hint but no mine with uncovered neighbor is available, no mine is revealed (e.g. when the complete coastline is flagged). Fix is to check this and reveal a random mine otherwise.
The feature is that currently, the number of rewarded hints
h
is always the rounded down fractionq
(currenty 5%) of the total number of minesM
, thush = floor(q*M)
. This means thath/M <= q
and thereby induces a negative bias, especially when using small fields. The fix is to let the expected value ofh
equalq*M
by randomly chosing betweenfloor(q*M)
andceil(q*M)
with the appropriate probability (all this sounds more complicated than it is).Cheers!