Closed rowboat1 closed 5 months ago
Hey
Thanks for this PR - it's definitely a good attempt at fixing a bad flaw you point out. I do find the logic a bit hard to follow though, and think it's a little unnecessarily complex.
It spurred me to make a similar, but simpler, PR that should also solve this issue: https://github.com/tom-james-watson/wikitrivia/pull/122.
Let me know what you think of that.
I also found my own logic confusing, and was thinking up my own improved solution, haha! Let me know what you think of #123 😄
The
tooClose
function will always hit if you draw too many early cards in the 1800-2020 range.For instance, if you draw 1880, and then 2000, you will now cause any card in the 1800-2020 range to fail on the
tooClose
check on your third draw, and force a random card to be drawn.When the tooClose function rules out all cards in a period, the game defaults to drawing a random card from the deck without any other failsafes.
One of the failsafes in
tooClose
is to ensure cards are at least 1 year away from any existing card. But this gets bypassed if the original check failed.Without this failsafe, we can have ties (which fail on a coinflip, and are annoying) and in some cases even a duplicate card being drawn.
This also creates many more happy cases that preserve the intended balancing effects of
avoidPeople
and splitting cards into three different periods.Should close #81 and #103 (in fact, if you look at the screenshot in #103 , you can see that they've drawn 3 cards in the 1800-2020 range during their game, likely causing this exact bug)