Xinerki / kgv-blackjack

Blackjack for FiveM, very close to GTA Online.
42 stars 32 forks source link

Balance of Fairness #17

Closed deviljin112 closed 4 years ago

deviljin112 commented 4 years ago

TLDR: Changed how the script draws a card. Instead of shuffling and then drawing a random card from the shuffle, a much more fair method is to shuffle and take the first card every time. Also added extra debugging options.

Long Version For Nerds: In classic blackjack the chance of winning vs the house is just under 50% (46% if we don't count a push as we technically don't lose). Game per game, house has 0.13% edge over the player. Even with the basic blackjack strategy that edge can be lowered by 0.05% at best. After running some tests and checking the coding I've realised how unfair the games were. Doing 50k bets, every time starting at 1mil for every test (3 tests with each setting - for about 30min each more or less or until my money is gone), I found that i would be on a lose streak for over 800k without a single win or push. I've looked into the code and plotted some maths into it. With the old method the chance of you winning is actually under 1 in 3, that's less than 33% of the time, due to how the shuffled deck of cards is ignored with a random draw selection. This defeats the standard rules of blackjack and gives the house a very large advantage. By just shuffling and using the 1st card of the shuffled deck I was able to bring the ratio back to under 50%, as its a game of chance after 3 tests (1mil start for 50k bet games) in one test i nearly doubled, one test i finished nearly the same amount and one test i dipped to just about 700k. Although not extensive as I've spent enough time just doing the maths for this. Using a shuffled deck is much more fair then the current method, and brings the correct winning odds or nearly the same odds to this game. If someone comments with "you can count cards on single shuffled deck" - yes and no. The cards are shuffled on each round therefore you cant really count it unless you are the last sitting player at a full table. If you really care about minor card counters, you can always double the deck which will still be more fair than the current system. As the odds don't change much with double deck systems they only stop card counters from cheating.

Thank you for reading if you were bothered.

deviljin112 commented 4 years ago

Also took out trailing white spaces as they really bothered my OCD :)

Xinerki commented 4 years ago

rad