kedoska / engine-blackjack

Javascript library to make blackjack engines
GNU General Public License v2.0
33 stars 29 forks source link

Case for 'even money' #60

Closed jmolero closed 4 years ago

jmolero commented 5 years ago

I think the engine is missing the insurance special case where the dealer asks for 'even money'. This kind of insurance should be available when the dealer has an ace card and the player has a blackjack.

After the 'DEAL' action, and if the player has a blackjack and the dealer face-up card is an ace, the game goes to the 'SHOWDOWN' stage instead of asking for even money/insurance.

The following link has an explanation with an example: http://www.hitorsplit.com/articles/What_is_Insurance_and_Even_Money.html

I might try to add this to the engine but maybe you can give me some hints.

kedoska commented 5 years ago

@jmolero this could be done introducing a new rule (ie evenMoneyInsurance). I will look into the required tests but it does not seem to be complex.

jmolero commented 5 years ago

Could be added as a rule but I think it should be part of the insurance. Even money is the mathematical result of the player taking insurance and having a blackjack: https://en.wikipedia.org/wiki/Even_money The player gets paid the same if has a blackjack and takes insurance regardless of the dealer cards.

I implemented this without the rule flag on #61

I tried all the cases of insurance and even money to check I didn't introduce any bugs:

kedoska commented 5 years ago

@jmolero I'll try to fix the CI as apparently, it is currently failing, but the #61 looks good to me. I just want to make sure it can be turned on and off by the rules to avoid introducing new functionality in production.

jmolero commented 5 years ago

Thanks @kedoska for looking into this. I think you are right, I didn't take into account it could be a breaking change. I pushed another commit that adds the evenMoneyInsurance rule and I set it to false by default in the preset. To enable even money, both insurance and evenMoneyInsurance need to be set to true. I also updated the tests for this feature in this commit.