kedoska / engine-blackjack

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

Why does bot not play for the draw? #44

Closed Edsardio closed 7 years ago

Edsardio commented 7 years ago

So I've actually managed to implement this into a discord bot (wasn't really that hard tbh)

When testing around I stumbled upon this.

152f24f280cd40a5aba567f7d089744f

The player did stand immediately, on the first draw for dealer both dealer and player had 16, dealer got another card and overdraw making the player win. This causes the player to double it's points instead of win his original amount. Is there a way to add this as an option when initializing the game?

kedoska commented 7 years ago

@Edsardio the issue here is that dealer stands on 17. So 16 is not enough and he must take another card. You are expecting a push situation but it is not .... Player won.

Edsardio commented 7 years ago

Is there no way to make the dealer play for the draw, would love the functionality myself :) Draw > lose

kedoska commented 7 years ago

it really depends on what you want to do:

  1. you want to provide a demo or a practice session... in that case you can have specific payload, forcing the engine to do what you want (so you can teach the player to do the right things cause you know the sequence of the cards)
  2. you want to change the game rules... not sure how much this will alter the stats of the game (but it is probably a lot..)

If the answer is... 2 alter the game, you can hack on this

        let stage = null
        if (dealerValue.hi < 17) {
          stage = TYPES.STAGE_DEALER_TURN
        } else {
          if (!rules.standOnSoft17 && engine.isSoftHand(dealerCards)) {
            stage = TYPES.STAGE_DEALER_TURN
          } else {
            stage = TYPES.STAGE_DONE
          }
        }

Instead of stay on STAGE_DEALER_TURN because the dealerValue.hi < 17 you can probably compare if dealerValue.hi is > playerValue. You also have to consider the split... so the logic will probably grows but everything is around STAGE_DEALER_TURN

Edsardio commented 7 years ago

Thanks for your fast and detailed replies :)