Pages

Wednesday 30 July 2014

Plain vanilla BlackJack simulation with R

Please before continue reading, make sure to read the disclaimer at the bottom of this article.

Here is a simulation I run with R in the same period I created the poker one.

I have just decided to call it plain vanilla since neither double down or split pairs are allowed. Rules are as basic as they can be.

The code looks like messy, I know, If I had to do it now, I guess I would do many things differently, however, the results looks fine, and the code runs fine as well, therefore it is not entirely to be thrown away I believe.

The simulation is divided in two parts. In the first one I looked for the probabilities for each possible event (that’s to say: “player wins”, “tie”, “dealer wins”). Since the code looks pretty hairy, many explanations are provided.

A small but important note: if you want to run the simulation, since it is a bit demanding computationally speaking, in order not to crash RStudio you may want to run a line a time and not the entire code all at once, or just maybe use only some functions, just be careful because since we run the simulation a big number of times and the functions are not the fastest to be run, your computer might complain a little.

Here is the code:

Let’s have a look at the results that we have got:


im1


By simply standing with a hand equal to 19, you can expect to win 59% of the times, and loose 28%. A tie is likely to occur 13% of the times.


Let’s now simulate 2000*100 games with a hand equal to 18 and 3 decks and then average the probabilities:


im5


im4


In this case the odds seem to be a lot worse than before, by just subtracting 1 point to the player’s hand we raised the probability of win for the dealer from 28% to 43.4%.


Why not run the simulation for each hand from 16 to 21 and then plot the results? Warning: your computer may yell at you after this demanding step!


im6


As we could expect, as the player’s hand gets higher, the probabilities of winning increases. For some reason which I ignore, R did not print in plain the probabilities of winning for the dealer, however you can easily get them from the table above or by calculating for each row 1 - Prob of Win – Prob of a tie, since the three events should (must) sum up to one. It is interesting to note that the probability of a tie is more or less near 12-14% and that, as we expected, it is equal to 0 when the hand is equal to 16 (since the dealer must draw on 16 and therefore a tie is not possible).


Here are the plots:


Rplot


Rplot01


Rplot02


This is the end of part 1 of the simulation.


 




And now the second part. Here we want to know what are the probabilities of not bust when we draw 1 or 2 cards given a certain hand.

Let’s have a look at the new results we have got:
This is a hand we have got by asking 2 times card from a single deck.


im7


with a starting hand equal to (10,”A”) if we were to ask 2 cards, here are the probabilities that we should face:


im8


Eventually, we can compute the probabilities of “survival” and bust for each hand from 16 to 17 and plot the results.


im9


im10


Rplot03


Rplot04


Rplot05


Rplot06


The results looks pretty interesting and it is nice to see that the probability of bust if we ask for 1 card and our starting hand is 11 is 0 as we could easily predict, however, if we were to ask 2 cards, our chances of survival would suddenly drop to 25%. A big leap!


Hope this was interesting.





Disclaimer: This article is for educational purpose ONLY. Odds generated by this code are calculated by a random simulation. As such the odds will represent an approximation of the true odds. They might even be completely wrong or misleading. This code must NOT be used for anything other than educational purpose. The provider of this code does not guarantee the accuracy of the results and accepts no liability for any loss or damage that may occur as a result of the use of this code. Understanding and agreeing to the terms of this disclaimer is a condition of use of this code. By reading the article you confirm you have understood and will comply with this disclaimer.

