Giter VIP home page Giter VIP logo

blackjack_ai's Introduction

BlackJack_AI

Contributors: Ani Hazarika

A project to create and analyse the mathematically optimal Blackjack AI.
https://www.profitsquad.co.uk/blackjack-strategy-how-to-play-perfect-blackjack/ This website (along with many others) describes a mathematically optimal strategy to playing Blackjack giving a chart for easy execution. Even after deploying this strategy, there is always a House Edge of 0.5%, so you win always lose on average 0.5% of your money.

This project is here to test this hypothesis. First I will play Blackjack using my best intuition (interpret that as you like) to play and then see the distribution of wins/losses that I achieve. Then I will make an AI that uses this optimal method and see if it achieves a better outcome than me.

Some of the simplifications I've made to do this project:

  1. As this is an experiment seeing how this strategy fairs against the house, there will only be one player and the dealer.
  2. Only one deck of cards will be used, and the deck will be shuffled after every round.
  3. I will not be considering bets in terms of amount of money. Instead I will assign discrete values to wins, ties and losses.

The chart below from https://towardsdatascience.com/winning-blackjack-using-machine-learning-681d924f197c shows the optimal strategy to Blackjack:
optimalchart

Over the course of a few months (yes that's how long it would take to get enough data) I will play a few games a day and record my wins(+1) and losses(-1). Then my total for the day is (wins+losses)/num_of_games. This will get appended to a list of my previous scores and a histogram will made. Hopefully a nice Normal Distribution can be seen showing the Central Limit Theorem with a mean of just below zero.

Then I will repeat this same process for the AI and see if the the mean is slightly higher than mine.

The histogram below shows the distribution of scores the optimal AI achieves after 200 rounds. (Love the Central Limit Theorem in action :)) It's mean it just below 0, showing that the house edge is always there. The mean of around -0.25 also shows the House Edge of 0.5%. I had let the AI play 50 games each round and so it would be expected to have a mean of -0.25. aihistogram

From the histogram below, it can clearly be seen that I am definitely a lot more erratic with my winnings than an optimal AI. However it is obvious that my mean losses are much greater than that of the AI (although I do occasionally win). playerhistogram

blackjack_ai's People

Contributors

anster01 avatar

Watchers

 avatar

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.