def _simulate_games(self, players, reps): log.info("players: %s; %s reps", players, reps) mmRules = rules.MauMau() games = [] for i in range(reps): game = play.play_game(mmRules, players) games.append(game) return games
#!/usr/bin/env python3 """ This module gives simple command line access to the functions. Start it without parameters to run a simple game. Start it with one of the functions in stat.py to run simulations and get stats. """ import logging import sys from mau_mau import rules, play, stats log = logging.getLogger() _rulesOfTheGame = rules.MauMau() def play_simple_game(players=3): log.setLevel(level=logging.DEBUG) playedGame = play.play_game(_rulesOfTheGame, players) log.info("And the winner is %s", playedGame.table.winner.name) def play_interactive_game(): log.setLevel(level=logging.DEBUG) playedGame = play.play_game(_rulesOfTheGame, ['Eric', 'John', 'human']) log.info("And the winner is %s", playedGame.table.winner.name) def get_function_from_name(name): if not name:
import pytest from mau_mau import rules, play from mau_mau.constants import DECK from mau_mau.subjects import Croupier mmRules = rules.MauMau() def test_game_with_too_many_players_crashes_early(): deckSize = len([(v, s) for v in DECK.VALUES for s in DECK.SUITS]) tooManyPlayers = deckSize // mmRules.cardsPerPlayer + 2 with pytest.raises(AssertionError): play.play_game(mmRules, tooManyPlayers) def test_game_with_one_player_crashes_early(): with pytest.raises(AssertionError): play.play_game(mmRules, 1) def test_game_with_default_amount_of_players_succeeds(): play.play_game(mmRules, 3) def test_invite_players_with_names_invites_right_amount(): names = ['a', 'b', 'c', 'd'] players = Croupier._create_real_players(names) assert len(players) == len(names) assert [p.name for p in players] == names
def __init__(self): self.rules = rules.MauMau()