diff --git a/chris_demo/__pycache__/card.cpython-311.pyc b/chris_demo/__pycache__/card.cpython-311.pyc new file mode 100644 index 0000000..265273c Binary files /dev/null and b/chris_demo/__pycache__/card.cpython-311.pyc differ diff --git a/chris_demo/__pycache__/dealer.cpython-311.pyc b/chris_demo/__pycache__/dealer.cpython-311.pyc new file mode 100644 index 0000000..fc31f69 Binary files /dev/null and b/chris_demo/__pycache__/dealer.cpython-311.pyc differ diff --git a/chris_demo/__pycache__/deck.cpython-311.pyc b/chris_demo/__pycache__/deck.cpython-311.pyc new file mode 100644 index 0000000..8c98c70 Binary files /dev/null and b/chris_demo/__pycache__/deck.cpython-311.pyc differ diff --git a/chris_demo/dealer.py b/chris_demo/dealer.py index 88cbb78..e92a9a9 100644 --- a/chris_demo/dealer.py +++ b/chris_demo/dealer.py @@ -44,6 +44,7 @@ class Dealer: self.deal_card_to_player() game.state["score"] = self.get_player_score() + def set_up_new_round(self, game): self.deck = Deck(self.position) for agent in self.deck.get_agents(): @@ -81,6 +82,8 @@ class Dealer: return (x + 4 * len(self.dealer_cards), y) def get_player_score(self): + """if score >21 set A va """ + return sum([card.value() for card in self.player_cards]) def end_round(self, game): diff --git a/chris_demo/game.py b/chris_demo/game.py index 4580853..0492ce0 100644 --- a/chris_demo/game.py +++ b/chris_demo/game.py @@ -1,11 +1,20 @@ from retro.game import Game from dealer import Dealer +import json -dealer = Dealer((1, 1)) -state = { +def play(): + dealer = Dealer((1, 1)) + state = { "score": 0, - "options": "h to hit or s to stay", -} -game = Game([dealer], state) -game.play() + "options": "H to hit or F to stay", + } + game = Game([dealer], state) + game.play() + + with open("result.json") as result_file: + json.dump(game.state) + +if __name__ == '__main__': + play() +