61 comments:

  1. MAU GANDAKAN DUIT HANYA DENGAN 10rb RUPIAH??

    DISINILAH TEMPATNYA DI P`0`K`E`R`V`1`T`A

    KEPUASAN MEMBER ADALAH PRIORITAS KAMI

    Dengan pelayanan Customer Service professional kami ONLINE 24 JAM proses Depo & WD yang cepat.

    Agen Poker Online Uang Asli Terpercaya di Indonesia

    8 PERMAINAN DALAM 1 USER ID :
    *ADU Q
    *BANDAR POKER
    *BANDAR Q
    *CAPSA SUSUN
    *DOMINO 99
    *POKER ONLINE
    *SAKONG
    *BANDAR 66 (NEW)

    ReplyDelete

  2. Do you enjoy playing Blackjack? but your luck is less than favorable.
    I had the same problem until I found easy money blackjack system.
    learn the tricks from the professionals.we all know that in most cases the house wins.
    they may give you a nibble every once in a while. you have the power to change your luck with easy money blackjack system. don't keep losing your hard earned money.
    for more details on the easy money blackjack system. please click the link below.
    http://bit.ly/2W9aVZj

    ReplyDelete
  3. Amazing and lovely, I like it and i will share it to others. Join us at http://bolanet88.biz

    Agen Judi Casino
    Casino Online
    Aplikasi Judi Bola Online
    Situs Bola

    ReplyDelete
  4. Look! In the sky. It's a bird, it's a plane. Or is it a hellicopter? No actually I think it is a bird. Or maybe I'm just seeing things. Who knows... After 10 shots of Whiskey things start to get a bit strange.

    situs poker online

    bonus poker
    poker online terbaik
    idn poker indonesia
    main ceme online
    cara menang poker
    panduan daftar poker online

    ReplyDelete
  5. Last Saturday, as I was weeding my organic foxglove bed, it struck me! I'm so glad we ended our 4 week holiday through Central Asia with an afternoon of volunteering at a Mongolian orphanage - it really made us feel we were giving something back at this time of global crisis. I guess Marx was more right than he knew when he warned us against the dangers of laissez-faire capitalism.
    roulette

    ReplyDelete
  6. I can't help but wonder what Edward Snowden would think about this. Isn't it amazing that we can find £30bn to spend on Trident but we can't afford even basic woodwind lessons for all Primary school pupils? It's all Thatcher's fault.

    agen poker online

    qq deposit murah
    promo poker online
    bandar q
    poker crop
    poker perforate

    ReplyDelete
  7. We were chatting over a coffee, simple filter, not Nescafe (baby-killers) and started to think out loud. Soil depletion is really just the tip of the iceberg when it comes to the challenges faced by African peasant farmers today. Viva la revolucion! Viva Chavez.
    Sbobet88

    ReplyDelete
  8. Memainkan taruhan Judi kartu idn poker memanglah sangat menyenangkan, apa lagi jika anda memainkannya bersama bandar yang tepat. Segera gabung dan jajal keberuntungan anda bermain judi Poker Online bersama idn poker sekarang juga. Pastinya Kemenangan akan menjadi satu satunya pilihan anda di sini

    IDN Poker

    ReplyDelete
  9. This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post.

    Adu ayam

    SBOBET

    cockfight battle
    cockfight arena
    cockfight player
    cockfight poker
    cockfight power

    ReplyDelete
  10. I’m honored to obtain a call coming from a friend as he discovered the important recommendations shared on your own site. Browsing your blog posting is a real wonderful experience.
    Thanks again for thinking of readers just like
    me, and I want for you the best of achievements like a professional in this discipline.

    gameqq

    agen poker indonesia

    domino player
    master domino
    rocang bonuses
    card gaple
    domino agents

    ReplyDelete
  11. Situs Pasang Permainan IDN Poker Online Terpercaya di Indonesia, dengan minimal deposit dan withdraw cukup 10 ribu saja loh... segera bergabung ya dan menangkan jackpot ratusan juta...

    Situs Poker Online
    Poker Online
    s128
    Baccarat Online

    ReplyDelete
  12. suka main idn poker ?? idn Poker ??

    suka main sabung ayam s128 ?

    ReplyDelete
  13. Здесь полная информация про блэкджек ребята: https://casino.azartru.net/blekdzhek.html и не говорите мне спасибо наконец.

    ReplyDelete
  14. Bermain judi poker qq online yang terpercaya itu hanya ada di http://www.sydneycityairportshuttle.com/UserProfile/tabid/695/userId/330714/Default.aspx dan pastinya akan bisa memberikan kemenangan dan keuntungan yang besar.

    ReplyDelete
  15. Sudah coba untuk bermain game bandarq online yang ada di situs terpercaya http://winbadutq.arwebo.com/12585034/game-bandarq-online-shop-terpercaya-bagaimanakah-kegemilangan-tinggi ini ? Buruan menangkan ratusan jutaan rupiah setiap harinya.

    ReplyDelete
  16. Total4D adalah bandar judi dan Agen Togel Online terbesar dan terpercaya mulai dari angka jitu Togel Singapore,hongkong,sidney dan data info keluaran togel

    Agen Togel Online
    Togel Online
    Togel Singapore
    Bandar Togel Terpercaya

    ReplyDelete
  17. Letak Yang Produktif Judi PokerQQ http://scoreshotus.thenerdsblog.com/312387/letak-yang-produktif-judi-pokerqq yang pastinya kalian akan bisa mendapatkannya pada badutqq saja.

    ReplyDelete
  18. Main Judi Online via Android yang Sangat Menyenangkan http://cs.scaleautomag.com/members/badutonline/default.aspx yang pastinya hanya ada pada situs judi badutqq online yang terpercaya ini.

    ReplyDelete
  19. Situs Agen Judi SBOBET, Agen SBOBET Terbesar, Agen SBOBET Dengan BOnus New Member, Agen SBOBET Bola Online, Judi Bola Deposit Termurah, Bandar SBOBET CS 24 Jam, Judi Online SBOBET, Daftar SBOBET Dengan Mudah, Cara Daftar Judi SBOBET, Bonus Besar Judi SBOBET, Judi SBOBET Deposit Pulsa, Judi SBOBET Terbaik, SBOBET Sepak Bola, Main Judi Bola Online SBOBET Sekarang, Judi Tembak Ikan Joker123, Tembak Ikan Joker123 Deposit Termurah, Judi Sabung Ayam Bonus 8x Win, Sabung Ayam Live Streaming, Judi Adu Ayam Online, Judi Sabung Ayam Online, Tembak Ikan Online Termurah, Game Ikan Deposit Termurah, Game Ikan Deposit Pulsa, Game Ikan Bonus Deposit, Game Ikan Dengan Jackpot Besar

    Judi Tembak Ikan Online

    bonus besar Sepak Bola

    Bandar judi Sepak Bola

    Judi Tembak Ikan Online

    bonus besar Sepak Bola

    Bandar judi Sepak Bola

    game online uang asli indonesia

    ReplyDelete
  20. Cheat Judi Online bisa memberikan keuntungan dengan cepat dan tentunya bisa membuat anda mendaptakan uang dengan mudah,jika anda berminat maka anda bisa mengunjungi blog dibawah ini.

    Aplikasi Hack Judi Online

    kunjungi juga blog dibawah ini


    info Game Online
    Perlu Menang
    informasi Judi Online
    Prediksi Togel Online


    ReplyDelete
  21. Trik Menang Judi QQ dengan Modal Sedikit http://martinadria92.arwebo.com/13405903/trik-menang-judi-qq-dengan-modal-sedikit yang terpercaya dan terbaik di badutqq saja.

    ReplyDelete
  22. Raih Untung Besar di Posisi Poker Online Terpercaya http://kartika93.arwebo.com/13429395/raih-untung-besar-di-posisi-poker-online-terpercaya yang terdapat pada babeqq online terbaik di Indonesia.

    ReplyDelete
  23. DEKAPOKER situs IDN Poker dengan Permainan game kartu yang lengkap seperti Judi poker online, dominoQQ, Capsa Susun, Ceme Online dan Ceme Keliling yang sangat di rekomendasikan untuk dimainkan menggunakan uang asli.

    ReplyDelete
  24. Join Bersama Website DominoQQ Online Terpercaya http://badut99.arwebo.com/13971100/join-bersama-website-dominoqq-online-terpercaya yang terbaik di BadutQQ online saja.

    ReplyDelete
  25. Taruhan Judi QQ Online Paling lengkap Dan Paling besar Di Indonesia http://99babeqq.arwebo.com/14117428/taruhan-judi-qq-online-paling-lengkap-dan-paling-besar-di-indonesia yang pastinya babeqq saja yang bisa memberikan hal tersebut.

    ReplyDelete
  26. mejaqq.com agen judi poker dominoqq bandarq online terbesar di asia

    Yang Merupakan Agen Judi Poker DominoQQ BandarQ Online Terbesar di Asia Hadir

    Untuk Anda Semua Dengan Games dan Bonus Yang Menarik!

    Bonus yang Kami Berikan di MEJAQQ :
    * Bonus CASHBACK 0,5% (Dibagikan setiap hari SENIN)
    * Bonus REFERRAL 10% + 10% SEUMUR HIDUP (Total kemenangan REFERRAL anda)
    * Minimal Deposit 20,000
    * Minimal Withdraw 20,000
    * 7 Bank Lokal (BCA, BNI, MANDIRI, BRI, DANAMON, CIMB NIAGA, PERMATA)
    * Deposit via E-Money, Pulsa XL dan TELKOMSEL
    * 100% Member vs Member
    * Pelayanan Bank dan Livechat 24 jam
    * Tersedia Dalam Aplikasi Android atau IOS.

    Mau dapet duit tanpa kerja? Bisa banget!
    Caranya? Buruan Kunjungi Sekarang Juga ^.^

    Info Lebih Lanjut :
    WA 1 : +855975482150
    WA 2 : +855978975095

    Kunjungi situs kami di :
    BandarQ Online
    Agen BandarQ Online

    BLOGSPOT :
    DUNIA VIRAL
    DUNIA MOVIE
    DUNIA GAME
    DUNIA ANIME

    ReplyDelete
  27. Buy Headphones at Cheapest Price with Amazing Quality

    https://seventysevenstyle.com/collections/wireless-products/products/nia-x5sp-headset-wireless-stereo-bluetooth-headphones-bluetooth-speakers-bluetooth-with-mic-yellow

    ReplyDelete
  28. Poker Online
    Letak Poker Online Terpercaya Letak Bermain Poker Online Terbaik http://idbadutqq.qowap.com/29484910/letak-poker-online-terpercaya-letak-bermain-poker-online-terbaik yang terbaik dan terpercaya di Indonesia.

    ReplyDelete
  29. This comment has been removed by the author.

    ReplyDelete
  30. bromo poker adalah situs poker online yang menyediakan permainan judi dewa poker 88. Link Alternatif Daftar dan Login Bromo Poker.

    panen poker merupakan situs judi idn poker terpercaya serta agen qq poker online terbaik resmi di Idonesia yang dapat dimainkan menggunakan asli.


    bromo poker

    panen poker

    ReplyDelete
  31. menghasilkan pendapatan tambahan dari internet telah dilakukan oleh sebagian besar orang dengan berbagai cara.

    ReplyDelete
  32. GRSoft Gaming is an honor winning, Live Casino game advancement organization of India. We offer curiosity and inventive game development with an exceptionally talented group of developer. Our bleeding edge gaming innovation creates esteem included gaming arrangements. Quality is our real worry for club game development. We offer tweaked Casino game development benefits over the globe and help you furnish with customized development. With our Casino game, individuals couldn't imagine anything better than to chance their gaining and appreciate the advantages. We have created numerous effective games like the video poker game, Sports wagering game, online club game, lottery games, and numerous other common games.

    Casino Games Software Developers UK, USA - Casino Game Development UK, USA

    ReplyDelete
  33. GRSoft Gaming is an honor winning, Live Casino game advancement organization of India. We offer curiosity and inventive game development with an exceptionally talented group of developer. Our bleeding edge gaming innovation creates esteem included gaming arrangements. Quality is our real worry for club game development. We offer tweaked Casino game development benefits over the globe and help you furnish with customized development. With our Casino game, individuals couldn't imagine anything better than to chance their gaining and appreciate the advantages. We have created numerous effective games like the video poker game, Sports wagering game, online club game, lottery games, and numerous other common games.

    Legacy Application Modernization India | Legacy Application Migration Services Company

    ReplyDelete
  34. Sakurapoker juga memberikan kemudahan bertransaksi seperti deposit 24 jam semua bank seperti bca, bni, mandiri, bri dan cimb. Semua transaksi akan diproses tanpa adanya jam offline, transaksi tidak akan diproses jika posisi bank sedang gangguan.

    Support Deposit Poker Online OVO, Gopay, Dana dan Link

    ReplyDelete
  35. instagram
    instagram login
    http://eshbrooklyn.com
    instagram video download
    instagram reels download
    instagram download
    instagram reels video download
    instagram story download
    instagram bio for girls
    instagram app
    instagram apk
    instagram account delete
    instagram autofree.in
    instagram account
    instagram appeal form
    instagram account delete permanently
    instagram apk download latest version
    instagram bio
    instagram bio for boys
    instagram blue tick
    instagram background
    instagram bio for girls attitude
    instagram bio for boys in hindi
    instagram blue tick copy
    instagram captions
    instagram captions for boys
    instagram captions for girls
    instagram customer care number
    instagram create new account
    instagram creator studio
    instagram customer care number india
    instagram contact number india
    instagram dp
    instagram download video
    instagram delete account
    instagram download for pc
    instagram download apk
    instagram delete
    instagram dp for girls
    instagram engagement rate
    instagram emoji
    instagram earnings
    instagram email id
    instagram engagement rate calculator
    instagram editing
    instagram emoji logo
    instagram email
    instagram followers
    instagram followers increase
    instagram fonts
    instagram followers hack
    instagram free followers
    instagram font style
    instagram for pc
    instagram forgot password
    instagram girls dp
    instagram girls name
    instagram girls bio
    instagram girls
    instagram group link
    instagram girl pic
    instagram gb
    instagram girls caption

    ReplyDelete
  36. Hasilkan uang andai di situs jagatslot yang berpusat di Indonesia https://45.142.212.203/

    ReplyDelete
  37. bandar togel online kingdomgrup sudah menjadi viral semenjak ppkm ini http://128.199.187.54/

    ReplyDelete
  38. semakin lama bermain bonus juga semakin bertambah, ayo segeralah bergabung disitus hkpools

    ReplyDelete
  39. dapatkan penghasilan tambahan disitus mpo slot.

    http://139.162.43.253/

    ReplyDelete