<jupyter_start><jupyter_text>Eerst even de python module voor websockets installeren<jupyter_code>pip install websocket-client<jupyter_output>Usage:   
  /home/sebas/anaconda3/bin/python -m pip install [options] <requirement specifier> [package-index-options] ...
  /home/sebas/anaconda3/bin/python -m pip install [options] -r <requirements file> [package-index-options] ...
  /home/sebas/anaconda3/bin/python -m pip install [options] [-e] <vcs project url> ...
  /home/sebas/anaconda3/bin/python -m pip install [options] [-e] <local project path> ...
  /home/sebas/anaconda3/bin/python -m pip install [options] <archive url/path> ...

no such option: -y
Note: you may need to restart the kernel to use updated packages.<jupyter_text>Imports die we gaan gebruiken<jupyter_code>import json
from random import random
from websocket import create_connection
# maak verbinding met de server
ws = create_connection("ws://ws.sebastiaanvermeulen.nl/pokerroom")

# vraag om aan een tafel te mogen zitten
ws.send(json.dumps({"Table":{"n_players":1,"small_blind":1,"big_blind":2,"stack":40,"game_type":"NoLimit"}}))

print("--------- going to play until > 1000 messages --------")
for _ in range(1000):
    
    # ontvang een JSON-bericht van de server en maak er een Python dictionary van
    message = json.loads(ws.recv())
    print(message)
    
    # Indien de server een reactie verwacht:
    if 'RequestAction' in message:        
        # random response
        rand = random() # uniform [0,1)
        if rand < .5:
            response = json.dumps({'Action':'Call'})
        elif rand < .7:
            response = json.dumps({'Action':{'Raise':2}})
        else:
            response = json.dumps({'Action':'Fold'})
        print(response)
        
        # stuur de reactie naar de server
        ws.send(response)
        
print("--------- hanging up --------")
ws.close()<jupyter_output>--------- going to play until >1000 messages --------
GameOver
{'Hole': {'player': 0, 'cards': [{'rank': 12, 'suit': 'Clubs'}, {'rank': 2, 'suit': 'Diamonds'}]}}
{'RequestAction': {'player': 0, 'bets': [0], 'pot': 0}}
{"Action": "Call"}
{'Flop': [{'rank': 13, 'suit': 'Hearts'}, {'rank': 2, 'suit': 'Spades'}, {'rank': 4, 'suit': 'Hearts'}]}
{'RequestAction': {'player': 0, 'bets': [0], 'pot': 0}}
{"Action": {"Raise": 2}}
{'River': {'rank': 14, 'suit': 'Diamonds'}}
{'RequestAction': {'player': 0, 'bets': [0], 'pot': 2}}
{"Action": "Call"}
{'Turn': {'rank': 3, 'suit': 'Diamonds'}}
{'RequestAction': {'player': 0, 'bets': [0], 'pot': 2}}
{"Action": "Fold"}
{'Showdown': {'score': {'royal_flush': False, 'straight_flush': 0, 'four_of_a_kind': 0, 'full_house': [0, 0], 'flush': 0, 'straight': 0, 'three_of_a_kind': 0, 'two_pair': [0, 0], 'one_pair': 0, 'high_card': [0, 0, 0, 0, 0]}, 'pot': 2, 'players': [0], 'stacks': [40]}}
GameOver
{'Hole': {'player': 0, 'cards': [{'rank': 11, 'suit': 'Hearts'},[...]
{'fraction_non_alphanumeric': 0.21428571428571427, 'fraction_numerical': 0.025189786059351276, 'mean_word_length': 3.7524590163934426, 'pattern_counts': {'":': 11, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '634233', 'license': 'MIT', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1017, 'n_words': 286, 'path': 'minimalist-poker-player.ipynb', 'repo_name': 'sebasv/pokerroom', 'size': '2898'}