Code Monkey home page Code Monkey logo

blackjack's Introduction

blackjack

BlackJack competition on kaggle https://www.kaggle.com/borisalekseev/blackjack-microchallenge/edit discussion https://www.kaggle.com/learn-forum/58735#latest-348767

blackjack.py is a description of game realization. Could be used to check the rules of the game.

Currently, dealer++.py consists an algorithm to calculate distribution of probabilities for dealer to get total of 17-21 or 22 (when dealer get more than 21) on each stage)

Folder js contains the port of dealer++.py to Javascript (thanks, Serg!)

Next goal - calculation of the best strategy for player.

The overall idea is (not finished yet!!):

def PlayerStrategy(total, aces = False):

"""

total - current total sum of cards

aces - is True if Aces are among the cards, False if not

should return

[Stop, Prob]

Stop - True - if the best decision is to stop, False - if not

Prob - probability if win

"""

dealer_distr = {17:0, 18:0, 19:0, 20:0, 21:0, 22:0}

dealer_distr = dealer()

player_win_if_stop = dealer_distr[22]

player_win_if_continue = 0

for c in range(1,11):

if total+c > 21:

  # player in fire

elif aces and total+c<12:

  # player use aces
  
  stop, prob = PlayerStrategy(total+c+10, aces or c == 1)
  
  if prob > player_win_if_continue:
  
    prob = player_win_if_continue
  
else:

  stop, prob = PlayerStrategy(total+c, aces or c == 1)
  
  if prob > player_win_if_continue:
  
    prob = player_win_if_continue

if player_win_if_stop > player_win_if_continue:

return [True, player_win_if_stop]

else:

return [False, player_win_if_continue]

blackjack's People

Contributors

a402539 avatar originalsin avatar

Watchers

 avatar  avatar

Forkers

originalsin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.