In [2]:
import random
from blackjack import Player, Dealer


def callback(subject, data):
    if subject == "decision":
        hand, dealer = data
        # VUL HIER JE EIGEN BESLISSINGSLOGICA IN
        # (DEZE EVENT MOET VERPLICHT EEN bool TERUGGEVEN!)
        return True
    elif subject == "card_seen":
        player, card = data
        # GEBRUIK DEZE EVENT EVENTUEEL OM DATA TE VERZAMELEN OVER
        # KAARTEN DIE AL 'GEWEEST' ZIJN
    elif subject == "result":
        result = data
        # GEBRUIK DEZE EVENT EVENTUEEL OM TE BEPALEN OF JE
        # WON OF VERLOOR
    elif subject == "message":
        message = data
        # GEBRUIK DEZE EVENT EVENTUEEL OM ZELF TE VOLGEN
        # WAT ER IN HET SPEL GEBEURT
        print(message)


# 1 speler experiment:
num_rounds = 10
players = []
players.append(
    Player(
        name="Player A",
        callback=callback
    )
)
dealer = Dealer(players)
for i in range(num_rounds):
    dealer.play_round()
    print()


Round starts
Player A got [Jd, Qh]
Dealer got 5c
Player A decided to stand
Dealer shows hand: [5c, Jh]
Dealer hand value = 15
Dealer hit, hand now: [5c, Jh, 10d]
Dealer hand value = 25
Dealer busted
Player A wins (reason: dealer busted)
Round ends

Round starts
Player A got [Qs, 8s]
Dealer got 4h
Player A decided to stand
Dealer shows hand: [4h, Jc]
Dealer hand value = 14
Dealer hit, hand now: [4h, Jc, 9s]
Dealer hand value = 23
Dealer busted
Player A wins (reason: dealer busted)
Round ends

Round starts
Player A got [9c, Kc]
Dealer got 9d
Player A decided to stand
Dealer shows hand: [9d, 4c]
Dealer hand value = 13
Dealer hit, hand now: [9d, 4c, 9h]
Dealer hand value = 22
Dealer busted
Player A wins (reason: dealer busted)
Round ends

Round starts
Player A got [Ks, As]
Dealer got 5s
Player A wins (reason: hit 21)
Round ends

Round starts
Player A got [6h, 2d]
Dealer got 4d
Player A decided to stand
Dealer shows hand: [4d, 3s]
Dealer hand value = 7
Dealer hit, hand now: [4d, 3s, 3c]
Dealer hand value = 10
Dealer hit, hand now: [4d, 3s, 3c, Ac]
Dealer hand value = 21
Dealer stands
Player A loses (reason: dealer 21 vs player 8)
Round ends

Round starts
Player A got [6s, 8d]
Dealer got 8c
Player A decided to hit, hand now: [6s, 8d, 10c]
Player A loses (reason: busted)
Round ends

Round starts
Player A got [7s, 10h]
Dealer got Ad
Player A decided to stand
Dealer shows hand: [Ad, 7c]
Dealer hand value = 18
Dealer stands
Player A loses (reason: dealer 18 vs player 17)
Round ends

Round starts
Player A got [Js, 4s]
Dealer got 2s
Player A decided to stand
Dealer shows hand: [2s, Kd]
Dealer hand value = 12
Dealer hit, hand now: [2s, Kd, Kh]
Dealer hand value = 22
Dealer busted
Player A wins (reason: dealer busted)
Round ends

Round starts
Player A got [3h, 7d]
Dealer got 5d
Player A decided to hit, hand now: [3h, 7d, 7h]
Player A decided to hit, hand now: [3h, 7d, 7h, Qd]
Player A loses (reason: busted)
Round ends

Round starts
Player A got [10s, 3d]
Dealer got Ah
Player A decided to hit, hand now: [10s, 3d, 6d]
Player A decided to stand
Dealer shows hand: [Ah, 5h]
Dealer hand value = 16
Dealer hit, hand now: [Ah, 5h, 6c]
Dealer hand value = 12
Dealer hit, hand now: [Ah, 5h, 6c, 8h]
Dealer hand value = 20
Dealer stands
Player A loses (reason: dealer 20 vs player 19)
Round ends


In [ ]: