Run the multiplayer game. Returns: Tuple[List[str], List[int], List[str]]: (players, scores, winners) Example: >>> import builtins, random >>> random.seed(2) >>> inputs = iter(["1", "Eve", "30", "13"]) >>> builtins.input = lambda prompt="": next
()
| 79 | |
| 80 | |
| 81 | def play_game() -> Tuple[List[str], List[int], List[str]]: |
| 82 | """ |
| 83 | Run the multiplayer game. |
| 84 | |
| 85 | Returns: |
| 86 | Tuple[List[str], List[int], List[str]]: (players, scores, winners) |
| 87 | |
| 88 | Example: |
| 89 | >>> import builtins, random |
| 90 | >>> random.seed(2) |
| 91 | >>> inputs = iter(["1", "Eve", "30", "13"]) |
| 92 | >>> builtins.input = lambda prompt="": next(inputs) |
| 93 | >>> players, scores, winners = play_game() |
| 94 | >>> players |
| 95 | ['Eve'] |
| 96 | >>> scores # doctest: +ELLIPSIS |
| 97 | [2] |
| 98 | >>> winners |
| 99 | ['Eve'] |
| 100 | """ |
| 101 | n = int(input("Enter number of players: ")) |
| 102 | players = get_players(n) |
| 103 | scores = [play_turn(p) for p in players] |
| 104 | min_score = min(scores) |
| 105 | winners = [p for p, s in zip(players, scores) if s == min_score] |
| 106 | print("\nResults:") |
| 107 | for p, s in zip(players, scores): |
| 108 | print(f"{p}: {s} attempts") |
| 109 | print("\nWinner(s):", ", ".join(winners)) |
| 110 | return players, scores, winners |
| 111 | |
| 112 | |
| 113 | if __name__ == "__main__": |
no test coverage detected