|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
import dataclasses
|
|
|
|
|
import pprint
|
|
|
|
|
import sys
|
|
|
|
|
import typing
|
|
|
|
@ -8,15 +9,6 @@ import typing
|
|
|
|
|
import cards
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Player:
|
|
|
|
|
hand: typing.Set[cards.Card]
|
|
|
|
|
captured: typing.Set[cards.Card]
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def score(self):
|
|
|
|
|
return len(self.captured)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
|
|
|
@ -33,25 +25,41 @@ def main():
|
|
|
|
|
)
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
for turn in _simulate_game(
|
|
|
|
|
player_count=args.player_count, turn_count=args.turn_count
|
|
|
|
|
):
|
|
|
|
|
_show_turn(turn)
|
|
|
|
|
|
|
|
|
|
Hyrule(player_count=args.player_count, turn_count=args.turn_count).play()
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _simulate_game(player_count=2, turn_count=5):
|
|
|
|
|
for turn in range(turn_count):
|
|
|
|
|
yield _simulate_turn(player_count=player_count)
|
|
|
|
|
@dataclasses.dataclass
|
|
|
|
|
class Player:
|
|
|
|
|
index: int
|
|
|
|
|
hand: typing.Set[cards.Card]
|
|
|
|
|
captured: typing.Set[cards.Card]
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def score(self):
|
|
|
|
|
return len(self.captured)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Hyrule:
|
|
|
|
|
def __init__(self, player_count=2, turn_count=5):
|
|
|
|
|
self._players = [
|
|
|
|
|
Player(index=i, hand=set(), captured=set()) for i in range(player_count)
|
|
|
|
|
]
|
|
|
|
|
self._turn_count = turn_count
|
|
|
|
|
|
|
|
|
|
def play(self):
|
|
|
|
|
for turn in self._each_turn():
|
|
|
|
|
self._show_turn(turn)
|
|
|
|
|
|
|
|
|
|
def _simulate_turn(player_count=2):
|
|
|
|
|
...
|
|
|
|
|
def _each_turn(self):
|
|
|
|
|
for turn_number in range(self._turn_count):
|
|
|
|
|
yield self._simulate_turn(turn_number)
|
|
|
|
|
|
|
|
|
|
def _simulate_turn(self, turn_number):
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
def _show_turn(turn):
|
|
|
|
|
...
|
|
|
|
|
def _show_turn(self, turn):
|
|
|
|
|
print(turn)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|