diff --git a/proj/hog/assets/icon.gif b/proj/hog/assets/icon.gif deleted file mode 100644 index ad5722c42..000000000 Binary files a/proj/hog/assets/icon.gif and /dev/null differ diff --git a/proj/hog/default_graphics.py b/proj/hog/default_graphics.py deleted file mode 100644 index 086b5d5f7..000000000 --- a/proj/hog/default_graphics.py +++ /dev/null @@ -1,74 +0,0 @@ -# Default dice for the Hog game. These can be overriden by students. - -dice = [ - "", - """ - - - - - - - - """, - """ - - - - - - - - - """, - """ - - - - - - - - - - """, - """ - - - - - - - - - - - """, - """ - - - - - - - - - - - - """, - """ - - - - - - - - - - - - - """, -] \ No newline at end of file diff --git a/proj/hog/dice.py b/proj/hog/dice.py deleted file mode 100644 index e7597e492..000000000 --- a/proj/hog/dice.py +++ /dev/null @@ -1,53 +0,0 @@ -"""Functions that simulate dice rolls. - -A dice function takes no arguments and returns a number from 1 to n -(inclusive), where n is the number of sides on the dice. - -Fair dice produce each possible outcome with equal probability. -Two fair dice are already defined, four_sided and six_sided, -and are generated by the make_fair_dice function. - -Test dice are deterministic: they always cycles through a fixed -sequence of values that are passed as arguments. -Test dice are generated by the make_test_dice function. -""" - -from random import randint - -def make_fair_dice(sides): - """Return a die that returns 1 to SIDES with equal chance.""" - assert type(sides) == int and sides >= 1, 'Illegal value for sides' - def dice(): - return randint(1,sides) - return dice - -four_sided = make_fair_dice(4) -six_sided = make_fair_dice(6) - -def make_test_dice(*outcomes): - """Return a die that cycles deterministically through OUTCOMES. - - >>> dice = make_test_dice(1, 2, 3) - >>> dice() - 1 - >>> dice() - 2 - >>> dice() - 3 - >>> dice() - 1 - >>> dice() - 2 - - This function uses Python syntax/techniques not yet covered in this course. - The best way to understand it is by reading the documentation and examples. - """ - assert len(outcomes) > 0, 'You must supply outcomes to make_test_dice' - for o in outcomes: - assert type(o) == int and o >= 1, 'Outcome is not a positive integer' - index = len(outcomes) - 1 - def dice(): - nonlocal index - index = (index + 1) % len(outcomes) - return outcomes[index] - return dice \ No newline at end of file diff --git a/proj/hog/fuss.png b/proj/hog/fuss.png deleted file mode 100644 index 773eee432..000000000 Binary files a/proj/hog/fuss.png and /dev/null differ diff --git a/proj/hog/hog.py b/proj/hog/hog.py deleted file mode 100644 index b31513321..000000000 --- a/proj/hog/hog.py +++ /dev/null @@ -1,301 +0,0 @@ -"""The Game of Hog.""" - -from dice import six_sided, make_test_dice -from ucb import main, trace, interact - -GOAL = 100 # The goal of Hog is to score 100 points. - -###################### -# Phase 1: Simulator # -###################### - - -def roll_dice(num_rolls, dice=six_sided): - """Simulate rolling the DICE exactly NUM_ROLLS > 0 times. Return the sum of - the outcomes unless any of the outcomes is 1. In that case, return 1. - - num_rolls: The number of dice rolls that will be made. - dice: A function that simulates a single dice roll outcome. Defaults to the six sided dice. - """ - # These assert statements ensure that num_rolls is a positive integer. - assert type(num_rolls) == int, 'num_rolls must be an integer.' - assert num_rolls > 0, 'Must roll at least once.' - # BEGIN PROBLEM 1 - "*** YOUR CODE HERE ***" - # END PROBLEM 1 - - -def boar_brawl(player_score, opponent_score): - """Return the points scored by rolling 0 dice according to Boar Brawl. - - player_score: The total score of the current player. - opponent_score: The total score of the other player. - - """ - # BEGIN PROBLEM 2 - "*** YOUR CODE HERE ***" - # END PROBLEM 2 - - -def take_turn(num_rolls, player_score, opponent_score, dice=six_sided): - """Return the points scored on a turn rolling NUM_ROLLS dice when the - player has PLAYER_SCORE points and the opponent has OPPONENT_SCORE points. - - num_rolls: The number of dice rolls that will be made. - player_score: The total score of the current player. - opponent_score: The total score of the other player. - dice: A function that simulates a single dice roll outcome. - """ - # Leave these assert statements here; they help check for errors. - assert type(num_rolls) == int, 'num_rolls must be an integer.' - assert num_rolls >= 0, 'Cannot roll a negative number of dice in take_turn.' - assert num_rolls <= 10, 'Cannot roll more than 10 dice.' - # BEGIN PROBLEM 3 - "*** YOUR CODE HERE ***" - # END PROBLEM 3 - - -def simple_update(num_rolls, player_score, opponent_score, dice=six_sided): - """Return the total score of a player who starts their turn with - PLAYER_SCORE and then rolls NUM_ROLLS DICE, ignoring Sus Fuss. - """ - score = player_score + take_turn(num_rolls, player_score, opponent_score, dice) - return score - -def is_prime(n): - """Return whether N is prime.""" - if n == 1: - return False - k = 2 - while k < n: - if n % k == 0: - return False - k += 1 - return True - -def num_factors(n): - """Return the number of factors of N, including 1 and N itself.""" - # BEGIN PROBLEM 4 - "*** YOUR CODE HERE ***" - # END PROBLEM 4 - -def sus_points(score): - """Return the new score of a player taking into account the Sus Fuss rule.""" - # BEGIN PROBLEM 4 - "*** YOUR CODE HERE ***" - # END PROBLEM 4 - -def sus_update(num_rolls, player_score, opponent_score, dice=six_sided): - """Return the total score of a player who starts their turn with - PLAYER_SCORE and then rolls NUM_ROLLS DICE, *including* Sus Fuss. - """ - # BEGIN PROBLEM 4 - "*** YOUR CODE HERE ***" - # END PROBLEM 4 - - -def always_roll_5(score, opponent_score): - """A strategy of always rolling 5 dice, regardless of the player's score or - the opponent's score. - """ - return 5 - - -def play(strategy0, strategy1, update, - score0=0, score1=0, dice=six_sided, goal=GOAL): - """Simulate a game and return the final scores of both players, with - Player 0's score first and Player 1's score second. - - E.g., play(always_roll_5, always_roll_5, sus_update) simulates a game in - which both players always choose to roll 5 dice on every turn and the Sus - Fuss rule is in effect. - - A strategy function, such as always_roll_5, takes the current player's - score and their opponent's score and returns the number of dice the current - player chooses to roll. - - An update function, such as sus_update or simple_update, takes the number - of dice to roll, the current player's score, the opponent's score, and the - dice function used to simulate rolling dice. It returns the updated score - of the current player after they take their turn. - - strategy0: The strategy for player0. - strategy1: The strategy for player1. - update: The update function (used for both players). - score0: Starting score for Player 0 - score1: Starting score for Player 1 - dice: A function of zero arguments that simulates a dice roll. - goal: The game ends and someone wins when this score is reached. - """ - who = 0 # Who is about to take a turn, 0 (first) or 1 (second) - # BEGIN PROBLEM 5 - "*** YOUR CODE HERE ***" - # END PROBLEM 5 - return score0, score1 - - -####################### -# Phase 2: Strategies # -####################### - - -def always_roll(n): - """Return a player strategy that always rolls N dice. - - A player strategy is a function that takes two total scores as arguments - (the current player's score, and the opponent's score), and returns a - number of dice that the current player will roll this turn. - - >>> strategy = always_roll(3) - >>> strategy(0, 0) - 3 - >>> strategy(99, 99) - 3 - """ - assert n >= 0 and n <= 10 - # BEGIN PROBLEM 6 - "*** YOUR CODE HERE ***" - # END PROBLEM 6 - - -def catch_up(score, opponent_score): - """A player strategy that always rolls 5 dice unless the opponent - has a higher score, in which case 6 dice are rolled. - - >>> catch_up(9, 4) - 5 - >>> strategy(17, 18) - 6 - """ - if score < opponent_score: - return 6 # Roll one more to catch up - else: - return 5 - - -def is_always_roll(strategy, goal=GOAL): - """Return whether STRATEGY always chooses the same number of dice to roll - given a game that goes to GOAL points. - - >>> is_always_roll(always_roll_5) - True - >>> is_always_roll(always_roll(3)) - True - >>> is_always_roll(catch_up) - False - """ - # BEGIN PROBLEM 7 - "*** YOUR CODE HERE ***" - # END PROBLEM 7 - - -def make_averaged(original_function, times_called=1000): - """Return a function that returns the average value of ORIGINAL_FUNCTION - called TIMES_CALLED times. - - To implement this function, you will have to use *args syntax. - - >>> dice = make_test_dice(4, 2, 5, 1) - >>> averaged_dice = make_averaged(roll_dice, 40) - >>> averaged_dice(1, dice) # The avg of 10 4's, 10 2's, 10 5's, and 10 1's - 3.0 - """ - # BEGIN PROBLEM 8 - "*** YOUR CODE HERE ***" - # END PROBLEM 8 - - -def max_scoring_num_rolls(dice=six_sided, times_called=1000): - """Return the number of dice (1 to 10) that gives the maximum average score for a turn. - Assume that the dice always return positive outcomes. - - >>> dice = make_test_dice(1, 6) - >>> max_scoring_num_rolls(dice) - 1 - """ - # BEGIN PROBLEM 9 - "*** YOUR CODE HERE ***" - # END PROBLEM 9 - - -def winner(strategy0, strategy1): - """Return 0 if strategy0 wins against strategy1, and 1 otherwise.""" - score0, score1 = play(strategy0, strategy1, sus_update) - if score0 > score1: - return 0 - else: - return 1 - - -def average_win_rate(strategy, baseline=always_roll(6)): - """Return the average win rate of STRATEGY against BASELINE. Averages the - winrate when starting the game as player 0 and as player 1. - """ - win_rate_as_player_0 = 1 - make_averaged(winner)(strategy, baseline) - win_rate_as_player_1 = make_averaged(winner)(baseline, strategy) - - return (win_rate_as_player_0 + win_rate_as_player_1) / 2 - - -def run_experiments(): - """Run a series of strategy experiments and report results.""" - six_sided_max = max_scoring_num_rolls(six_sided) - print('Max scoring num rolls for six-sided dice:', six_sided_max) - - print('always_roll(6) win rate:', average_win_rate(always_roll(6))) # near 0.5 - print('catch_up win rate:', average_win_rate(catch_up)) - print('always_roll(3) win rate:', average_win_rate(always_roll(3))) - print('always_roll(8) win rate:', average_win_rate(always_roll(8))) - - print('boar_strategy win rate:', average_win_rate(boar_strategy)) - print('sus_strategy win rate:', average_win_rate(sus_strategy)) - print('final_strategy win rate:', average_win_rate(final_strategy)) - "*** You may add additional experiments as you wish ***" - - - -def boar_strategy(score, opponent_score, threshold=11, num_rolls=6): - """This strategy returns 0 dice if Boar Brawl gives at least THRESHOLD - points, and returns NUM_ROLLS otherwise. Ignore score and Sus Fuss. - """ - # BEGIN PROBLEM 10 - return num_rolls # Remove this line once implemented. - # END PROBLEM 10 - - -def sus_strategy(score, opponent_score, threshold=11, num_rolls=6): - """This strategy returns 0 dice when your score would increase by at least threshold.""" - # BEGIN PROBLEM 11 - return num_rolls # Remove this line once implemented. - # END PROBLEM 11 - - -def final_strategy(score, opponent_score): - """Write a brief description of your final strategy. - - *** YOUR DESCRIPTION HERE *** - """ - # BEGIN PROBLEM 12 - return 6 # Remove this line once implemented. - # END PROBLEM 12 - - -########################## -# Command Line Interface # -########################## - -# NOTE: The function in this section does not need to be changed. It uses -# features of Python not yet covered in the course. - -@main -def run(*args): - """Read in the command-line argument and calls corresponding functions.""" - import argparse - parser = argparse.ArgumentParser(description="Play Hog") - parser.add_argument('--run_experiments', '-r', action='store_true', - help='Runs strategy experiments') - - args = parser.parse_args() - - if args.run_experiments: - run_experiments() \ No newline at end of file diff --git a/proj/hog/hog.zip b/proj/hog/hog.zip deleted file mode 100644 index ed75e73df..000000000 Binary files a/proj/hog/hog.zip and /dev/null differ diff --git a/proj/hog/hog_gui.py b/proj/hog/hog_gui.py deleted file mode 100644 index a3c3fc9c7..000000000 --- a/proj/hog/hog_gui.py +++ /dev/null @@ -1,156 +0,0 @@ -"""Web server for the hog GUI.""" -import io -import os -import logging -from contextlib import redirect_stdout - -from gui_files.common_server import route, start - -import hog -import dice -import default_graphics - -PORT = 31415 -DEFAULT_SERVER = "https://hog.cs61a.org" -GUI_FOLDER = "gui_files/" -PATHS = {} - - -class HogLoggingException(Exception): - pass - - -@route -def take_turn(prev_rolls, move_history, goal, game_rules): - """Simulate the whole game up to the current turn.""" - fair_dice = dice.make_fair_dice(6) - dice_results = [] - - sus_fuss = game_rules["Sus Fuss"] - - def logged_dice(): - if len(dice_results) < len(prev_rolls): - out = prev_rolls[len(dice_results)] - else: - out = fair_dice() - dice_results.append(out) - return out - - final_scores = None - who = 0 - - move_cnt = 0 - - def strategy_for(player): - def strategy(*scores): - nonlocal final_scores, move_cnt, who - final_scores = scores - if player: - final_scores = final_scores[::-1] - who = player - if move_cnt == len(move_history): - raise HogLoggingException() - move = move_history[move_cnt] - move_cnt += 1 - return move - - return strategy - - game_over = False - - try: - final_scores = trace_play( - hog.play, - strategy_for(0), - strategy_for(1), - hog.sus_update if sus_fuss else hog.simple_update, - 0, - 0, - dice=logged_dice, - goal=goal, - )[:2] - except HogLoggingException: - pass - else: - game_over = True - - return { - "rolls": dice_results, - "finalScores": final_scores, - "message": "", - "gameOver": game_over, - "who": who, - } - - -@route -def strategy(name, scores): - STRATEGIES = { - "boar_strategy": hog.boar_strategy, - "sus_strategy": hog.sus_strategy, - "final_strategy": hog.final_strategy, - } - return STRATEGIES[name](*scores[::-1]) - - -@route("dice_graphic.svg") -def draw_dice_graphic(num): - num = int(num[0]) - # Either draw student-provided dice or our default dice - if hasattr(hog, "draw_dice"): - graphic = hog.draw_dice(num) - return str(graphic) - return default_graphics.dice[num] - - -def trace_play(play, strategy0, strategy1, update, score0, score1, dice, goal): - """Wraps the user's play function and - (1) ensures that strategy0 and strategy1 are called exactly once per turn - (2) records the entire game, returning the result as a list of dictionaries, - each with keys "s0_start", "s1_start", "who", "num_dice", "dice_values" - Returns (s0, s1, trace) where s0, s1 are the return values from play and trace - is the trace as specified above. - This might seem a bit overcomplicated but it will also used to create the game - traces for the fuzz test (when run against the staff solution). - """ - game_trace = [] - - def mod_strategy(who, my_score, opponent_score): - if game_trace: - prev_total_score = game_trace[-1]["s0_start"] + game_trace[-1]["s1_start"] - if prev_total_score == my_score + opponent_score: - # game is still on last turn since the total number of points - # goes up every turn - return game_trace[-1]["num_dice"] - current_num_dice = (strategy0, strategy1)[who](my_score, opponent_score) - current_turn = { - "s0_start": [my_score, opponent_score][who], - "s1_start": [my_score, opponent_score][1 - who], - "who": who, - "num_dice": current_num_dice, - "dice_values": [], # no dice rolled yet - } - game_trace.append(current_turn) - return current_num_dice - - def mod_dice(): - roll = dice() - if not game_trace: - raise RuntimeError("roll_dice called before either strategy function") - game_trace[-1]["dice_values"].append(roll) - return roll - - s0, s1 = play( - lambda a, b: mod_strategy(0, a, b), - lambda a, b: mod_strategy(1, a, b), - update, - score0, - score1, - dice=mod_dice, - goal=goal, - ) - return s0, s1, game_trace - - -if __name__ == "__main__" or "gunicorn" in os.environ.get("SERVER_SOFTWARE", ""): - app = start(PORT, DEFAULT_SERVER, GUI_FOLDER) \ No newline at end of file diff --git a/proj/hog/hog_ui.py b/proj/hog/hog_ui.py deleted file mode 100644 index 18e189f08..000000000 --- a/proj/hog/hog_ui.py +++ /dev/null @@ -1,131 +0,0 @@ -##################################### -# Optional: Adding a User Interface # -##################################### - -from hog import * - -######################## -# Printing game events # -######################## - - -def play_and_print(strategy0, strategy1): - """Simulate a game and print out what happened during the simulation.""" - final0, final1 = play(printing_strategy(0, strategy0), - printing_strategy(1, strategy1), - sus_update_and_print, 0, 0, - printing_dice(six_sided)) - print('The final score is Player 0:', final0, 'vs Player 1:', final1) - - -def printing_strategy(who, strategy): - """Return a strategy that also prints the player's score and choice. - - (This could print "rolls 1 dice..." which is ungrammatical, but that's ok.) - - >>> strategy0 = printing_strategy(0, always_roll_5) - >>> strategy0(10, 20) - The score is 10 to 20 and Player 0 rolls 5 dice... - 5 - >>> strategy1 = printing_strategy(1, always_roll_5) - >>> strategy1(8, 16) - The score is 16 to 8 and Player 1 rolls 5 dice... - 5 - """ - assert who == 0 or who == 1, 'the player must be 0 or 1' - - def choose_and_print(score, opponent_score): - "A strategy function that also prints." - if who == 0: - score0, score1 = score, opponent_score - else: - score0, score1 = opponent_score, score - num_rolls = strategy(score, opponent_score) - print('The score is', score0, 'to', score1, 'and Player', who, - 'rolls', num_rolls, 'dice...') - return num_rolls - return choose_and_print - - -def printing_dice(dice): - """Return a dice function that also prints the outcome and a space.""" - def dice_and_print(): - "A dice function that also prints." - outcome = dice() - print(outcome, end=' ') - return outcome - return dice_and_print - - -def sus_update_and_print(num_rolls, player_score, opponent_score, dice): - """Return the updated score, print out the score update, and print when - Sus Fuss is triggered. - - >>> d = printing_dice(make_test_dice(4, 5, 3)) - >>> sus_update_and_print(3, 9, 99, d) - [ 4 5 3 ] => 12; 9 + 12 = 21 triggering **Sus Fuss**, increasing to 23 - 23 - """ - print(' [', end=" ") - turn_score = take_turn(num_rolls, player_score, opponent_score, dice) # Prints dice outcomes - print('] =>', turn_score, end='; ') - print(player_score, '+', turn_score, '=', player_score + turn_score, end='') - score = turn_score + player_score - sus_score = sus_points(score) - if sus_score != score: - score = sus_score - print(' triggering **Sus Fuss**, increasing to', score) - else: - print() # This print completes the line without adding any additional text - return score - - -######################## -# Accepting User Input # -######################## - - -def get_int(prompt, lower, upper): - """Return an integer i such that i >= lower and i <= upper.""" - choice = input(prompt) - while not choice.isnumeric() or int(choice) < lower or int(choice) > upper: - print('Please enter an integer from', lower, 'to', upper) - choice = input(prompt) - return int(choice) - - -def interactive_strategy(who): - """Return a strategy for which the user provides the number of rolls.""" - def strategy(score, opponent_score): - print('Player', who, ', you have', score, 'and your opponent has', opponent_score) - choice = get_int('How many dice will you roll? ', 0, 10) - return choice - return strategy - - -#################### -# Playing the game # -#################### - - -def play_with(num_players): - """Play a game with NUM_PLAYERS interactive (human) players.""" - if num_players == 0: - play_and_print(always_roll_5, always_roll_5) - elif num_players == 1: - play_and_print(interactive_strategy(0), always_roll_5) - elif num_players == 2: - play_and_print(interactive_strategy(0), interactive_strategy(1)) - else: - print('num_players must be 0, 1, or 2.') - - -@main -def run(*args): - """Select number of players and play a game.""" - import argparse - parser = argparse.ArgumentParser(description="Play Hog") - parser.add_argument('--num_players', '-n', type=int, default=0, - help='How many interactive players (0, 1, or 2)') - args = parser.parse_args() - play_with(args.num_players) \ No newline at end of file diff --git a/proj/hog/index.html b/proj/hog/index.html deleted file mode 100644 index 0df90a290..000000000 --- a/proj/hog/index.html +++ /dev/null @@ -1,1634 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The Game of Hog | CS 61A Fall 2024 - - - - - - -
- -
-
-
-

- -The Game of Hog - - - - - - -

-
- -
-

5-sided die

- - I know! I'll use my
Higher-order functions to
Order higher -rolls.
-
- - - -

Introduction

- - -

Important submission note: For full credit:

- -
    -
  • Submit with Phase 1 complete by Thursday 09/12, worth 1 pt.
  • -
  • Submit the complete project by Thursday 09/19.
  • -
- -

Try to attempt the problems in order, as some later problems will depend on -earlier problems in their implementation and therefore also when running ok -tests.

- -

You may complete the project with a partner.

- -

You can get 1 bonus point by submitting the entire project by Wednesday 09/18. -You can receive extensions on the project deadline and checkpoint -deadline, but not on the early deadline, unless you're a DSP student with an -accommodation for assignment extensions.

- -

In this project, you will develop a simulator and multiple strategies for the -dice game Hog. You will need to use control statements and higher-order -functions together, as described in Sections 1.2 through 1.6 of Composing -Programs, the online textbook.

- -

When students in the past have tried to implement the functions without -thoroughly reading the problem description, they’ve often run into issues. -😱 -Read each description thoroughly before starting to code.

- - -

Rules

- - -

In Hog, two players alternate turns trying to be the first to end a turn with -at least GOAL total points, where GOAL defaults to 100. On each turn, the current player chooses some number -of dice to roll together, up to 10. That player's score for the turn is the sum of the -dice outcomes. However, a player who rolls too many dice risks:

- -
    -
  • Sow Sad. If any of the dice outcomes is a 1, the current player's score - for the turn is 1, regardless of the other values rolled.
  • -
- - - -
- -
    -
  • Example 1: The current player rolls 7 dice, 5 of which are 1's. They - score 1 point for the turn.
  • -
  • Example 2: The current player rolls 4 dice, all of which are 3's. Since - Sow Sad did not occur, they score 12 points for the turn.
  • -
- -
- -

In a normal game of Hog, those are all the rules. To spice up the game, we'll -include some special rules:

- -
    -
  • Boar Brawl. A player who chooses to roll zero dice scores three times - the absolute difference between the tens digit of the opponent’s score and - the ones digit of the current player’s score, or 1, whichever is greater. - The ones digit refers to the rightmost digit and the tens digit refers to - the second-rightmost digit. If a player's score is a single digit (less than - 10), the tens digit of that player's score is 0.
  • -
- - - -
- -
    -
  • Example 1:

    - -
      -
    • The current player has 21 points and the opponent has 46 points, and the current player - chooses to roll zero dice.
    • -
    • The tens digit of the opponent's score is 4 and the ones digit of the current player's score is 1.
    • -
    • Therefore, the player gains 3 * abs(4 - 1) = 9 points.
    • -
  • -
  • Example 2:

    - -
      -
    • The current player has 45 points and the opponent has 52 points, and the current player - chooses to roll zero dice.
    • -
    • The tens digit of the opponent's score is 5 and the ones digit of the current player's score is 5.
    • -
    • Since 3 * abs(5 - 5) = 0, the player gains 1 point.
    • -
  • -
  • Example 3:

    - -
      -
    • The current player has 2 points and the opponent has 5 points, and the current player - chooses to roll zero dice.
    • -
    • The tens digit of the opponent's score is 0 and the ones digit of the current player's score is 2.
    • -
    • Therefore, the player gains 3 * abs(0 - 2) = 6 points.
    • -
  • -
- -
- -
    -
  • Sus Fuss. - We call a number sus if it has exactly - 3 or 4 factors, including 1 and the number itself. - If, after rolling, the current player's score is a sus number, their score instantly increases to the next prime number.
  • -
- - - -
- -
    -
  • Example 1:

    - -
      -
    • A player has 14 points and rolls 2 dice that earns them 7 points. - Their new score would be 21, which has 4 factors: 1, 3, 7, and 21. - Therefore, 21 is sus, and the player's score is immediately increased to 23, the - next prime number.
    • -
  • -
  • Example 2:

    - -
      -
    • A player with 63 points rolls 5 dice and earns 1 point from their turn. - Their new score would be 64 (Sow Sad 😢), which has 7 factors: 1, 2, 4, 8, 16, - 32, and 64. - Since 64 is not sus, the score of the player is unchanged.
    • -
  • -
  • Example 3:

    - -
      -
    • A player has 49 points and rolls 5 dice that total 18 points. - Their new score would be 67, which is prime and has 2 factors: 1 and 67. - Since 67 is not sus, the score of the player is unchanged.
    • -
  • -
- -
- - -

Download starter files

- - -

To get started, download all of the project code as a zip archive. -Below is a list of all the files you will see in the archive once unzipped. -For the project, you'll only be making changes to hog.py.

- -
    -
  • hog.py: A starter implementation of Hog
  • -
  • dice.py: Functions for making and rolling dice
  • -
  • hog_gui.py: A graphical user interface (GUI) for Hog (updated)
  • -
  • ucb.py: Utility functions for CS 61A
  • -
  • hog_ui.py: A text-based user interface (UI) for Hog
  • -
  • ok: CS 61A autograder
  • -
  • tests: A directory of tests used by ok
  • -
  • gui_files: A directory of various things used by the web GUI
  • -
- -

You may notice some files other than the ones listed above too—those are needed for making the autograder and portions of the GUI work. Please do not modify any files other than hog.py.

- - - - -

Logistics

- - - - - - - -

The project is worth 25 points, of which 1 point is for submitting -Phase 1 by the checkpoint date of Thursday 09/12.

- - -

You will turn in the following files:

- -
    -
  • hog.py
  • -
- -

You do not need to modify or turn in any other files to complete the -project. To submit the project, submit the required files to the appropriate Gradescope assignment.

- -

You may not use artificial intelligence tools to help you with this project -or reference solutions found on the internet.

- -

For the functions that we ask you to complete, there may be some -initial code that we provide. If you would rather not use that code, -feel free to delete it and start from scratch. You may also add new -function definitions as you see fit.

- -

However, please do not modify any other functions or edit any files not -listed above. Doing so may result in your code failing our autograder tests. -Also, please do not change any function signatures (names, argument order, or -number of arguments).

- - - -

Throughout this project, you should be testing the correctness of your code. -It is good practice to test often, so that it is easy to isolate any problems. -However, you should not be testing too often, to allow yourself time to -think through problems.

- -

We have provided an autograder called ok to help you -with testing your code and tracking your progress. The first time you run the -autograder, you will be asked to log in with your Ok account using your web -browser. Please do so. Each time you run ok, it will back up -your work and progress on our servers.

- -

The primary purpose of ok is to test your implementations.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

If you want to test your code interactively, you can run - -

 python3 ok -q [question number] -i 
- -with the appropriate question number (e.g. 01) inserted. -This will run the tests for that question until the first one you failed, -then give you a chance to test the functions you wrote interactively.

- -

You can also use the debugging print feature in OK by writing - -

 print("DEBUG:", x) 
- -which will produce an output in your terminal without causing OK tests to fail -with extra output. - -

Graphical User Interface

- -

A graphical user interface (GUI, for short) is provided for you. At the moment, it doesn't work because you haven't implemented the game logic. Once you complete the play function, you will be able to play a fully interactive version of Hog!

- -

Once you've done that, you can run the GUI from your terminal and play Hog in your browser:

- -
python3 hog_gui.py
- - - - -

Getting Started Videos

- - -

These videos may provide some helpful direction for tackling the coding -problems on this assignment.

- -

To see these videos, you should be logged into your berkeley.edu email.

- - -

YouTube link

- - -

Phase 1: Rules of the Game

- - -

In the first phase, you will develop a simulator for the game of Hog.

- - -

Problem 0 (0 pt)

- - -

The dice.py file represents dice using non-pure zero-argument functions. -These functions are non-pure because they may have different return values each -time they are called, and so a side-effect of calling the function is -changing what will be returned when the function is called again.

- -

Here's the documentation from dice.py that you need to read in order to -simulate dice in this project.

- -
A dice function takes no arguments and returns a number from 1 to n
-(inclusive), where n is the number of sides on the dice.
-
-Fair dice produce each possible outcome with equal probability.
-Two fair dice are already defined, four_sided and six_sided,
-and are generated by the make_fair_dice function.
-
-def make_fair_dice(sides):
-    """Return a die that generates values ranging from 1 to SIDES, each with an equal chance."""
-    ...
-
-four_sided = make_fair_dice(4)
-six_sided = make_fair_dice(6)
-
-Test dice are deterministic: they always cycles through a fixed
-sequence of values that are passed as arguments.
-Test dice are generated by the make_test_dice function.
-
-def make_test_dice(...):
-    """Return a die that cycles deterministically through OUTCOMES.
-
-    >>> dice = make_test_dice(1, 2, 3)
-    >>> dice()
-    1
-    >>> dice()
-    2
-    >>> dice()
-    3
-    >>> dice()
-    1
-    >>> dice()
-    2
- - - -

Check your understanding by unlocking the following tests.

- -
python3 ok -q 00 -u
- -
- -

You can exit the unlocker by typing exit().

- -

Typing Ctrl-C on Windows to exit out of the unlocker has been known to cause -problems, so avoid doing so.

- - -

Problem 1 (2 pt)

- - -

Implement the roll_dice function in hog.py. It takes two arguments: a -positive integer called num_rolls, which specifies the number of times to roll a die, and a -dice function. It returns the number of points scored by rolling the die -that number of times in a turn: either the sum of the outcomes or 1 (Sow -Sad).

- -
    -
  • Sow Sad. If any of the dice outcomes is a 1, the current player's score - for the turn is 1, regardless of the other values rolled.
  • -
- - - -
- -
    -
  • Example 1: The current player rolls 7 dice, 5 of which are 1's. They - score 1 point for the turn.
  • -
  • Example 2: The current player rolls 4 dice, all of which are 3's. Since - Sow Sad did not occur, they score 12 points for the turn.
  • -
- -
- -

To obtain a single outcome of a dice roll, call dice(). You should call -dice() exactly num_rolls times in the body of roll_dice.

- -

Remember to call dice() exactly num_rolls times even if Sow Sad happens -in the middle of rolling. By doing so, you will correctly simulate rolling -all the dice together (and the user interface will work correctly).

- -

Note: The roll_dice function, and many other functions throughout the -project, makes use of default argument values—you can see this in the -function heading:

- -
def roll_dice(num_rolls, dice=six_sided): ...
- -

The argument dice=six_sided indicates that the dice parameter in the -roll_dice function is optional. If no value is provided for dice, then -six_sided will be used by default.

- -

For example, calling roll_dice(3, four_sided), simulates rolling 3 four-sided dice, while calling roll_dice(3) -simulates rolling 3 six-sided dice due to the default argument.

- -

Understand the problem:

- -

Before writing any code, unlock the tests to verify your understanding of the question:

python3 ok -q 01 -u
- -
- -

Note: You will not be able to test your code using ok until you unlock -the test cases for the corresponding question.

- -

Write code and check your work:

- -

Once you are done unlocking, begin implementing your solution. You can check your correctness with:

python3 ok -q 01
- -
- - - -
- -

Check out the Debugging Guide!

- - -

Debugging Tips

- - -

If the tests don't pass, it's time to debug. You can observe the behavior of -your function using Python directly. First, start the Python interpreter and -load the hog.py file.

- -
python3 -i hog.py
- -

Then, you can call your roll_dice function on any number of dice you want.

- -
>>> roll_dice(4)
- -

You will find that the previous expression may have a different result each -time you call it, since it is simulating random dice rolls. You can also use -test dice that fix the outcomes of the dice in advance. For example, rolling -twice when you know that the dice will come up 3 and 4 should give a total -outcome of 7.

- -
>>> fixed_dice = make_test_dice(3, 4)
->>> roll_dice(2, fixed_dice)
-7
- -

On most systems, you can evaluate the same expression again by pressing the -up arrow, then pressing enter or return. To evaluate earlier commands, press -the up arrow repeatedly.

- -

If you find a problem, you first need to change your hog.py file to fix the -problem, and save the file. Then, to check whether your fix works, you'll -have to quit the Python interpreter by either using exit() or Ctrl^D, and -re-run the interpreter to test the changes you made. Pressing the up arrow in -both the terminal and the Python interpreter should give you access to your -previous expressions, even after restarting Python.

- -

Continue debugging your code and running the ok tests until they all pass.

- -

One more debugging tip: to start the interactive interpreter automatically -upon failing an ok test, use -i. For example, python3 ok -q 01 -i will -run the tests for question 1, then start an interactive interpreter with -hog.py loaded if a test fails.

- -
- - -

Problem 2 (2 pt)

- - -

Implement boar_brawl, which takes the player's current score player_score and the -opponent's current score opponent_score, and returns the number of points scored when -the player rolls 0 dice and Boar Brawl is invoked.

- -
    -
  • Boar Brawl. A player who chooses to roll zero dice scores three times - the absolute difference between the tens digit of the opponent’s score and - the ones digit of the current player’s score, or 1, whichever is greater. - The ones digit refers to the rightmost digit and the tens digit refers to - the second-rightmost digit. If a player's score is a single digit (less than - 10), the tens digit of that player's score is 0.
  • -
- - - -
- -
    -
  • Example 1:

    - -
      -
    • The current player has 21 points and the opponent has 46 points, and the current player - chooses to roll zero dice.
    • -
    • The tens digit of the opponent's score is 4 and the ones digit of the current player's score is 1.
    • -
    • Therefore, the player gains 3 * abs(4 - 1) = 9 points.
    • -
  • -
  • Example 2:

    - -
      -
    • The current player has 45 points and the opponent has 52 points, and the current player - chooses to roll zero dice.
    • -
    • The tens digit of the opponent's score is 5 and the ones digit of the current player's score is 5.
    • -
    • Since 3 * abs(5 - 5) = 0, the player gains 1 point.
    • -
  • -
  • Example 3:

    - -
      -
    • The current player has 2 points and the opponent has 5 points, and the current player - chooses to roll zero dice.
    • -
    • The tens digit of the opponent's score is 0 and the ones digit of the current player's score is 2.
    • -
    • Therefore, the player gains 3 * abs(0 - 2) = 6 points.
    • -
  • -
- -
- -

Don't assume that scores are below 100. Write your boar_brawl function so -that it works correctly for any non-negative score.

- - - -

Important: Your implementation should not use str, lists, or -contain square brackets [ ]. The test cases will check if those have -been used.

- -

Before writing any code, unlock the tests to verify your understanding of the question:

python3 ok -q 02 -u
- -

Once you are done unlocking, begin implementing your solution. You can check your correctness with:

python3 ok -q 02
- -
- -

You can also test boar_brawl interactively by running python3 -i hog.py -from the terminal and calling boar_brawl on various inputs.

- - -

Problem 3 (2 pt)

- - -

Implement the take_turn function, which returns the number of points scored -for a turn by rolling the given dice num_rolls times.

- -

Your implementation of take_turn should call both the roll_dice and -boar_brawl functions rather than repeating their implementations.

- -

Before writing any code, unlock the tests to verify your understanding of the question:

python3 ok -q 03 -u
- -

Once you are done unlocking, begin implementing your solution. You can check your correctness with:

python3 ok -q 03
- -
- -
- - -

Problem 4 (2 pt)

- - -

First, implement num_factors, which takes in a positive integer n and determines the number -of factors that n has.

- -

1 and n are both factors of n!

- -

After, implement sus_points and sus_update.

- -
    -
  • sus_points takes in a player's score and returns the player's - new score after applying the Sus Fuss rule, even if the score remains unchanged. For example, - sus_points(5) should return 5 and sus_points(21) should return 23. You should use num_factors - and the provided is_prime function in your implementation.
  • -
  • sus_update returns a player's total score after they roll num_rolls dice, taking - both Boar Brawl and Sus Fuss into account. You should use sus_points in - this function.
  • -
- -

Hints:

- -
    -
  • You can look at the implementation of simple_update provided in hog.py and use that - as a starting point for your sus_update function.
  • -
  • Recall that take-turn already took the Boar Brawl rule into consideration!
  • -
- -
    -
  • Sus Fuss. - We call a number sus if it has exactly - 3 or 4 factors, including 1 and the number itself. - If, after rolling, the current player's score is a sus number, their score instantly increases to the next prime number.
  • -
- - - -
- -
    -
  • Example 1:

    - -
      -
    • A player has 14 points and rolls 2 dice that earns them 7 points. - Their new score would be 21, which has 4 factors: 1, 3, 7, and 21. - Therefore, 21 is sus, and the player's score is immediately increased to 23, the - next prime number.
    • -
  • -
  • Example 2:

    - -
      -
    • A player with 63 points rolls 5 dice and earns 1 point from their turn. - Their new score would be 64 (Sow Sad 😢), which has 7 factors: 1, 2, 4, 8, 16, - 32, and 64. - Since 64 is not sus, the score of the player is unchanged.
    • -
  • -
  • Example 3:

    - -
      -
    • A player has 49 points and rolls 5 dice that total 18 points. - Their new score would be 67, which is prime and has 2 factors: 1 and 67. - Since 67 is not sus, the score of the player is unchanged.
    • -
  • -
- -
- -

Before writing any code, unlock the tests to verify your understanding of the question:

python3 ok -q 04 -u
- -

Once you are done unlocking, begin implementing your solution. You can check your correctness with:

python3 ok -q 04
- -
- - -

Problem 5 (4 pt)

- - -

Implement the play function, which simulates a full game of Hog. Players take -turns rolling dice until one of the players reaches the goal score. -The function then returns the final scores of both players.

- -

To determine how many dice are rolled each turn, call the current player's -strategy function (Player 0 uses strategy0 and Player 1 uses strategy1). A -strategy is a function that, given a player's score and their opponent's -score, returns the number of dice that the current player will roll in that -turn. A simple example strategy is always_roll_5 which appears above play.

- -

To determine the updated score for a player after they take a turn, call the -update function. An update function takes the number -of dice to roll, the current player's score, the opponent's score, and the -dice function used to simulate rolling dice. It returns the updated score -of the current player after they take their turn. Two examples of update functions -are simple_update and sus_update. Remember, update functions return the player's -total score after their turn, not just the change in score.

- -

The game ends when a player reaches or exceeds the goal score by the end of their turn, -after all applicable rules have been applied. play will then return the -final total scores of both players, with Player 0's score first and Player 1's -score second.

- -

Some example calls to play are:

- -
    -
  • play(always_roll_5, always_roll_5, simple_update) simulates two players - that both always roll 5 dice each turn, playing with just the Sow Sad and Boar - Brawl rules.
  • -
  • play(always_roll_5, always_roll_5, sus_update) simulates two players - that both always roll 5 dice each turn, playing with the Sus Fuss rule in - addition to the Sow Sad and Boar Brawl rules (i.e. all the rules).
  • -
- -

Important: For the user interface to work, a strategy function should be -called only once per turn. Only call strategy0 when it is Player 0's turn -and only call strategy1 when it is Player 1's turn.

- -

Hints:

- -
    -
  • If who is the current player, the next player is 1 - who.
  • -
  • To call play(always_roll_5, always_roll_5, sus_update) and print out - what happens each turn, run python3 hog_ui.py from the terminal.
  • -
- -

Before writing any code, unlock the tests to verify your understanding of the question:

python3 ok -q 05 -u
- -

Once you are done unlocking, begin implementing your solution. You can check your correctness with:

python3 ok -q 05
- -
- -

Check to make sure that you completed all the problems in Phase 1:

- -
python3 ok --score
- -

Then, submit your work to Gradescope before the checkpoint deadline:

- -

When you run ok commands, you'll still see that some tests are locked -because you haven't completed the whole project yet. You'll get full credit for -the checkpoint if you complete all the problems up to this point.

- -

Congratulations! You have finished Phase 1 of this project!

- -
- - -

Interlude: User Interfaces

- - -

There are no required problems in this section of the project, just some -examples for you to read and understand. See Phase 2 for the remaining -project problems.

- - -

Printing Game Events

- - -

We have built a simulator for the game, but haven't added any code to describe -how the game events should be displayed to a person. Therefore, we've built a -computer game that no one can play. (Lame!)

- -

However, the simulator is expressed in terms of small functions, and we can -replace each function by a version that prints out what happens when it is -called. Using higher-order functions, we can do so without changing much of our -original code. An example appears in hog_ui.py, which you are encouraged to -read.

- -

The play_and_print function calls the same play function just implemented, -but using:

- -
    -
  • new strategy functions (e.g., printing_strategy(0, always_roll_5)) that - print out the scores and number of dice rolled.
  • -
  • a new update function (sus_update_and_print) that prints the outcome of - each turn.
  • -
  • a new dice function (printing_dice(six_sided)) that prints the outcome of - rolling the dice.
  • -
- -

Notice how much of the original simulator code can be reused.

- -

Running python3 hog_ui.py from the terminal calls -play_and_print(always_roll_5, always_roll_5).

- - -

Accepting User Input

- - -

The built-in input function waits for the user to type a line of text and -then returns that text as a string. The built-in int function can take a -string containing the digits of an integer and return that integer.

- -

The interactive_strategy function returns a strategy that let's a person -choose how many dice to roll each turn by calling input.

- -

With this strategy, we can finally play a game using our play function:

- -

Running python3 hog_ui.py -n 1 from the terminal calls -play_and_print(interactive_strategy(0), always_roll_5), which plays a game -betweem a human (Player 0) and a computer strategy that always rolls 5.

- -

Running python3 hog_ui.py -n 2 from the terminal calls -play_and_print(interactive_strategy(0), interactive_strategy(1)), which plays -a game between two human players.

- -

You are welcome to change hog_ui.py in any way you want, for example to use -different strategies than always_roll_5.

- - -

Graphical User Interface (GUI)

- - -

We have also provided a web-based graphical user interface for the game using a similar approach as hog_ui.py called hog_gui.py. You can run it from the terminal:

- -
python3 hog_gui.py
- -

Like hog_ui.py, the GUI relies on your simulator implementation, so if you have any bugs in your code, they will be reflected in the GUI. This means you can also use the GUI as a debugging tool; however, it's better to run the tests first.

- -

The source code for the Hog GUI is publicly available on Github but involves several other programming languages: Javascript, HTML, and CSS.

- -
- - -

Phase 2: Strategies

- - -

In this phase, you will experiment with ways to improve upon the simple always_roll_five -strategy of always rolling five dice. A strategy is a function that -takes two arguments: the current player's score and their opponent's score. It -returns the number of dice the player will roll, which can be from 0 to 10 -(inclusive).

- - -

Problem 6 (2 pt)

- - -

Implement always_roll, a higher-order function that takes a number of dice -n and returns a strategy function that always rolls n dice. Thus, always_roll(5) -would be equivalent to always_roll_5.

- -

Before writing any code, unlock the tests to verify your understanding of the question:

python3 ok -q 06 -u
- -
-

Once you are done unlocking, begin implementing your solution. You can check your correctness with:

python3 ok -q 06
- -
- - -

Problem 7 (2 pt)

- - -

A strategy has a fixed number of possible argument values. For example, in a game with a goal of -100, there are only 100 possible score values (0-99) and 100 possible -opponent_score values (0-99), resulting in 10,000 possible argument combinations to a strategy function.

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Player ScoreOpponent Score Combinations
0(0,0), (0,1), (0,2), ..., (0,99)
1(1,0), (1,1), (1,2), ..., (1,99)
2(2,0), (2,1), (2,2), ..., (2,99)
......
98(98,0), (98,1), (98,2), ..., (98,99)
99(99,0), (99,1), (99,2), ..., (99,99)
-
- - - - -

Implement is_always_roll, which takes a strategy and returns whether that -strategy always rolls the same number of dice for every possible argument -combination, where each score is up to goal points.

- -

Reminder: The game continues until one player reaches goal points (in -the above example goal is set to 100, but it could be any number). -Ensure your solution considers every possible combination of score and opponent_score for the specified goal.

- -

Before writing any code, unlock the tests to verify your understanding of the question:

python3 ok -q 07 -u
- -
-

Once you are done unlocking, begin implementing your solution. You can check your correctness with:

python3 ok -q 07
- -
- - -

Problem 8 (2 pt)

- - - - -

Implement make_averaged, which is a higher-order function that -takes a function original_function as an argument.

- -

The return value of make_averaged is a function that takes in the same -arguments as original_function. When called with specific arguments, this function should repeatedly -call original_function on those same arguments, times_called times, and return the average of the results. -Take a look at the make_averaged doctest. Be sure to keep track of what values are being passed into the function!

- -

Doctest Walkthrough: -Take a close look at the make_averaged doctest. Here, original_function is roll_dice. -Notice the line averaged_dice(1, dice). This implies that the arguments for roll_dice are (1, dice) (think about why!) Observe how averaged_dice accepts the same arguments as roll_dice. The arguments are not passed directly to roll_dice but rather to averaged_dice. (Think about how this can be achieved!) Keep in mind, make_averaged should work with any original_function that shares the same argument structure as the function returned by make_averaged. -In this example, rolling a single die is considered a sample (roll_dice(1, dice)). Since times_called is set to 40, this sampling is repeated 40 times. The make_averaged function then calculates the average result of these 40 calls to roll_dice.

- -

Important: -To implement this function, you will need to use a new piece of Python syntax. -We would like to write a function that accepts an arbitrary number of arguments, -and then calls another function using exactly those arguments. Here's how -it works.

- -

Instead of listing formal parameters for a function, you can write *args, -which represents all of the arguments that get passed into the -function. We can then call another function with these same arguments by -passing these *args into this other function. For example:

- -
>>> def printed(f):
-...     def print_and_return(*args):
-...         result = f(*args)
-...         print('Result:', result)
-...         return result
-...     return print_and_return
->>> printed_pow = printed(pow)
->>> printed_pow(2, 8)  # *args represents the arguments (2, 8)
-Result: 256
-256
->>> printed_abs = printed(abs)
->>> printed_abs(-10)  # *args represents one argument (-10)
-Result: 10
-10
- -

Here, we can pass any number of arguments into print_and_return via the -*args syntax. We can also use *args inside our print_and_return -function to make another function call with the same arguments.

- -

Before writing any code, unlock the tests to verify your understanding of the question:

python3 ok -q 08 -u
- -
-

Once you are done unlocking, begin implementing your solution. You can check your correctness with:

python3 ok -q 08
- -
- - -

Problem 9 (2 pt)

- - -

Implement max_scoring_num_rolls, which runs an experiment to -determine the number of rolls (from 1 to 10) that gives the maximum average -score for a turn. Your implementation should use make_averaged and -roll_dice.

- -

If two numbers of rolls are tied for the maximum average score, return the -lower number. For example, if both 3 and 6 achieve the same maximum average score, -return 3.

- -

You might find it useful to read the doctest for this problem and make_averaged (Problem 8), before doing the unlocking test.

- -

Important: In order to pass all of our tests, please make sure that you are -testing dice rolls starting from 1 going up to 10, rather than from 10 to 1.

- -

Before writing any code, unlock the tests to verify your understanding of the question:

python3 ok -q 09 -u
- -
-

Once you are done unlocking, begin implementing your solution. You can check your correctness with:

python3 ok -q 09
- -
- - -

Running Experiments

- - -

The provided run_experiments function calls -max_scoring_num_rolls(six_sided) and prints the result. You will likely find -that rolling 6 dice maximizes the result of roll_dice using six-sided dice.

- -

To call this function and see the result, run hog.py with the -r flag:

- -
python3 hog.py -r
- -

In addition, run_experiments compares various strategies to always_roll(6). -You are welcome to change the implementation of run_experiments as you wish. -Note that running experiments with boar_strategy and sus_strategy will not -have accurate results until you implement them in the next two problems.

- -

Some of the experiments may take up to a minute to run. You can always reduce -the number of trials in your call to make_averaged to speed up experiments.

- -

Running experiments won't affect your score on the project.

- -
- - -

Problem 10 (2 pt)

- - -

A strategy can try to take advantage of the Boar Brawl rule by rolling 0 when -it is most beneficial to do so. Implement boar_strategy, which returns 0 -whenever rolling 0 would give at least threshold points and returns -num_rolls otherwise. This strategy should not also take into account -the Sus Fuss rule.

- -

Hint: You can use the boar_brawl function you defined in Problem 2.

- -

Before writing any code, unlock the tests to verify your understanding of the question:

python3 ok -q 10 -u
- -
-

Once you are done unlocking, begin implementing your solution. You can check your correctness with:

python3 ok -q 10
- -
- -

You should find that running python3 hog.py -r now shows a win rate for -boar_strategy close to 66-67%.

- - -

Problem 11 (2 pt)

- - -

A better strategy would take advantage of both Boar Brawl and Sus Fuss in -combination. -For example, if a player has 53 points and their opponent has 60, rolling 0 -would bring them to 62, which is a sus number, and so they would end the -turn with 67 points: a gain of 67 - 53 = 14!

- -

The sus_strategy returns 0 whenever rolling 0 would result in a score that -is at least threshold points more than the player's score at the -start of turn.

- -

Hint: You can use the sus_update function you defined in Problem 4.

- -

Before writing any code, unlock the tests to verify your understanding of the question:

python3 ok -q 11 -u
- -
-

Once you are done unlocking, begin implementing your solution. You can check your correctness with:

python3 ok -q 11
- -
- -

You should find that running python3 hog.py -r now shows a win rate for -sus_strategy close to 67-69%.

- - -

Optional: Problem 12 (0 pt)

- - -

Implement final_strategy, which combines these ideas and any other ideas you -have to achieve a high win rate against the baseline strategy. Some -suggestions:

- -
    -
  • If you know the goal score (by default it is 100), there's no benefit to - scoring more than the goal. Check whether you can win by rolling 0, 1 or 2 - dice. If you are in the lead, you might decide to take fewer risks.
  • -
  • Instead of using a threshold, roll 0 whenever it would give you more points - on average than rolling 6.
  • -
- -

You can check that your final strategy is valid by running ok.

- -
python3 ok -q 12
- -
- - -

Project submission

- - -

Run ok on all problems to make sure all tests are unlocked and pass:

- -
python3 ok
- -

You can also check your score on each part of the project:

- -
python3 ok --score
- -

Once you are satisfied, submit this assignment by uploading hog.py to Gradescope. For a refresher on how to do this, refer to Lab 00.

- -

You can add a partner to your Gradescope submission by clicking on + Add Group Member under your name on the right hand side of your submission. Only one partner needs to submit to Gradescope.

- -

Congratulations, you have reached the end of your first CS 61A project! -If you haven't already, relax and enjoy a few games of Hog with a friend.

- -
- -
- -

/proj/hog_contest

- - -

Hog Contest

- - -

If you're interested, you can take your implementation of Hog one step further -by participating in the Hog Contest, where you play your final_strategy -against those of other students. The winning strategies will receive extra -credit and will be recognized in future semesters!

- -

To see more, read the contest description. Or check out -the leaderboard.

- - - - - - - - - -
- - -
- -
- - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/proj/hog/ok b/proj/hog/ok deleted file mode 100644 index b84a800fe..000000000 Binary files a/proj/hog/ok and /dev/null differ diff --git a/proj/hog/proj01.ok b/proj/hog/proj01.ok deleted file mode 100644 index a0080abb1..000000000 --- a/proj/hog/proj01.ok +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "Project 1: Hog", - "endpoint": "cal/cs61a/fa24/proj01", - "src": [ - "hog.py" - ], - "tests": { - "tests/0*.py": "ok_test", - "tests/1*.py": "ok_test" - }, - "default_tests": [ - "00", - "01", - "02", - "03", - "04", - "05", - "06", - "07", - "08", - "09", - "10", - "11", - "12" - ], - "protocols": [ - "file_contents", - "unlock", - "grading", - "analytics", - "collaborate", - "backup" - ] -} \ No newline at end of file diff --git a/proj/hog/tests/00.py b/proj/hog/tests/00.py deleted file mode 100644 index 33a56a420..000000000 --- a/proj/hog/tests/00.py +++ /dev/null @@ -1,57 +0,0 @@ -test = { - 'name': 'Question 0', - 'points': 0, - 'suites': [ - { - 'cases': [ - { - 'code': r""" - >>> test_dice = make_test_dice(4, 1, 2) - >>> test_dice() - edcbd82ba98a8122be244fa325c62071 - # locked - >>> test_dice() # Second call - 43d176e102c8d95338faf8791aa509b3 - # locked - >>> test_dice() # Third call - 46caef5ffd6d72c8757279cbcf01b12f - # locked - >>> test_dice() # Fourth call - edcbd82ba98a8122be244fa325c62071 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - """, - 'teardown': '', - 'type': 'doctest' - }, - { - 'cases': [ - { - 'answer': '5c489e1123a9d0cfdd0c26a27a56d42b', - 'choices': [ - 'make_test_dice(6)', - 'make_fair_dice(6)', - 'six_sided', - 'six_sided()', - 'six_sided(1)', - 'six_sided(6)' - ], - 'hidden': False, - 'locked': True, - 'multiline': False, - 'question': 'Which of the following is the correct way to "roll" a fair, six-sided die?' - } - ], - 'scored': False, - 'type': 'concept' - } - ] -} diff --git a/proj/hog/tests/01.py b/proj/hog/tests/01.py deleted file mode 100644 index 1208a0ea9..000000000 --- a/proj/hog/tests/01.py +++ /dev/null @@ -1,808 +0,0 @@ -test = { - 'name': 'Question 1', - 'points': 2, - 'suites': [ - { - 'cases': [ - { - 'code': r""" - >>> roll_dice(2, make_test_dice(4, 6, 1)) - 70e71b420a966665c548a3bb2cb30d7d - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> roll_dice(3, make_test_dice(4, 6, 1)) - 43d176e102c8d95338faf8791aa509b3 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> roll_dice(4, make_test_dice(2, 2, 3)) - 872dbe4a4fe5d8451aa842c21194c866 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> a = roll_dice(4, make_test_dice(1, 2, 3)) - >>> a # check that the value is being returned, not printed - 43d176e102c8d95338faf8791aa509b3 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> counted_dice = make_test_dice(4, 1, 2, 6) - >>> roll_dice(3, counted_dice) - 43d176e102c8d95338faf8791aa509b3 - # locked - >>> # Make sure you call dice exactly num_rolls times! - >>> # If you call it fewer or more than that, it won't be at the right spot in the cycle for the next roll - >>> # Note that a return statement within a loop ends the loop - >>> roll_dice(1, counted_dice) - 327b19ffebddf93982e1ad2a4a6486f4 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> roll_dice(9, make_test_dice(6)) - 72862184559d57299206f055e2cc5a63 - # locked - >>> roll_dice(7, make_test_dice(2, 2, 2, 2, 2, 2, 1)) - 43d176e102c8d95338faf8791aa509b3 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - """, - 'teardown': '', - 'type': 'doctest' - }, - { - 'cases': [ - { - 'code': r""" - >>> roll_dice(5, make_test_dice(4, 2, 3, 3, 4, 1)) - 16 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> roll_dice(2, make_test_dice(1)) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(5, 4, 3, 2, 1) - >>> roll_dice(1, dice) # Roll 1 (5) - 5 - >>> roll_dice(4, dice) # Reset (4, 3, 2, 1) - 1 - >>> roll_dice(2, dice) # Roll 2 (5, 4) - 9 - >>> roll_dice(3, dice) # Reset (3, 2, 1) - 1 - >>> roll_dice(3, dice) # Roll 3 (5, 4, 3) - 12 - >>> roll_dice(2, dice) # Reset (2, 1) - 1 - >>> roll_dice(4, dice) # Roll 4 (5, 4, 3, 2) - 14 - >>> roll_dice(1, dice) # Reset (1) - 1 - >>> roll_dice(5, dice) # Roll 5 (5, 4, 3, 2, 1) - 1 - >>> roll_dice(10, dice) # Roll 10 (5, 4, 3, 2, 1, 5, 4, 3, 2, 1) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - """, - 'teardown': '', - 'type': 'doctest' - }, - { - 'cases': [ - { - 'code': r""" - >>> dice = make_test_dice(2, 4, 3, 5, 2, 2) - >>> roll_dice(4, dice) - 14 - >>> roll_dice(4, dice) - 10 - >>> roll_dice(3, dice) - 10 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 4, 5, 4, 3) - >>> roll_dice(2, dice) - 1 - >>> roll_dice(1, dice) - 5 - >>> roll_dice(4, dice) - 1 - >>> roll_dice(3, dice) - 12 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(5, 2) - >>> roll_dice(4, dice) - 14 - >>> roll_dice(3, dice) - 12 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3, 1, 4, 1, 3, 4) - >>> roll_dice(4, dice) - 1 - >>> roll_dice(1, dice) - 3 - >>> roll_dice(2, dice) - 7 - >>> roll_dice(3, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1,) - >>> roll_dice(3, dice) - 1 - >>> roll_dice(2, dice) - 1 - >>> roll_dice(5, dice) - 1 - >>> roll_dice(1, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(4,) - >>> roll_dice(4, dice) - 16 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(2, 3, 5) - >>> roll_dice(1, dice) - 2 - >>> roll_dice(5, dice) - 18 - >>> roll_dice(3, dice) - 10 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 5, 4) - >>> roll_dice(2, dice) - 1 - >>> roll_dice(1, dice) - 4 - >>> roll_dice(5, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(2,) - >>> roll_dice(4, dice) - 8 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1,) - >>> roll_dice(2, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3, 1, 3) - >>> roll_dice(2, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(4, 5) - >>> roll_dice(4, dice) - 18 - >>> roll_dice(2, dice) - 9 - >>> roll_dice(5, dice) - 22 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 4) - >>> roll_dice(3, dice) - 1 - >>> roll_dice(4, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 1, 3, 5) - >>> roll_dice(3, dice) - 1 - >>> roll_dice(1, dice) - 5 - >>> roll_dice(5, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3, 2, 1, 2, 3, 2) - >>> roll_dice(2, dice) - 5 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(2, 5, 1, 3) - >>> roll_dice(4, dice) - 1 - >>> roll_dice(4, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(5, 4, 1, 4) - >>> roll_dice(5, dice) - 1 - >>> roll_dice(3, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(4, 5) - >>> roll_dice(2, dice) - 9 - >>> roll_dice(4, dice) - 18 - >>> roll_dice(5, dice) - 22 - >>> roll_dice(3, dice) - 14 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3, 5, 1, 4, 3) - >>> roll_dice(1, dice) - 3 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3, 1, 5, 2, 5, 3) - >>> roll_dice(1, dice) - 3 - >>> roll_dice(2, dice) - 1 - >>> roll_dice(4, dice) - 13 - >>> roll_dice(4, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(2,) - >>> roll_dice(1, dice) - 2 - >>> roll_dice(4, dice) - 8 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(2, 3) - >>> roll_dice(4, dice) - 10 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3, 3, 5, 5, 1, 2) - >>> roll_dice(3, dice) - 11 - >>> roll_dice(3, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3,) - >>> roll_dice(4, dice) - 12 - >>> roll_dice(1, dice) - 3 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(5, 4, 1, 3) - >>> roll_dice(4, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(5, 3, 2, 1) - >>> roll_dice(4, dice) - 1 - >>> roll_dice(4, dice) - 1 - >>> roll_dice(3, dice) - 10 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3, 2, 2) - >>> roll_dice(3, dice) - 7 - >>> roll_dice(1, dice) - 3 - >>> roll_dice(3, dice) - 7 - >>> roll_dice(5, dice) - 11 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 3, 1, 5, 3, 3) - >>> roll_dice(4, dice) - 1 - >>> roll_dice(4, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1,) - >>> roll_dice(2, dice) - 1 - >>> roll_dice(2, dice) - 1 - >>> roll_dice(4, dice) - 1 - >>> roll_dice(4, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 4) - >>> roll_dice(1, dice) - 1 - >>> roll_dice(4, dice) - 1 - >>> roll_dice(3, dice) - 1 - >>> roll_dice(2, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(5, 2, 2, 3, 2, 5) - >>> roll_dice(3, dice) - 9 - >>> roll_dice(3, dice) - 10 - >>> roll_dice(5, dice) - 14 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 2, 3, 2, 4) - >>> roll_dice(5, dice) - 1 - >>> roll_dice(2, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(5, 3) - >>> roll_dice(3, dice) - 13 - >>> roll_dice(1, dice) - 3 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3, 3) - >>> roll_dice(2, dice) - 6 - >>> roll_dice(1, dice) - 3 - >>> roll_dice(1, dice) - 3 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 2, 1, 3) - >>> roll_dice(4, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 2, 3, 2) - >>> roll_dice(4, dice) - 1 - >>> roll_dice(4, dice) - 1 - >>> roll_dice(2, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 2, 3, 4, 1, 2) - >>> roll_dice(5, dice) - 1 - >>> roll_dice(1, dice) - 2 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3,) - >>> roll_dice(3, dice) - 9 - >>> roll_dice(4, dice) - 12 - >>> roll_dice(4, dice) - 12 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(2, 5, 3, 3) - >>> roll_dice(1, dice) - 2 - >>> roll_dice(2, dice) - 8 - >>> roll_dice(4, dice) - 13 - >>> roll_dice(2, dice) - 5 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3,) - >>> roll_dice(2, dice) - 6 - >>> roll_dice(2, dice) - 6 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 3, 5, 4, 3) - >>> roll_dice(3, dice) - 1 - >>> roll_dice(1, dice) - 4 - >>> roll_dice(4, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(5, 4, 5, 1, 4, 5) - >>> roll_dice(2, dice) - 9 - >>> roll_dice(5, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(4,) - >>> roll_dice(2, dice) - 8 - >>> roll_dice(3, dice) - 12 - >>> roll_dice(1, dice) - 4 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1,) - >>> roll_dice(4, dice) - 1 - >>> roll_dice(1, dice) - 1 - >>> roll_dice(2, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 1, 5, 5, 5) - >>> roll_dice(4, dice) - 1 - >>> roll_dice(1, dice) - 5 - >>> roll_dice(1, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(5, 5, 2, 2, 1, 3) - >>> roll_dice(2, dice) - 10 - >>> roll_dice(5, dice) - 1 - >>> roll_dice(2, dice) - 7 - >>> roll_dice(2, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(5,) - >>> roll_dice(4, dice) - 20 - >>> roll_dice(4, dice) - 20 - >>> roll_dice(5, dice) - 25 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 2, 2, 5, 4) - >>> roll_dice(4, dice) - 1 - >>> roll_dice(5, dice) - 1 - >>> roll_dice(1, dice) - 4 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 3) - >>> roll_dice(5, dice) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3, 3) - >>> roll_dice(1, dice) - 3 - >>> roll_dice(4, dice) - 12 - >>> roll_dice(5, dice) - 15 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> # generated case - >>> from hog import * - """, - 'teardown': '', - 'type': 'doctest' - } - ] -} diff --git a/proj/hog/tests/02.py b/proj/hog/tests/02.py deleted file mode 100644 index f61c91b08..000000000 --- a/proj/hog/tests/02.py +++ /dev/null @@ -1,154 +0,0 @@ -test = { - 'name': 'Question 2', - 'points': 2, - 'suites': [ - { - 'cases': [ - { - 'code': r""" - >>> boar_brawl(21, 46) - 872dbe4a4fe5d8451aa842c21194c866 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_brawl(52, 79) - af0b3285304485122429774c0ea3182a - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_brawl(0, 0) - 43d176e102c8d95338faf8791aa509b3 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_brawl(0, 5) - 43d176e102c8d95338faf8791aa509b3 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_brawl(2, 5) - 327b19ffebddf93982e1ad2a4a6486f4 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_brawl(7, 2) - 6790f7070fa643e868f99363486b6275 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_brawl(6, 10) - 15 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> boar_brawl(16, 27) - 12 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> boar_brawl(39, 71) - 6 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> boar_brawl(72, 29) - 43d176e102c8d95338faf8791aa509b3 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_brawl(82, 115) # don't assume scores are below 100 - 3 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> boar_brawl(99, 121) # don't assume scores are below 100 - 21 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> a = boar_brawl(42, 61) - >>> a # check that the value is being returned, not printed - 12 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> boar_brawl(727, 939) - 12 - >>> # ban str and indexing (lists) - >>> test.check('hog.py', 'boar_brawl', ['Slice', 'List', 'ListComp', 'Index', 'Subscript', 'For']) - True - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - >>> import tests.construct_check as test - """, - 'teardown': '', - 'type': 'doctest' - } - ] -} diff --git a/proj/hog/tests/03.py b/proj/hog/tests/03.py deleted file mode 100644 index 793bd8309..000000000 --- a/proj/hog/tests/03.py +++ /dev/null @@ -1,145 +0,0 @@ -test = { - 'name': 'Question 3', - 'points': 2, - 'suites': [ - { - 'cases': [ - { - 'code': r""" - >>> take_turn(2, 7, 27, make_test_dice(4, 5, 1)) - 872dbe4a4fe5d8451aa842c21194c866 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> take_turn(3, 15, 9, make_test_dice(4, 6, 1)) - 43d176e102c8d95338faf8791aa509b3 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> take_turn(0, 12, 41) # what happens when you roll 0 dice? - 327b19ffebddf93982e1ad2a4a6486f4 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> take_turn(0, 37, 15) - 18 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> take_turn(0, 35, 21) - 9 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> take_turn(2, 15, 25, make_test_dice(6)) - 12 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> take_turn(9, 2, 3, make_test_dice(4)) - 36 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> take_turn(7, 4, 11, make_test_dice(4)) - 28 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> take_turn(8, 3, 15, make_test_dice(5)) - 40 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> take_turn(1, 3, 6, make_test_dice(5, 1)) - 5 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> take_turn(2, 3, 4, make_test_dice(5, 1)) - 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - """, - 'teardown': '', - 'type': 'doctest' - }, - { - 'cases': [ - { - 'code': r""" - >>> hog.take_turn(5, 0, 0) # Make sure you call roll_dice! - Called roll dice! - 9002 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> import hog - >>> def roll_dice(num_rolls, dice): - ... print("Called roll dice!") - ... return 9002 - ... - >>> hog.roll_dice, old_roll_dice = roll_dice, hog.roll_dice - """, - 'teardown': r""" - >>> hog.roll_dice = old_roll_dice - """, - 'type': 'doctest' - } - ] -} diff --git a/proj/hog/tests/04.py b/proj/hog/tests/04.py deleted file mode 100644 index 15ecd576d..000000000 --- a/proj/hog/tests/04.py +++ /dev/null @@ -1,288 +0,0 @@ -test = { - 'name': 'Question 4', - 'points': 2, - 'suites': [ - { - 'cases': [ - { - 'code': r""" - >>> num_factors(1) - 43d176e102c8d95338faf8791aa509b3 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> num_factors(2) - 46caef5ffd6d72c8757279cbcf01b12f - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> num_factors(3) - 46caef5ffd6d72c8757279cbcf01b12f - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> num_factors(9) - 16e2cf37e8254529473d9e0a36b75fcb - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> num_factors(28) - 327b19ffebddf93982e1ad2a4a6486f4 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> num_factors(64) - c42887e7b9ffe8fc26bb57b61329f916 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> num_factors(72) - 12 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> num_factors(97) - 46caef5ffd6d72c8757279cbcf01b12f - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> num_factors(99) - 6 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> sus_points(1) - 43d176e102c8d95338faf8791aa509b3 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> sus_points(21) - d4e635123d3bf027954fb7a6e4ca8cdb - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> sus_points(25) - 29 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> sus_points(62) - 2c3cbe4a2ba154412b20007fbd3a9b63 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> sus_points(64) - 5c6853796ff2cb8acdd00712bc721759 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> sus_points(67) - 67 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> sus_points(75) - 75 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> sus_points(86) - 89 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> sus_points(100) - 100 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> simple_update(2, 5, 7, make_test_dice(2, 4)) - ebb85ed86e75db9ccb48b9592f867cc1 - # locked - >>> sus_update(2, 5, 7, make_test_dice(2, 4)) # is 11 a sus number? - ebb85ed86e75db9ccb48b9592f867cc1 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> simple_update(0, 15, 37) # what happens when you roll 0 dice? - 6790f7070fa643e868f99363486b6275 - # locked - >>> sus_update(0, 15, 37) # is 21 a sus number? - d4e635123d3bf027954fb7a6e4ca8cdb - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> simple_update(2, 2, 3, make_test_dice(4)) - 70e71b420a966665c548a3bb2cb30d7d - # locked - >>> sus_update(2, 2, 3, make_test_dice(4)) # is 10 a sus number? - ebb85ed86e75db9ccb48b9592f867cc1 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> sus_update(3, 11, 12, make_test_dice(4, 5, 6)) - 29 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> sus_update(2, 29, 17, make_test_dice(1, 3)) - 30 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> sus_update(0, 41, 42) - 50 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> sus_update(0, 40, 22) - 47 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> sus_update(2, 56, 56, make_test_dice(4)) - 64 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> import types - >>> def imports(): - ... for name, val in globals().items(): - ... if isinstance(val, types.ModuleType): - ... yield val.__name__ - >>> list(imports()) # do NOT import any new modules! - ['tests.construct_check', 'types'] - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - >>> import tests.construct_check as test - """, - 'teardown': '', - 'type': 'doctest' - } - ] -} diff --git a/proj/hog/tests/05.py b/proj/hog/tests/05.py deleted file mode 100644 index 2dab641cc..000000000 --- a/proj/hog/tests/05.py +++ /dev/null @@ -1,3116 +0,0 @@ -test = { - 'name': 'Question 5', - 'points': 4, - 'suites': [ - { - 'cases': [ - { - 'answer': 'a4d959d6146005b45f9590c6bc256e37', - 'choices': [ - 'While score0 and score1 are both less than goal', - 'While at least one of score0 or score1 is less than goal', - 'While score0 is less than goal', - 'While score1 is less than goal' - ], - 'hidden': False, - 'locked': True, - 'multiline': False, - 'question': r""" - The variables score0 and score1 are the scores for Player 0 - and Player 1, respectively. Under what conditions should the - game continue? - """ - }, - { - 'answer': 'bcda62bd369acb79a636e354f5ef2f48', - 'choices': [ - 'The number of dice a player will roll', - 'A function that returns the number of dice a player will roll', - "A player's desired turn outcome" - ], - 'hidden': False, - 'locked': True, - 'multiline': False, - 'question': 'What is a strategy in the context of this game?' - }, - { - 'answer': '6092933b58b128fe246b574b1aa79389', - 'choices': [ - 'strategy1(score1, score0)', - 'strategy1(score0, score1)', - 'strategy1(score1)', - 'strategy1(score0)' - ], - 'hidden': False, - 'locked': True, - 'multiline': False, - 'question': r""" - If strategy1 is Player 1's strategy function, score0 is - Player 0's current score, and score1 is Player 1's current - score, then which of the following demonstrates correct - usage of strategy1? - """ - }, - { - 'answer': '962aea5f59fc55bd65ccacf4603c8f22', - 'choices': [ - '0', - '1', - '5', - '10' - ], - 'hidden': False, - 'locked': True, - 'multiline': False, - 'question': r""" - Player 0 has a score of 55, Player 1 has a score of 22, - and Player 0's strategy is given by lambda x, y: ((y % 10) * (x % 10)) % 10. - How many dice will Player 0 roll on their turn? - """ - } - ], - 'scored': False, - 'type': 'concept' - }, - { - 'cases': [ - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=69484, score0=15, score1=10, goal=32, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (15, 10). - Player 0 rolls 8 dice and gets outcomes [2, 1, 6, 6, 6, 5, 4, 4]. - End scores = (16, 10) - >>> print(turns[1]) - Start scores = (16, 10). - Player 1 rolls 5 dice and gets outcomes [4, 2, 4, 6, 2]. - End scores = (16, 28) - >>> print(turns[2]) - Start scores = (16, 28). - Player 0 rolls 3 dice and gets outcomes [1, 1, 5]. - End scores = (17, 28) - >>> print(turns[3]) - Start scores = (17, 28). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (17, 49) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=42415, score0=3, score1=3, goal=46, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (3, 3). - Player 0 rolls 3 dice and gets outcomes [5, 5, 4]. - End scores = (17, 3) - >>> print(turns[1]) - Start scores = (17, 3). - Player 1 rolls 8 dice and gets outcomes [3, 1, 3, 3, 2, 3, 1, 5]. - End scores = (17, 4) - >>> print(turns[2]) - Start scores = (17, 4). - Player 0 rolls 6 dice and gets outcomes [1, 6, 4, 5, 2, 5]. - End scores = (18, 4) - >>> print(turns[3]) - Start scores = (18, 4). - Player 1 rolls 2 dice and gets outcomes [3, 6]. - End scores = (18, 13) - >>> print(turns[4]) - Start scores = (18, 13). - Player 0 rolls 6 dice and gets outcomes [4, 1, 6, 3, 2, 1]. - End scores = (19, 13) - >>> print(turns[5]) - Start scores = (19, 13). - Player 1 rolls 8 dice and gets outcomes [6, 2, 2, 1, 3, 4, 1, 3]. - End scores = (19, 14) - >>> print(turns[6]) - Start scores = (19, 14). - Player 0 rolls 10 dice and gets outcomes [4, 2, 3, 5, 6, 4, 3, 4, 3, 4]. - End scores = (57, 14) - >>> print(turns[7]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=15589, score0=14, score1=13, goal=88, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (14, 13). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (23, 13) - >>> print(turns[1]) - Start scores = (23, 13). - Player 1 rolls 1 dice and gets outcomes [3]. - End scores = (23, 16) - >>> print(turns[2]) - Start scores = (23, 16). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (29, 16) - >>> print(turns[3]) - Start scores = (29, 16). - Player 1 rolls 6 dice and gets outcomes [3, 4, 1, 5, 2, 6]. - End scores = (29, 17) - >>> print(turns[4]) - Start scores = (29, 17). - Player 0 rolls 1 dice and gets outcomes [1]. - End scores = (30, 17) - >>> print(turns[5]) - Start scores = (30, 17). - Player 1 rolls 3 dice and gets outcomes [4, 5, 2]. - End scores = (30, 28) - >>> print(turns[6]) - Start scores = (30, 28). - Player 0 rolls 10 dice and gets outcomes [6, 6, 5, 2, 1, 6, 6, 3, 5, 1]. - End scores = (31, 28) - >>> print(turns[7]) - Start scores = (31, 28). - Player 1 rolls 6 dice and gets outcomes [2, 3, 6, 2, 5, 3]. - End scores = (31, 49) - >>> print(turns[8]) - Start scores = (31, 49). - Player 0 rolls 2 dice and gets outcomes [5, 2]. - End scores = (38, 49) - >>> print(turns[9]) - Start scores = (38, 49). - Player 1 rolls 4 dice and gets outcomes [3, 2, 4, 6]. - End scores = (38, 64) - >>> print(turns[10]) - Start scores = (38, 64). - Player 0 rolls 6 dice and gets outcomes [3, 3, 3, 3, 5, 5]. - End scores = (60, 64) - >>> print(turns[11]) - Start scores = (60, 64). - Player 1 rolls 8 dice and gets outcomes [4, 6, 5, 2, 3, 2, 3, 4]. - End scores = (60, 93) - >>> print(turns[12]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=27754, score0=23, score1=55, goal=56, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (23, 55). - Player 0 rolls 4 dice and gets outcomes [5, 2, 6, 1]. - End scores = (24, 55) - >>> print(turns[1]) - Start scores = (24, 55). - Player 1 rolls 7 dice and gets outcomes [2, 3, 1, 3, 6, 4, 4]. - End scores = (24, 56) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=50266, score0=64, score1=24, goal=88, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (64, 24). - Player 0 rolls 9 dice and gets outcomes [5, 5, 1, 4, 6, 6, 2, 4, 1]. - End scores = (67, 24) - >>> print(turns[1]) - Start scores = (67, 24). - Player 1 rolls 8 dice and gets outcomes [5, 6, 5, 4, 1, 5, 1, 1]. - End scores = (67, 29) - >>> print(turns[2]) - Start scores = (67, 29). - Player 0 rolls 5 dice and gets outcomes [4, 3, 2, 6, 5]. - End scores = (89, 29) - >>> print(turns[3]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=3995, score0=3, score1=4, goal=10, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (3, 4). - Player 0 rolls 4 dice and gets outcomes [5, 4, 5, 3]. - End scores = (20, 4) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=1033, score0=47, score1=10, goal=49, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (47, 10). - Player 0 rolls 5 dice and gets outcomes [4, 6, 3, 5, 1]. - End scores = (48, 10) - >>> print(turns[1]) - Start scores = (48, 10). - Player 1 rolls 7 dice and gets outcomes [3, 3, 5, 5, 2, 1, 2]. - End scores = (48, 11) - >>> print(turns[2]) - Start scores = (48, 11). - Player 0 rolls 10 dice and gets outcomes [5, 6, 5, 3, 6, 5, 2, 3, 2, 2]. - End scores = (89, 11) - >>> print(turns[3]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=23897, score0=8, score1=11, goal=44, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (8, 11). - Player 0 rolls 9 dice and gets outcomes [4, 1, 4, 4, 3, 3, 2, 2, 3]. - End scores = (9, 11) - >>> print(turns[1]) - Start scores = (9, 11). - Player 1 rolls 1 dice and gets outcomes [5]. - End scores = (9, 16) - >>> print(turns[2]) - Start scores = (9, 16). - Player 0 rolls 3 dice and gets outcomes [1, 5, 6]. - End scores = (10, 16) - >>> print(turns[3]) - Start scores = (10, 16). - Player 1 rolls 1 dice and gets outcomes [6]. - End scores = (10, 22) - >>> print(turns[4]) - Start scores = (10, 22). - Player 0 rolls 9 dice and gets outcomes [1, 3, 4, 3, 6, 4, 3, 5, 3]. - End scores = (11, 22) - >>> print(turns[5]) - Start scores = (11, 22). - Player 1 rolls 9 dice and gets outcomes [1, 5, 2, 2, 5, 2, 1, 2, 5]. - End scores = (11, 23) - >>> print(turns[6]) - Start scores = (11, 23). - Player 0 rolls 6 dice and gets outcomes [6, 4, 4, 1, 6, 6]. - End scores = (12, 23) - >>> print(turns[7]) - Start scores = (12, 23). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (12, 29) - >>> print(turns[8]) - Start scores = (12, 29). - Player 0 rolls 5 dice and gets outcomes [2, 2, 4, 6, 6]. - End scores = (32, 29) - >>> print(turns[9]) - Start scores = (32, 29). - Player 1 rolls 3 dice and gets outcomes [3, 4, 2]. - End scores = (32, 38) - >>> print(turns[10]) - Start scores = (32, 38). - Player 0 rolls 9 dice and gets outcomes [1, 3, 4, 1, 6, 2, 6, 2, 5]. - End scores = (33, 38) - >>> print(turns[11]) - Start scores = (33, 38). - Player 1 rolls 8 dice and gets outcomes [1, 1, 2, 5, 4, 3, 6, 4]. - End scores = (33, 39) - >>> print(turns[12]) - Start scores = (33, 39). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (34, 39) - >>> print(turns[13]) - Start scores = (34, 39). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (34, 57) - >>> print(turns[14]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=17635, score0=7, score1=9, goal=10, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (7, 9). - Player 0 rolls 2 dice and gets outcomes [3, 2]. - End scores = (12, 9) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=98858, score0=0, score1=20, goal=66, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (0, 20). - Player 0 rolls 4 dice and gets outcomes [5, 1, 4, 1]. - End scores = (1, 20) - >>> print(turns[1]) - Start scores = (1, 20). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (1, 23) - >>> print(turns[2]) - Start scores = (1, 23). - Player 0 rolls 1 dice and gets outcomes [6]. - End scores = (7, 23) - >>> print(turns[3]) - Start scores = (7, 23). - Player 1 rolls 10 dice and gets outcomes [2, 5, 6, 6, 6, 5, 6, 4, 1, 5]. - End scores = (7, 24) - >>> print(turns[4]) - Start scores = (7, 24). - Player 0 rolls 7 dice and gets outcomes [3, 6, 6, 6, 2, 6, 4]. - End scores = (40, 24) - >>> print(turns[5]) - Start scores = (40, 24). - Player 1 rolls 7 dice and gets outcomes [1, 4, 3, 4, 2, 2, 5]. - End scores = (40, 29) - >>> print(turns[6]) - Start scores = (40, 29). - Player 0 rolls 10 dice and gets outcomes [4, 4, 3, 2, 3, 4, 4, 6, 6, 6]. - End scores = (83, 29) - >>> print(turns[7]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=96385, score0=13, score1=20, goal=36, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (13, 20). - Player 0 rolls 1 dice and gets outcomes [6]. - End scores = (19, 20) - >>> print(turns[1]) - Start scores = (19, 20). - Player 1 rolls 6 dice and gets outcomes [5, 2, 3, 5, 2, 5]. - End scores = (19, 42) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=66739, score0=5, score1=4, goal=11, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (5, 4). - Player 0 rolls 2 dice and gets outcomes [6, 4]. - End scores = (15, 4) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=88253, score0=8, score1=5, goal=35, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (8, 5). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (32, 5) - >>> print(turns[1]) - Start scores = (32, 5). - Player 1 rolls 9 dice and gets outcomes [1, 4, 4, 2, 4, 2, 4, 3, 4]. - End scores = (32, 6) - >>> print(turns[2]) - Start scores = (32, 6). - Player 0 rolls 7 dice and gets outcomes [5, 2, 3, 5, 5, 5, 3]. - End scores = (60, 6) - >>> print(turns[3]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=39236, score0=15, score1=32, goal=53, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (15, 32). - Player 0 rolls 2 dice and gets outcomes [1, 3]. - End scores = (16, 32) - >>> print(turns[1]) - Start scores = (16, 32). - Player 1 rolls 5 dice and gets outcomes [2, 4, 1, 4, 1]. - End scores = (16, 33) - >>> print(turns[2]) - Start scores = (16, 33). - Player 0 rolls 1 dice and gets outcomes [6]. - End scores = (22, 33) - >>> print(turns[3]) - Start scores = (22, 33). - Player 1 rolls 9 dice and gets outcomes [5, 4, 5, 4, 3, 3, 2, 1, 1]. - End scores = (22, 34) - >>> print(turns[4]) - Start scores = (22, 34). - Player 0 rolls 5 dice and gets outcomes [5, 6, 3, 6, 4]. - End scores = (46, 34) - >>> print(turns[5]) - Start scores = (46, 34). - Player 1 rolls 10 dice and gets outcomes [4, 2, 2, 2, 4, 5, 2, 4, 1, 3]. - End scores = (46, 35) - >>> print(turns[6]) - Start scores = (46, 35). - Player 0 rolls 5 dice and gets outcomes [5, 3, 5, 6, 5]. - End scores = (70, 35) - >>> print(turns[7]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=73001, score0=15, score1=18, goal=23, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (15, 18). - Player 0 rolls 6 dice and gets outcomes [6, 4, 1, 2, 1, 4]. - End scores = (16, 18) - >>> print(turns[1]) - Start scores = (16, 18). - Player 1 rolls 8 dice and gets outcomes [5, 6, 2, 2, 2, 3, 3, 3]. - End scores = (16, 44) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=6301, score0=47, score1=33, goal=71, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (47, 33). - Player 0 rolls 5 dice and gets outcomes [1, 6, 4, 5, 2]. - End scores = (48, 33) - >>> print(turns[1]) - Start scores = (48, 33). - Player 1 rolls 7 dice and gets outcomes [4, 5, 6, 5, 6, 1, 5]. - End scores = (48, 34) - >>> print(turns[2]) - Start scores = (48, 34). - Player 0 rolls 1 dice and gets outcomes [3]. - End scores = (51, 34) - >>> print(turns[3]) - Start scores = (51, 34). - Player 1 rolls 4 dice and gets outcomes [5, 4, 3, 3]. - End scores = (51, 49) - >>> print(turns[4]) - Start scores = (51, 49). - Player 0 rolls 6 dice and gets outcomes [5, 3, 1, 2, 2, 3]. - End scores = (52, 49) - >>> print(turns[5]) - Start scores = (52, 49). - Player 1 rolls 7 dice and gets outcomes [4, 1, 5, 3, 6, 2, 5]. - End scores = (52, 50) - >>> print(turns[6]) - Start scores = (52, 50). - Player 0 rolls 6 dice and gets outcomes [5, 5, 5, 2, 6, 2]. - End scores = (77, 50) - >>> print(turns[7]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=96485, score0=51, score1=24, goal=85, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (51, 24). - Player 0 rolls 4 dice and gets outcomes [3, 4, 4, 1]. - End scores = (52, 24) - >>> print(turns[1]) - Start scores = (52, 24). - Player 1 rolls 2 dice and gets outcomes [1, 6]. - End scores = (52, 29) - >>> print(turns[2]) - Start scores = (52, 29). - Player 0 rolls 5 dice and gets outcomes [6, 6, 5, 5, 3]. - End scores = (79, 29) - >>> print(turns[3]) - Start scores = (79, 29). - Player 1 rolls 6 dice and gets outcomes [5, 6, 5, 6, 3, 5]. - End scores = (79, 59) - >>> print(turns[4]) - Start scores = (79, 59). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (97, 59) - >>> print(turns[5]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=20652, score0=30, score1=3, goal=51, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (30, 3). - Player 0 rolls 7 dice and gets outcomes [3, 6, 3, 3, 2, 1, 2]. - End scores = (31, 3) - >>> print(turns[1]) - Start scores = (31, 3). - Player 1 rolls 3 dice and gets outcomes [5, 5, 5]. - End scores = (31, 18) - >>> print(turns[2]) - Start scores = (31, 18). - Player 0 rolls 10 dice and gets outcomes [5, 6, 1, 3, 3, 6, 3, 2, 1, 3]. - End scores = (32, 18) - >>> print(turns[3]) - Start scores = (32, 18). - Player 1 rolls 9 dice and gets outcomes [5, 3, 3, 6, 2, 3, 5, 1, 6]. - End scores = (32, 19) - >>> print(turns[4]) - Start scores = (32, 19). - Player 0 rolls 4 dice and gets outcomes [4, 6, 2, 1]. - End scores = (37, 19) - >>> print(turns[5]) - Start scores = (37, 19). - Player 1 rolls 1 dice and gets outcomes [2]. - End scores = (37, 23) - >>> print(turns[6]) - Start scores = (37, 23). - Player 0 rolls 5 dice and gets outcomes [5, 3, 4, 1, 6]. - End scores = (41, 23) - >>> print(turns[7]) - Start scores = (41, 23). - Player 1 rolls 10 dice and gets outcomes [5, 1, 5, 6, 1, 1, 3, 1, 2, 5]. - End scores = (41, 24) - >>> print(turns[8]) - Start scores = (41, 24). - Player 0 rolls 9 dice and gets outcomes [3, 3, 5, 5, 3, 6, 2, 4, 3]. - End scores = (75, 24) - >>> print(turns[9]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=80360, score0=23, score1=11, goal=38, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (23, 11). - Player 0 rolls 1 dice and gets outcomes [2]. - End scores = (25, 11) - >>> print(turns[1]) - Start scores = (25, 11). - Player 1 rolls 2 dice and gets outcomes [6, 1]. - End scores = (25, 12) - >>> print(turns[2]) - Start scores = (25, 12). - Player 0 rolls 4 dice and gets outcomes [2, 1, 2, 1]. - End scores = (26, 12) - >>> print(turns[3]) - Start scores = (26, 12). - Player 1 rolls 8 dice and gets outcomes [2, 2, 5, 4, 2, 3, 5, 6]. - End scores = (26, 41) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=53740, score0=21, score1=18, goal=56, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (21, 18). - Player 0 rolls 1 dice and gets outcomes [5]. - End scores = (26, 18) - >>> print(turns[1]) - Start scores = (26, 18). - Player 1 rolls 9 dice and gets outcomes [2, 3, 4, 6, 1, 4, 3, 5, 2]. - End scores = (26, 19) - >>> print(turns[2]) - Start scores = (26, 19). - Player 0 rolls 1 dice and gets outcomes [3]. - End scores = (29, 19) - >>> print(turns[3]) - Start scores = (29, 19). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (29, 40) - >>> print(turns[4]) - Start scores = (29, 40). - Player 0 rolls 9 dice and gets outcomes [3, 3, 5, 2, 2, 5, 2, 1, 5]. - End scores = (30, 40) - >>> print(turns[5]) - Start scores = (30, 40). - Player 1 rolls 2 dice and gets outcomes [4, 6]. - End scores = (30, 50) - >>> print(turns[6]) - Start scores = (30, 50). - Player 0 rolls 9 dice and gets outcomes [3, 5, 2, 4, 6, 6, 1, 5, 3]. - End scores = (31, 50) - >>> print(turns[7]) - Start scores = (31, 50). - Player 1 rolls 3 dice and gets outcomes [1, 4, 6]. - End scores = (31, 51) - >>> print(turns[8]) - Start scores = (31, 51). - Player 0 rolls 9 dice and gets outcomes [3, 1, 5, 5, 2, 6, 1, 6, 6]. - End scores = (32, 51) - >>> print(turns[9]) - Start scores = (32, 51). - Player 1 rolls 1 dice and gets outcomes [5]. - End scores = (32, 56) - >>> print(turns[10]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=53943, score0=29, score1=9, goal=50, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (29, 9). - Player 0 rolls 4 dice and gets outcomes [6, 3, 3, 4]. - End scores = (45, 9) - >>> print(turns[1]) - Start scores = (45, 9). - Player 1 rolls 9 dice and gets outcomes [4, 1, 5, 3, 3, 3, 4, 2, 3]. - End scores = (45, 11) - >>> print(turns[2]) - Start scores = (45, 11). - Player 0 rolls 9 dice and gets outcomes [6, 6, 5, 3, 4, 1, 4, 1, 1]. - End scores = (47, 11) - >>> print(turns[3]) - Start scores = (47, 11). - Player 1 rolls 2 dice and gets outcomes [3, 6]. - End scores = (47, 20) - >>> print(turns[4]) - Start scores = (47, 20). - Player 0 rolls 9 dice and gets outcomes [3, 3, 6, 6, 2, 1, 6, 3, 3]. - End scores = (48, 20) - >>> print(turns[5]) - Start scores = (48, 20). - Player 1 rolls 1 dice and gets outcomes [3]. - End scores = (48, 23) - >>> print(turns[6]) - Start scores = (48, 23). - Player 0 rolls 9 dice and gets outcomes [6, 4, 2, 3, 1, 2, 2, 2, 2]. - End scores = (53, 23) - >>> print(turns[7]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=85875, score0=21, score1=66, goal=67, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (21, 66). - Player 0 rolls 2 dice and gets outcomes [2, 1]. - End scores = (22, 66) - >>> print(turns[1]) - Start scores = (22, 66). - Player 1 rolls 4 dice and gets outcomes [5, 5, 2, 2]. - End scores = (22, 80) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=20869, score0=28, score1=16, goal=39, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (28, 16). - Player 0 rolls 7 dice and gets outcomes [4, 5, 4, 5, 2, 3, 1]. - End scores = (29, 16) - >>> print(turns[1]) - Start scores = (29, 16). - Player 1 rolls 3 dice and gets outcomes [1, 6, 2]. - End scores = (29, 17) - >>> print(turns[2]) - Start scores = (29, 17). - Player 0 rolls 6 dice and gets outcomes [6, 1, 1, 2, 2, 6]. - End scores = (30, 17) - >>> print(turns[3]) - Start scores = (30, 17). - Player 1 rolls 9 dice and gets outcomes [6, 4, 4, 2, 5, 6, 1, 5, 5]. - End scores = (30, 18) - >>> print(turns[4]) - Start scores = (30, 18). - Player 0 rolls 10 dice and gets outcomes [2, 5, 2, 4, 6, 2, 1, 4, 6, 3]. - End scores = (31, 18) - >>> print(turns[5]) - Start scores = (31, 18). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (31, 37) - >>> print(turns[6]) - Start scores = (31, 37). - Player 0 rolls 5 dice and gets outcomes [4, 4, 1, 1, 6]. - End scores = (32, 37) - >>> print(turns[7]) - Start scores = (32, 37). - Player 1 rolls 8 dice and gets outcomes [5, 5, 5, 2, 2, 4, 4, 1]. - End scores = (32, 41) - >>> print(turns[8]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=98819, score0=10, score1=37, goal=50, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (10, 37). - Player 0 rolls 8 dice and gets outcomes [4, 3, 5, 4, 6, 1, 4, 3]. - End scores = (11, 37) - >>> print(turns[1]) - Start scores = (11, 37). - Player 1 rolls 1 dice and gets outcomes [5]. - End scores = (11, 42) - >>> print(turns[2]) - Start scores = (11, 42). - Player 0 rolls 5 dice and gets outcomes [3, 4, 5, 4, 4]. - End scores = (31, 42) - >>> print(turns[3]) - Start scores = (31, 42). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (31, 45) - >>> print(turns[4]) - Start scores = (31, 45). - Player 0 rolls 8 dice and gets outcomes [1, 1, 1, 6, 4, 6, 5, 5]. - End scores = (32, 45) - >>> print(turns[5]) - Start scores = (32, 45). - Player 1 rolls 5 dice and gets outcomes [2, 3, 5, 4, 5]. - End scores = (32, 64) - >>> print(turns[6]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=82794, score0=60, score1=43, goal=61, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (60, 43). - Player 0 rolls 3 dice and gets outcomes [3, 5, 2]. - End scores = (70, 43) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=83069, score0=7, score1=76, goal=80, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (7, 76). - Player 0 rolls 10 dice and gets outcomes [1, 5, 2, 6, 4, 6, 1, 1, 2, 5]. - End scores = (8, 76) - >>> print(turns[1]) - Start scores = (8, 76). - Player 1 rolls 4 dice and gets outcomes [4, 4, 5, 5]. - End scores = (8, 94) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=95167, score0=30, score1=33, goal=60, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (30, 33). - Player 0 rolls 10 dice and gets outcomes [6, 6, 6, 5, 3, 3, 3, 3, 4, 5]. - End scores = (79, 33) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=70738, score0=16, score1=15, goal=23, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (16, 15). - Player 0 rolls 7 dice and gets outcomes [2, 3, 5, 2, 1, 2, 4]. - End scores = (17, 15) - >>> print(turns[1]) - Start scores = (17, 15). - Player 1 rolls 4 dice and gets outcomes [4, 1, 1, 3]. - End scores = (17, 16) - >>> print(turns[2]) - Start scores = (17, 16). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (35, 16) - >>> print(turns[3]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=28923, score0=8, score1=25, goal=50, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (8, 25). - Player 0 rolls 8 dice and gets outcomes [5, 1, 1, 2, 5, 2, 2, 1]. - End scores = (11, 25) - >>> print(turns[1]) - Start scores = (11, 25). - Player 1 rolls 9 dice and gets outcomes [6, 2, 2, 1, 6, 1, 1, 3, 1]. - End scores = (11, 29) - >>> print(turns[2]) - Start scores = (11, 29). - Player 0 rolls 7 dice and gets outcomes [1, 2, 3, 3, 3, 6, 2]. - End scores = (12, 29) - >>> print(turns[3]) - Start scores = (12, 29). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (12, 53) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=58200, score0=32, score1=95, goal=99, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (32, 95). - Player 0 rolls 6 dice and gets outcomes [5, 3, 4, 6, 1, 5]. - End scores = (37, 95) - >>> print(turns[1]) - Start scores = (37, 95). - Player 1 rolls 6 dice and gets outcomes [2, 5, 3, 3, 6, 4]. - End scores = (37, 127) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=72093, score0=5, score1=20, goal=31, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (5, 20). - Player 0 rolls 1 dice and gets outcomes [5]. - End scores = (11, 20) - >>> print(turns[1]) - Start scores = (11, 20). - Player 1 rolls 7 dice and gets outcomes [3, 4, 3, 5, 2, 6, 1]. - End scores = (11, 23) - >>> print(turns[2]) - Start scores = (11, 23). - Player 0 rolls 5 dice and gets outcomes [3, 2, 3, 2, 6]. - End scores = (29, 23) - >>> print(turns[3]) - Start scores = (29, 23). - Player 1 rolls 5 dice and gets outcomes [5, 3, 4, 5, 6]. - End scores = (29, 47) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=71578, score0=16, score1=49, goal=81, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (16, 49). - Player 0 rolls 6 dice and gets outcomes [4, 3, 2, 1, 6, 3]. - End scores = (17, 49) - >>> print(turns[1]) - Start scores = (17, 49). - Player 1 rolls 10 dice and gets outcomes [6, 3, 6, 6, 2, 1, 2, 6, 3, 1]. - End scores = (17, 50) - >>> print(turns[2]) - Start scores = (17, 50). - Player 0 rolls 5 dice and gets outcomes [2, 5, 3, 5, 3]. - End scores = (37, 50) - >>> print(turns[3]) - Start scores = (37, 50). - Player 1 rolls 3 dice and gets outcomes [3, 1, 3]. - End scores = (37, 53) - >>> print(turns[4]) - Start scores = (37, 53). - Player 0 rolls 9 dice and gets outcomes [3, 5, 2, 5, 2, 6, 3, 5, 5]. - End scores = (73, 53) - >>> print(turns[5]) - Start scores = (73, 53). - Player 1 rolls 7 dice and gets outcomes [4, 3, 6, 1, 5, 3, 2]. - End scores = (73, 54) - >>> print(turns[6]) - Start scores = (73, 54). - Player 0 rolls 7 dice and gets outcomes [2, 2, 4, 6, 3, 6, 6]. - End scores = (102, 54) - >>> print(turns[7]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=72869, score0=5, score1=4, goal=11, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (5, 4). - Player 0 rolls 2 dice and gets outcomes [3, 1]. - End scores = (7, 4) - >>> print(turns[1]) - Start scores = (7, 4). - Player 1 rolls 2 dice and gets outcomes [5, 4]. - End scores = (7, 13) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=66473, score0=39, score1=74, goal=81, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (39, 74). - Player 0 rolls 6 dice and gets outcomes [5, 3, 3, 1, 5, 4]. - End scores = (40, 74) - >>> print(turns[1]) - Start scores = (40, 74). - Player 1 rolls 3 dice and gets outcomes [3, 3, 1]. - End scores = (40, 75) - >>> print(turns[2]) - Start scores = (40, 75). - Player 0 rolls 4 dice and gets outcomes [6, 3, 4, 5]. - End scores = (58, 75) - >>> print(turns[3]) - Start scores = (58, 75). - Player 1 rolls 5 dice and gets outcomes [4, 4, 5, 2, 3]. - End scores = (58, 93) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=43296, score0=56, score1=14, goal=69, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (56, 14). - Player 0 rolls 5 dice and gets outcomes [5, 3, 1, 4, 5]. - End scores = (59, 14) - >>> print(turns[1]) - Start scores = (59, 14). - Player 1 rolls 3 dice and gets outcomes [3, 5, 1]. - End scores = (59, 17) - >>> print(turns[2]) - Start scores = (59, 17). - Player 0 rolls 10 dice and gets outcomes [4, 5, 6, 4, 6, 4, 3, 4, 6, 2]. - End scores = (103, 17) - >>> print(turns[3]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=15289, score0=61, score1=5, goal=69, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (61, 5). - Player 0 rolls 5 dice and gets outcomes [6, 4, 6, 5, 4]. - End scores = (86, 5) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=13609, score0=14, score1=0, goal=15, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (14, 0). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (26, 0) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=99130, score0=70, score1=53, goal=72, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (70, 53). - Player 0 rolls 2 dice and gets outcomes [5, 3]. - End scores = (78, 53) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=32108, score0=9, score1=37, goal=93, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (9, 37). - Player 0 rolls 9 dice and gets outcomes [1, 2, 1, 2, 2, 5, 2, 6, 5]. - End scores = (11, 37) - >>> print(turns[1]) - Start scores = (11, 37). - Player 1 rolls 6 dice and gets outcomes [4, 2, 6, 4, 3, 6]. - End scores = (11, 67) - >>> print(turns[2]) - Start scores = (11, 67). - Player 0 rolls 1 dice and gets outcomes [6]. - End scores = (17, 67) - >>> print(turns[3]) - Start scores = (17, 67). - Player 1 rolls 9 dice and gets outcomes [2, 1, 4, 5, 2, 2, 1, 5, 1]. - End scores = (17, 68) - >>> print(turns[4]) - Start scores = (17, 68). - Player 0 rolls 5 dice and gets outcomes [4, 6, 3, 2, 6]. - End scores = (41, 68) - >>> print(turns[5]) - Start scores = (41, 68). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (41, 80) - >>> print(turns[6]) - Start scores = (41, 80). - Player 0 rolls 6 dice and gets outcomes [4, 4, 2, 2, 1, 3]. - End scores = (42, 80) - >>> print(turns[7]) - Start scores = (42, 80). - Player 1 rolls 6 dice and gets outcomes [5, 1, 2, 3, 4, 2]. - End scores = (42, 81) - >>> print(turns[8]) - Start scores = (42, 81). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (60, 81) - >>> print(turns[9]) - Start scores = (60, 81). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (60, 96) - >>> print(turns[10]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=2069, score0=55, score1=37, goal=64, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (55, 37). - Player 0 rolls 9 dice and gets outcomes [3, 3, 2, 5, 5, 6, 5, 4, 1]. - End scores = (56, 37) - >>> print(turns[1]) - Start scores = (56, 37). - Player 1 rolls 3 dice and gets outcomes [3, 3, 2]. - End scores = (56, 45) - >>> print(turns[2]) - Start scores = (56, 45). - Player 0 rolls 9 dice and gets outcomes [6, 1, 1, 3, 5, 5, 1, 1, 5]. - End scores = (57, 45) - >>> print(turns[3]) - Start scores = (57, 45). - Player 1 rolls 4 dice and gets outcomes [5, 4, 6, 2]. - End scores = (57, 62) - >>> print(turns[4]) - Start scores = (57, 62). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (60, 62) - >>> print(turns[5]) - Start scores = (60, 62). - Player 1 rolls 1 dice and gets outcomes [3]. - End scores = (60, 65) - >>> print(turns[6]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=39055, score0=54, score1=8, goal=64, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (54, 8). - Player 0 rolls 6 dice and gets outcomes [5, 6, 3, 4, 5, 5]. - End scores = (83, 8) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=65291, score0=4, score1=3, goal=23, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (4, 3). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (16, 3) - >>> print(turns[1]) - Start scores = (16, 3). - Player 1 rolls 3 dice and gets outcomes [4, 5, 1]. - End scores = (16, 4) - >>> print(turns[2]) - Start scores = (16, 4). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (34, 4) - >>> print(turns[3]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=76703, score0=25, score1=24, goal=76, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (25, 24). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (37, 24) - >>> print(turns[1]) - Start scores = (37, 24). - Player 1 rolls 2 dice and gets outcomes [4, 6]. - End scores = (37, 37) - >>> print(turns[2]) - Start scores = (37, 37). - Player 0 rolls 1 dice and gets outcomes [5]. - End scores = (42, 37) - >>> print(turns[3]) - Start scores = (42, 37). - Player 1 rolls 10 dice and gets outcomes [5, 3, 6, 2, 6, 3, 4, 6, 4, 3]. - End scores = (42, 79) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=27707, score0=55, score1=8, goal=66, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (55, 8). - Player 0 rolls 8 dice and gets outcomes [5, 1, 5, 6, 5, 4, 1, 4]. - End scores = (56, 8) - >>> print(turns[1]) - Start scores = (56, 8). - Player 1 rolls 8 dice and gets outcomes [6, 3, 1, 6, 5, 2, 1, 1]. - End scores = (56, 9) - >>> print(turns[2]) - Start scores = (56, 9). - Player 0 rolls 1 dice and gets outcomes [2]. - End scores = (58, 9) - >>> print(turns[3]) - Start scores = (58, 9). - Player 1 rolls 3 dice and gets outcomes [3, 1, 2]. - End scores = (58, 10) - >>> print(turns[4]) - Start scores = (58, 10). - Player 0 rolls 8 dice and gets outcomes [6, 2, 3, 5, 4, 2, 2, 5]. - End scores = (87, 10) - >>> print(turns[5]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=95614, score0=21, score1=52, goal=74, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (21, 52). - Player 0 rolls 4 dice and gets outcomes [4, 5, 4, 5]. - End scores = (41, 52) - >>> print(turns[1]) - Start scores = (41, 52). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (41, 59) - >>> print(turns[2]) - Start scores = (41, 59). - Player 0 rolls 9 dice and gets outcomes [6, 2, 6, 4, 3, 1, 3, 6, 2]. - End scores = (42, 59) - >>> print(turns[3]) - Start scores = (42, 59). - Player 1 rolls 8 dice and gets outcomes [5, 1, 5, 6, 2, 3, 2, 4]. - End scores = (42, 60) - >>> print(turns[4]) - Start scores = (42, 60). - Player 0 rolls 8 dice and gets outcomes [1, 4, 1, 4, 6, 3, 3, 2]. - End scores = (43, 60) - >>> print(turns[5]) - Start scores = (43, 60). - Player 1 rolls 3 dice and gets outcomes [5, 2, 5]. - End scores = (43, 72) - >>> print(turns[6]) - Start scores = (43, 72). - Player 0 rolls 4 dice and gets outcomes [5, 5, 4, 4]. - End scores = (61, 72) - >>> print(turns[7]) - Start scores = (61, 72). - Player 1 rolls 5 dice and gets outcomes [4, 3, 1, 2, 6]. - End scores = (61, 73) - >>> print(turns[8]) - Start scores = (61, 73). - Player 0 rolls 10 dice and gets outcomes [1, 2, 2, 2, 3, 4, 1, 5, 4, 5]. - End scores = (67, 73) - >>> print(turns[9]) - Start scores = (67, 73). - Player 1 rolls 7 dice and gets outcomes [4, 3, 5, 1, 5, 5, 1]. - End scores = (67, 79) - >>> print(turns[10]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=59761, score0=37, score1=12, goal=81, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (37, 12). - Player 0 rolls 9 dice and gets outcomes [5, 2, 6, 2, 5, 1, 4, 3, 5]. - End scores = (38, 12) - >>> print(turns[1]) - Start scores = (38, 12). - Player 1 rolls 7 dice and gets outcomes [5, 5, 4, 3, 2, 1, 6]. - End scores = (38, 13) - >>> print(turns[2]) - Start scores = (38, 13). - Player 0 rolls 4 dice and gets outcomes [4, 5, 6, 5]. - End scores = (58, 13) - >>> print(turns[3]) - Start scores = (58, 13). - Player 1 rolls 2 dice and gets outcomes [5, 5]. - End scores = (58, 23) - >>> print(turns[4]) - Start scores = (58, 23). - Player 0 rolls 4 dice and gets outcomes [5, 2, 1, 4]. - End scores = (59, 23) - >>> print(turns[5]) - Start scores = (59, 23). - Player 1 rolls 1 dice and gets outcomes [2]. - End scores = (59, 25) - >>> print(turns[6]) - Start scores = (59, 25). - Player 0 rolls 2 dice and gets outcomes [2, 4]. - End scores = (65, 25) - >>> print(turns[7]) - Start scores = (65, 25). - Player 1 rolls 4 dice and gets outcomes [2, 3, 3, 3]. - End scores = (65, 36) - >>> print(turns[8]) - Start scores = (65, 36). - Player 0 rolls 5 dice and gets outcomes [5, 5, 6, 5, 5]. - End scores = (91, 36) - >>> print(turns[9]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=12023, score0=20, score1=6, goal=42, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (20, 6). - Player 0 rolls 4 dice and gets outcomes [1, 1, 5, 2]. - End scores = (21, 6) - >>> print(turns[1]) - Start scores = (21, 6). - Player 1 rolls 10 dice and gets outcomes [6, 1, 2, 6, 2, 3, 5, 5, 5, 3]. - End scores = (21, 7) - >>> print(turns[2]) - Start scores = (21, 7). - Player 0 rolls 2 dice and gets outcomes [2, 4]. - End scores = (27, 7) - >>> print(turns[3]) - Start scores = (27, 7). - Player 1 rolls 7 dice and gets outcomes [3, 5, 5, 5, 1, 3, 5]. - End scores = (27, 8) - >>> print(turns[4]) - Start scores = (27, 8). - Player 0 rolls 4 dice and gets outcomes [1, 4, 2, 5]. - End scores = (28, 8) - >>> print(turns[5]) - Start scores = (28, 8). - Player 1 rolls 7 dice and gets outcomes [4, 6, 2, 3, 6, 4, 4]. - End scores = (28, 37) - >>> print(turns[6]) - Start scores = (28, 37). - Player 0 rolls 2 dice and gets outcomes [1, 6]. - End scores = (29, 37) - >>> print(turns[7]) - Start scores = (29, 37). - Player 1 rolls 5 dice and gets outcomes [4, 2, 5, 1, 4]. - End scores = (29, 38) - >>> print(turns[8]) - Start scores = (29, 38). - Player 0 rolls 1 dice and gets outcomes [4]. - End scores = (33, 38) - >>> print(turns[9]) - Start scores = (33, 38). - Player 1 rolls 3 dice and gets outcomes [6, 1, 1]. - End scores = (33, 39) - >>> print(turns[10]) - Start scores = (33, 39). - Player 0 rolls 2 dice and gets outcomes [1, 2]. - End scores = (34, 39) - >>> print(turns[11]) - Start scores = (34, 39). - Player 1 rolls 7 dice and gets outcomes [2, 6, 1, 2, 1, 2, 1]. - End scores = (34, 40) - >>> print(turns[12]) - Start scores = (34, 40). - Player 0 rolls 1 dice and gets outcomes [4]. - End scores = (38, 40) - >>> print(turns[13]) - Start scores = (38, 40). - Player 1 rolls 10 dice and gets outcomes [1, 4, 4, 1, 2, 1, 4, 1, 5, 1]. - End scores = (38, 41) - >>> print(turns[14]) - Start scores = (38, 41). - Player 0 rolls 6 dice and gets outcomes [1, 5, 3, 5, 2, 5]. - End scores = (39, 41) - >>> print(turns[15]) - Start scores = (39, 41). - Player 1 rolls 1 dice and gets outcomes [1]. - End scores = (39, 42) - >>> print(turns[16]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=9065, score0=45, score1=30, goal=46, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (45, 30). - Player 0 rolls 1 dice and gets outcomes [2]. - End scores = (47, 30) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=52376, score0=72, score1=18, goal=75, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (72, 18). - Player 0 rolls 4 dice and gets outcomes [4, 4, 5, 3]. - End scores = (88, 18) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=47323, score0=23, score1=6, goal=92, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (23, 6). - Player 0 rolls 2 dice and gets outcomes [4, 1]. - End scores = (24, 6) - >>> print(turns[1]) - Start scores = (24, 6). - Player 1 rolls 6 dice and gets outcomes [4, 1, 6, 2, 5, 4]. - End scores = (24, 7) - >>> print(turns[2]) - Start scores = (24, 7). - Player 0 rolls 7 dice and gets outcomes [2, 3, 5, 2, 4, 5, 4]. - End scores = (49, 7) - >>> print(turns[3]) - Start scores = (49, 7). - Player 1 rolls 9 dice and gets outcomes [3, 4, 2, 5, 6, 5, 6, 2, 4]. - End scores = (49, 44) - >>> print(turns[4]) - Start scores = (49, 44). - Player 0 rolls 7 dice and gets outcomes [6, 2, 6, 2, 1, 1, 2]. - End scores = (50, 44) - >>> print(turns[5]) - Start scores = (50, 44). - Player 1 rolls 9 dice and gets outcomes [5, 4, 3, 1, 4, 1, 1, 1, 4]. - End scores = (50, 45) - >>> print(turns[6]) - Start scores = (50, 45). - Player 0 rolls 6 dice and gets outcomes [6, 4, 4, 2, 6, 5]. - End scores = (77, 45) - >>> print(turns[7]) - Start scores = (77, 45). - Player 1 rolls 4 dice and gets outcomes [6, 1, 1, 6]. - End scores = (77, 46) - >>> print(turns[8]) - Start scores = (77, 46). - Player 0 rolls 7 dice and gets outcomes [6, 1, 1, 4, 5, 3, 1]. - End scores = (78, 46) - >>> print(turns[9]) - Start scores = (78, 46). - Player 1 rolls 3 dice and gets outcomes [5, 5, 5]. - End scores = (78, 61) - >>> print(turns[10]) - Start scores = (78, 61). - Player 0 rolls 3 dice and gets outcomes [1, 4, 1]. - End scores = (79, 61) - >>> print(turns[11]) - Start scores = (79, 61). - Player 1 rolls 7 dice and gets outcomes [2, 5, 3, 5, 3, 1, 5]. - End scores = (79, 62) - >>> print(turns[12]) - Start scores = (79, 62). - Player 0 rolls 9 dice and gets outcomes [2, 1, 2, 4, 6, 1, 2, 5, 4]. - End scores = (80, 62) - >>> print(turns[13]) - Start scores = (80, 62). - Player 1 rolls 3 dice and gets outcomes [6, 3, 4]. - End scores = (80, 75) - >>> print(turns[14]) - Start scores = (80, 75). - Player 0 rolls 7 dice and gets outcomes [1, 6, 1, 2, 2, 3, 1]. - End scores = (81, 75) - >>> print(turns[15]) - Start scores = (81, 75). - Player 1 rolls 7 dice and gets outcomes [4, 3, 3, 3, 4, 6, 4]. - End scores = (81, 102) - >>> print(turns[16]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=44237, score0=12, score1=79, goal=89, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (12, 79). - Player 0 rolls 3 dice and gets outcomes [3, 3, 4]. - End scores = (23, 79) - >>> print(turns[1]) - Start scores = (23, 79). - Player 1 rolls 7 dice and gets outcomes [5, 4, 3, 6, 3, 6, 6]. - End scores = (23, 112) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=27065, score0=2, score1=0, goal=12, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (2, 0). - Player 0 rolls 5 dice and gets outcomes [5, 2, 2, 1, 3]. - End scores = (3, 0) - >>> print(turns[1]) - Start scores = (3, 0). - Player 1 rolls 3 dice and gets outcomes [2, 1, 3]. - End scores = (3, 1) - >>> print(turns[2]) - Start scores = (3, 1). - Player 0 rolls 6 dice and gets outcomes [4, 5, 2, 2, 4, 3]. - End scores = (23, 1) - >>> print(turns[3]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=37376, score0=71, score1=22, goal=97, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (71, 22). - Player 0 rolls 5 dice and gets outcomes [6, 3, 1, 2, 5]. - End scores = (72, 22) - >>> print(turns[1]) - Start scores = (72, 22). - Player 1 rolls 3 dice and gets outcomes [3, 6, 6]. - End scores = (72, 37) - >>> print(turns[2]) - Start scores = (72, 37). - Player 0 rolls 9 dice and gets outcomes [6, 2, 5, 3, 2, 2, 2, 5, 4]. - End scores = (103, 37) - >>> print(turns[3]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=97077, score0=13, score1=2, goal=17, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (13, 2). - Player 0 rolls 10 dice and gets outcomes [1, 5, 3, 4, 3, 1, 5, 5, 1, 6]. - End scores = (17, 2) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=66508, score0=38, score1=25, goal=97, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (38, 25). - Player 0 rolls 1 dice and gets outcomes [6]. - End scores = (44, 25) - >>> print(turns[1]) - Start scores = (44, 25). - Player 1 rolls 4 dice and gets outcomes [4, 4, 2, 3]. - End scores = (44, 41) - >>> print(turns[2]) - Start scores = (44, 41). - Player 0 rolls 4 dice and gets outcomes [1, 5, 3, 4]. - End scores = (45, 41) - >>> print(turns[3]) - Start scores = (45, 41). - Player 1 rolls 4 dice and gets outcomes [2, 4, 3, 1]. - End scores = (45, 42) - >>> print(turns[4]) - Start scores = (45, 42). - Player 0 rolls 2 dice and gets outcomes [6, 2]. - End scores = (53, 42) - >>> print(turns[5]) - Start scores = (53, 42). - Player 1 rolls 9 dice and gets outcomes [5, 2, 2, 2, 6, 4, 3, 3, 6]. - End scores = (53, 75) - >>> print(turns[6]) - Start scores = (53, 75). - Player 0 rolls 9 dice and gets outcomes [1, 6, 6, 6, 1, 1, 2, 2, 2]. - End scores = (54, 75) - >>> print(turns[7]) - Start scores = (54, 75). - Player 1 rolls 2 dice and gets outcomes [3, 6]. - End scores = (54, 84) - >>> print(turns[8]) - Start scores = (54, 84). - Player 0 rolls 5 dice and gets outcomes [4, 5, 3, 2, 3]. - End scores = (71, 84) - >>> print(turns[9]) - Start scores = (71, 84). - Player 1 rolls 2 dice and gets outcomes [1, 3]. - End scores = (71, 89) - >>> print(turns[10]) - Start scores = (71, 89). - Player 0 rolls 2 dice and gets outcomes [5, 3]. - End scores = (79, 89) - >>> print(turns[11]) - Start scores = (79, 89). - Player 1 rolls 6 dice and gets outcomes [2, 6, 3, 6, 3, 1]. - End scores = (79, 90) - >>> print(turns[12]) - Start scores = (79, 90). - Player 0 rolls 1 dice and gets outcomes [4]. - End scores = (83, 90) - >>> print(turns[13]) - Start scores = (83, 90). - Player 1 rolls 3 dice and gets outcomes [3, 4, 3]. - End scores = (83, 100) - >>> print(turns[14]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=75418, score0=2, score1=5, goal=11, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (2, 5). - Player 0 rolls 2 dice and gets outcomes [4, 4]. - End scores = (10, 5) - >>> print(turns[1]) - Start scores = (10, 5). - Player 1 rolls 7 dice and gets outcomes [6, 3, 6, 1, 4, 6, 5]. - End scores = (10, 6) - >>> print(turns[2]) - Start scores = (10, 6). - Player 0 rolls 7 dice and gets outcomes [6, 1, 6, 5, 2, 2, 1]. - End scores = (11, 6) - >>> print(turns[3]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=68629, score0=17, score1=25, goal=47, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (17, 25). - Player 0 rolls 4 dice and gets outcomes [2, 6, 2, 1]. - End scores = (18, 25) - >>> print(turns[1]) - Start scores = (18, 25). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (18, 37) - >>> print(turns[2]) - Start scores = (18, 37). - Player 0 rolls 8 dice and gets outcomes [3, 3, 1, 1, 1, 5, 5, 3]. - End scores = (19, 37) - >>> print(turns[3]) - Start scores = (19, 37). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (19, 55) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=1568, score0=3, score1=29, goal=51, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (3, 29). - Player 0 rolls 1 dice and gets outcomes [4]. - End scores = (7, 29) - >>> print(turns[1]) - Start scores = (7, 29). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (7, 56) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=72434, score0=8, score1=45, goal=67, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (8, 45). - Player 0 rolls 8 dice and gets outcomes [6, 1, 6, 6, 6, 3, 5, 4]. - End scores = (9, 45) - >>> print(turns[1]) - Start scores = (9, 45). - Player 1 rolls 4 dice and gets outcomes [3, 3, 4, 4]. - End scores = (9, 59) - >>> print(turns[2]) - Start scores = (9, 59). - Player 0 rolls 9 dice and gets outcomes [3, 2, 5, 5, 1, 6, 4, 3, 3]. - End scores = (10, 59) - >>> print(turns[3]) - Start scores = (10, 59). - Player 1 rolls 5 dice and gets outcomes [5, 6, 6, 6, 5]. - End scores = (10, 87) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=55979, score0=75, score1=80, goal=95, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (75, 80). - Player 0 rolls 4 dice and gets outcomes [4, 1, 6, 4]. - End scores = (76, 80) - >>> print(turns[1]) - Start scores = (76, 80). - Player 1 rolls 4 dice and gets outcomes [3, 1, 1, 3]. - End scores = (76, 81) - >>> print(turns[2]) - Start scores = (76, 81). - Player 0 rolls 3 dice and gets outcomes [2, 5, 6]. - End scores = (89, 81) - >>> print(turns[3]) - Start scores = (89, 81). - Player 1 rolls 4 dice and gets outcomes [3, 2, 5, 5]. - End scores = (89, 96) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=93729, score0=37, score1=63, goal=83, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (37, 63). - Player 0 rolls 8 dice and gets outcomes [3, 1, 1, 4, 5, 5, 1, 5]. - End scores = (41, 63) - >>> print(turns[1]) - Start scores = (41, 63). - Player 1 rolls 2 dice and gets outcomes [2, 5]. - End scores = (41, 70) - >>> print(turns[2]) - Start scores = (41, 70). - Player 0 rolls 6 dice and gets outcomes [1, 3, 3, 5, 3, 3]. - End scores = (42, 70) - >>> print(turns[3]) - Start scores = (42, 70). - Player 1 rolls 7 dice and gets outcomes [6, 5, 3, 3, 3, 3, 5]. - End scores = (42, 98) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=53739, score0=54, score1=50, goal=58, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (54, 50). - Player 0 rolls 9 dice and gets outcomes [4, 3, 5, 6, 3, 2, 3, 4, 2]. - End scores = (86, 50) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=30305, score0=21, score1=1, goal=55, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (21, 1). - Player 0 rolls 6 dice and gets outcomes [1, 6, 5, 2, 2, 5]. - End scores = (23, 1) - >>> print(turns[1]) - Start scores = (23, 1). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (23, 5) - >>> print(turns[2]) - Start scores = (23, 5). - Player 0 rolls 3 dice and gets outcomes [6, 4, 6]. - End scores = (41, 5) - >>> print(turns[3]) - Start scores = (41, 5). - Player 1 rolls 6 dice and gets outcomes [4, 1, 3, 3, 5, 3]. - End scores = (41, 7) - >>> print(turns[4]) - Start scores = (41, 7). - Player 0 rolls 5 dice and gets outcomes [2, 1, 6, 5, 5]. - End scores = (42, 7) - >>> print(turns[5]) - Start scores = (42, 7). - Player 1 rolls 4 dice and gets outcomes [4, 3, 6, 3]. - End scores = (42, 23) - >>> print(turns[6]) - Start scores = (42, 23). - Player 0 rolls 5 dice and gets outcomes [4, 1, 5, 4, 6]. - End scores = (43, 23) - >>> print(turns[7]) - Start scores = (43, 23). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (43, 29) - >>> print(turns[8]) - Start scores = (43, 29). - Player 0 rolls 5 dice and gets outcomes [3, 1, 4, 3, 4]. - End scores = (44, 29) - >>> print(turns[9]) - Start scores = (44, 29). - Player 1 rolls 7 dice and gets outcomes [2, 1, 5, 2, 3, 4, 3]. - End scores = (44, 30) - >>> print(turns[10]) - Start scores = (44, 30). - Player 0 rolls 3 dice and gets outcomes [4, 5, 3]. - End scores = (56, 30) - >>> print(turns[11]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=63941, score0=1, score1=44, goal=73, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (1, 44). - Player 0 rolls 6 dice and gets outcomes [2, 1, 1, 5, 1, 6]. - End scores = (2, 44) - >>> print(turns[1]) - Start scores = (2, 44). - Player 1 rolls 9 dice and gets outcomes [5, 2, 3, 5, 1, 1, 5, 5, 1]. - End scores = (2, 45) - >>> print(turns[2]) - Start scores = (2, 45). - Player 0 rolls 8 dice and gets outcomes [5, 4, 3, 4, 3, 1, 2, 2]. - End scores = (3, 45) - >>> print(turns[3]) - Start scores = (3, 45). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (3, 60) - >>> print(turns[4]) - Start scores = (3, 60). - Player 0 rolls 9 dice and gets outcomes [2, 6, 5, 5, 2, 2, 3, 2, 1]. - End scores = (4, 60) - >>> print(turns[5]) - Start scores = (4, 60). - Player 1 rolls 2 dice and gets outcomes [4, 3]. - End scores = (4, 67) - >>> print(turns[6]) - Start scores = (4, 67). - Player 0 rolls 8 dice and gets outcomes [6, 6, 4, 5, 3, 3, 4, 3]. - End scores = (38, 67) - >>> print(turns[7]) - Start scores = (38, 67). - Player 1 rolls 5 dice and gets outcomes [2, 6, 5, 6, 6]. - End scores = (38, 92) - >>> print(turns[8]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=55351, score0=33, score1=18, goal=69, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (33, 18). - Player 0 rolls 7 dice and gets outcomes [5, 2, 1, 2, 3, 5, 1]. - End scores = (34, 18) - >>> print(turns[1]) - Start scores = (34, 18). - Player 1 rolls 10 dice and gets outcomes [4, 4, 2, 2, 2, 2, 2, 5, 6, 2]. - End scores = (34, 49) - >>> print(turns[2]) - Start scores = (34, 49). - Player 0 rolls 1 dice and gets outcomes [2]. - End scores = (36, 49) - >>> print(turns[3]) - Start scores = (36, 49). - Player 1 rolls 1 dice and gets outcomes [5]. - End scores = (36, 54) - >>> print(turns[4]) - Start scores = (36, 54). - Player 0 rolls 7 dice and gets outcomes [3, 1, 1, 5, 2, 2, 6]. - End scores = (37, 54) - >>> print(turns[5]) - Start scores = (37, 54). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (37, 57) - >>> print(turns[6]) - Start scores = (37, 57). - Player 0 rolls 2 dice and gets outcomes [5, 6]. - End scores = (48, 57) - >>> print(turns[7]) - Start scores = (48, 57). - Player 1 rolls 4 dice and gets outcomes [1, 2, 4, 2]. - End scores = (48, 58) - >>> print(turns[8]) - Start scores = (48, 58). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (57, 58) - >>> print(turns[9]) - Start scores = (57, 58). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (57, 67) - >>> print(turns[10]) - Start scores = (57, 67). - Player 0 rolls 3 dice and gets outcomes [3, 6, 1]. - End scores = (58, 67) - >>> print(turns[11]) - Start scores = (58, 67). - Player 1 rolls 6 dice and gets outcomes [1, 2, 2, 2, 5, 6]. - End scores = (58, 68) - >>> print(turns[12]) - Start scores = (58, 68). - Player 0 rolls 9 dice and gets outcomes [3, 3, 6, 3, 6, 2, 3, 2, 1]. - End scores = (59, 68) - >>> print(turns[13]) - Start scores = (59, 68). - Player 1 rolls 6 dice and gets outcomes [1, 3, 6, 4, 3, 3]. - End scores = (59, 69) - >>> print(turns[14]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=50979, score0=50, score1=2, goal=56, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (50, 2). - Player 0 rolls 5 dice and gets outcomes [6, 2, 3, 4, 5]. - End scores = (70, 2) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=64647, score0=11, score1=5, goal=33, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (11, 5). - Player 0 rolls 1 dice and gets outcomes [1]. - End scores = (12, 5) - >>> print(turns[1]) - Start scores = (12, 5). - Player 1 rolls 9 dice and gets outcomes [6, 6, 6, 6, 2, 3, 4, 6, 3]. - End scores = (12, 47) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=87563, score0=63, score1=55, goal=90, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (63, 55). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (69, 55) - >>> print(turns[1]) - Start scores = (69, 55). - Player 1 rolls 10 dice and gets outcomes [5, 5, 4, 2, 4, 6, 2, 5, 6, 6]. - End scores = (69, 100) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=46403, score0=9, score1=12, goal=13, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (9, 12). - Player 0 rolls 9 dice and gets outcomes [4, 6, 3, 2, 3, 2, 6, 4, 1]. - End scores = (11, 12) - >>> print(turns[1]) - Start scores = (11, 12). - Player 1 rolls 4 dice and gets outcomes [1, 1, 6, 3]. - End scores = (11, 13) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=77217, score0=2, score1=39, goal=83, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (2, 39). - Player 0 rolls 3 dice and gets outcomes [6, 4, 6]. - End scores = (18, 39) - >>> print(turns[1]) - Start scores = (18, 39). - Player 1 rolls 10 dice and gets outcomes [4, 4, 5, 1, 2, 3, 3, 5, 6, 3]. - End scores = (18, 40) - >>> print(turns[2]) - Start scores = (18, 40). - Player 0 rolls 9 dice and gets outcomes [3, 6, 6, 3, 3, 2, 2, 5, 5]. - End scores = (53, 40) - >>> print(turns[3]) - Start scores = (53, 40). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (53, 59) - >>> print(turns[4]) - Start scores = (53, 59). - Player 0 rolls 8 dice and gets outcomes [4, 3, 4, 4, 6, 6, 6, 1]. - End scores = (54, 59) - >>> print(turns[5]) - Start scores = (54, 59). - Player 1 rolls 8 dice and gets outcomes [1, 6, 6, 5, 3, 3, 5, 1]. - End scores = (54, 60) - >>> print(turns[6]) - Start scores = (54, 60). - Player 0 rolls 6 dice and gets outcomes [5, 2, 5, 1, 1, 4]. - End scores = (59, 60) - >>> print(turns[7]) - Start scores = (59, 60). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (59, 75) - >>> print(turns[8]) - Start scores = (59, 75). - Player 0 rolls 1 dice and gets outcomes [1]. - End scores = (60, 75) - >>> print(turns[9]) - Start scores = (60, 75). - Player 1 rolls 4 dice and gets outcomes [4, 5, 6, 3]. - End scores = (60, 97) - >>> print(turns[10]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=32342, score0=1, score1=1, goal=15, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (1, 1). - Player 0 rolls 5 dice and gets outcomes [5, 4, 1, 6, 1]. - End scores = (2, 1) - >>> print(turns[1]) - Start scores = (2, 1). - Player 1 rolls 1 dice and gets outcomes [6]. - End scores = (2, 7) - >>> print(turns[2]) - Start scores = (2, 7). - Player 0 rolls 8 dice and gets outcomes [5, 3, 4, 6, 4, 3, 1, 1]. - End scores = (3, 7) - >>> print(turns[3]) - Start scores = (3, 7). - Player 1 rolls 6 dice and gets outcomes [1, 4, 1, 6, 6, 6]. - End scores = (3, 8) - >>> print(turns[4]) - Start scores = (3, 8). - Player 0 rolls 7 dice and gets outcomes [5, 3, 3, 6, 5, 5, 3]. - End scores = (33, 8) - >>> print(turns[5]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=81605, score0=73, score1=74, goal=91, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (73, 74). - Player 0 rolls 1 dice and gets outcomes [4]. - End scores = (79, 74) - >>> print(turns[1]) - Start scores = (79, 74). - Player 1 rolls 4 dice and gets outcomes [3, 4, 5, 2]. - End scores = (79, 88) - >>> print(turns[2]) - Start scores = (79, 88). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (83, 88) - >>> print(turns[3]) - Start scores = (83, 88). - Player 1 rolls 10 dice and gets outcomes [6, 5, 6, 2, 6, 4, 3, 4, 3, 6]. - End scores = (83, 137) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=25561, score0=69, score1=44, goal=89, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (69, 44). - Player 0 rolls 4 dice and gets outcomes [5, 6, 3, 1]. - End scores = (70, 44) - >>> print(turns[1]) - Start scores = (70, 44). - Player 1 rolls 3 dice and gets outcomes [3, 4, 1]. - End scores = (70, 45) - >>> print(turns[2]) - Start scores = (70, 45). - Player 0 rolls 9 dice and gets outcomes [6, 2, 3, 4, 5, 1, 3, 1, 3]. - End scores = (71, 45) - >>> print(turns[3]) - Start scores = (71, 45). - Player 1 rolls 10 dice and gets outcomes [4, 2, 6, 4, 4, 5, 1, 5, 1, 1]. - End scores = (71, 46) - >>> print(turns[4]) - Start scores = (71, 46). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (80, 46) - >>> print(turns[5]) - Start scores = (80, 46). - Player 1 rolls 2 dice and gets outcomes [3, 2]. - End scores = (80, 51) - >>> print(turns[6]) - Start scores = (80, 51). - Player 0 rolls 10 dice and gets outcomes [6, 3, 5, 1, 1, 2, 4, 4, 6, 6]. - End scores = (81, 51) - >>> print(turns[7]) - Start scores = (81, 51). - Player 1 rolls 2 dice and gets outcomes [6, 5]. - End scores = (81, 62) - >>> print(turns[8]) - Start scores = (81, 62). - Player 0 rolls 6 dice and gets outcomes [1, 5, 3, 4, 3, 6]. - End scores = (82, 62) - >>> print(turns[9]) - Start scores = (82, 62). - Player 1 rolls 8 dice and gets outcomes [5, 1, 5, 6, 4, 1, 6, 3]. - End scores = (82, 63) - >>> print(turns[10]) - Start scores = (82, 63). - Player 0 rolls 9 dice and gets outcomes [6, 5, 2, 1, 5, 5, 5, 2, 4]. - End scores = (83, 63) - >>> print(turns[11]) - Start scores = (83, 63). - Player 1 rolls 6 dice and gets outcomes [2, 3, 2, 3, 5, 5]. - End scores = (83, 83) - >>> print(turns[12]) - Start scores = (83, 83). - Player 0 rolls 2 dice and gets outcomes [2, 5]. - End scores = (90, 83) - >>> print(turns[13]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=599, score0=3, score1=0, goal=14, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (3, 0). - Player 0 rolls 7 dice and gets outcomes [2, 3, 2, 4, 1, 2, 6]. - End scores = (5, 0) - >>> print(turns[1]) - Start scores = (5, 0). - Player 1 rolls 7 dice and gets outcomes [3, 4, 5, 2, 4, 4, 5]. - End scores = (5, 29) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=59603, score0=27, score1=58, goal=90, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (27, 58). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (33, 58) - >>> print(turns[1]) - Start scores = (33, 58). - Player 1 rolls 5 dice and gets outcomes [2, 1, 2, 1, 6]. - End scores = (33, 59) - >>> print(turns[2]) - Start scores = (33, 59). - Player 0 rolls 5 dice and gets outcomes [4, 2, 1, 6, 5]. - End scores = (34, 59) - >>> print(turns[3]) - Start scores = (34, 59). - Player 1 rolls 5 dice and gets outcomes [5, 5, 3, 4, 2]. - End scores = (34, 78) - >>> print(turns[4]) - Start scores = (34, 78). - Player 0 rolls 5 dice and gets outcomes [4, 1, 4, 3, 5]. - End scores = (35, 78) - >>> print(turns[5]) - Start scores = (35, 78). - Player 1 rolls 2 dice and gets outcomes [3, 2]. - End scores = (35, 83) - >>> print(turns[6]) - Start scores = (35, 83). - Player 0 rolls 10 dice and gets outcomes [5, 2, 5, 2, 5, 1, 5, 1, 1, 1]. - End scores = (36, 83) - >>> print(turns[7]) - Start scores = (36, 83). - Player 1 rolls 10 dice and gets outcomes [6, 1, 3, 4, 1, 5, 6, 2, 6, 3]. - End scores = (36, 84) - >>> print(turns[8]) - Start scores = (36, 84). - Player 0 rolls 4 dice and gets outcomes [2, 3, 2, 3]. - End scores = (46, 84) - >>> print(turns[9]) - Start scores = (46, 84). - Player 1 rolls 10 dice and gets outcomes [6, 5, 5, 6, 1, 6, 4, 1, 1, 4]. - End scores = (46, 85) - >>> print(turns[10]) - Start scores = (46, 85). - Player 0 rolls 4 dice and gets outcomes [2, 4, 5, 4]. - End scores = (61, 85) - >>> print(turns[11]) - Start scores = (61, 85). - Player 1 rolls 4 dice and gets outcomes [6, 6, 4, 4]. - End scores = (61, 105) - >>> print(turns[12]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=29427, score0=18, score1=35, goal=56, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (18, 35). - Player 0 rolls 7 dice and gets outcomes [6, 4, 3, 1, 5, 5, 4]. - End scores = (19, 35) - >>> print(turns[1]) - Start scores = (19, 35). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (19, 47) - >>> print(turns[2]) - Start scores = (19, 47). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (34, 47) - >>> print(turns[3]) - Start scores = (34, 47). - Player 1 rolls 8 dice and gets outcomes [1, 5, 3, 1, 6, 4, 6, 6]. - End scores = (34, 48) - >>> print(turns[4]) - Start scores = (34, 48). - Player 0 rolls 8 dice and gets outcomes [1, 6, 4, 5, 5, 3, 6, 2]. - End scores = (35, 48) - >>> print(turns[5]) - Start scores = (35, 48). - Player 1 rolls 5 dice and gets outcomes [2, 4, 6, 1, 1]. - End scores = (35, 49) - >>> print(turns[6]) - Start scores = (35, 49). - Player 0 rolls 8 dice and gets outcomes [6, 1, 2, 2, 5, 5, 4, 4]. - End scores = (36, 49) - >>> print(turns[7]) - Start scores = (36, 49). - Player 1 rolls 5 dice and gets outcomes [2, 4, 5, 1, 3]. - End scores = (36, 50) - >>> print(turns[8]) - Start scores = (36, 50). - Player 0 rolls 7 dice and gets outcomes [1, 1, 2, 1, 1, 3, 6]. - End scores = (37, 50) - >>> print(turns[9]) - Start scores = (37, 50). - Player 1 rolls 10 dice and gets outcomes [4, 5, 3, 2, 4, 3, 4, 2, 5, 2]. - End scores = (37, 84) - >>> print(turns[10]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=90865, score0=9, score1=18, goal=35, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (9, 18). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (33, 18) - >>> print(turns[1]) - Start scores = (33, 18). - Player 1 rolls 4 dice and gets outcomes [3, 1, 5, 6]. - End scores = (33, 19) - >>> print(turns[2]) - Start scores = (33, 19). - Player 0 rolls 5 dice and gets outcomes [3, 1, 3, 1, 4]. - End scores = (34, 19) - >>> print(turns[3]) - Start scores = (34, 19). - Player 1 rolls 6 dice and gets outcomes [3, 1, 4, 6, 1, 3]. - End scores = (34, 20) - >>> print(turns[4]) - Start scores = (34, 20). - Player 0 rolls 5 dice and gets outcomes [5, 6, 3, 4, 3]. - End scores = (55, 20) - >>> print(turns[5]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=27412, score0=3, score1=10, goal=22, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (3, 10). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (11, 10) - >>> print(turns[1]) - Start scores = (11, 10). - Player 1 rolls 10 dice and gets outcomes [6, 3, 3, 4, 2, 2, 6, 4, 6, 2]. - End scores = (11, 48) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=64099, score0=14, score1=44, goal=46, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (14, 44). - Player 0 rolls 10 dice and gets outcomes [2, 2, 2, 4, 4, 2, 1, 3, 2, 6]. - End scores = (17, 44) - >>> print(turns[1]) - Start scores = (17, 44). - Player 1 rolls 7 dice and gets outcomes [6, 4, 2, 2, 4, 1, 2]. - End scores = (17, 45) - >>> print(turns[2]) - Start scores = (17, 45). - Player 0 rolls 10 dice and gets outcomes [6, 5, 6, 2, 6, 2, 5, 1, 5, 3]. - End scores = (18, 45) - >>> print(turns[3]) - Start scores = (18, 45). - Player 1 rolls 3 dice and gets outcomes [3, 4, 6]. - End scores = (18, 59) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=99115, score0=30, score1=22, goal=34, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (30, 22). - Player 0 rolls 6 dice and gets outcomes [5, 5, 6, 4, 4, 4]. - End scores = (58, 22) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=41138, score0=84, score1=25, goal=92, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (84, 25). - Player 0 rolls 4 dice and gets outcomes [1, 5, 2, 5]. - End scores = (89, 25) - >>> print(turns[1]) - Start scores = (89, 25). - Player 1 rolls 10 dice and gets outcomes [2, 4, 2, 6, 5, 2, 4, 3, 6, 5]. - End scores = (89, 64) - >>> print(turns[2]) - Start scores = (89, 64). - Player 0 rolls 8 dice and gets outcomes [3, 4, 6, 3, 1, 1, 2, 1]. - End scores = (90, 64) - >>> print(turns[3]) - Start scores = (90, 64). - Player 1 rolls 4 dice and gets outcomes [6, 6, 5, 1]. - End scores = (90, 67) - >>> print(turns[4]) - Start scores = (90, 67). - Player 0 rolls 1 dice and gets outcomes [3]. - End scores = (97, 67) - >>> print(turns[5]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=75946, score0=76, score1=58, goal=91, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (76, 58). - Player 0 rolls 9 dice and gets outcomes [2, 4, 1, 3, 4, 6, 6, 3, 4]. - End scores = (77, 58) - >>> print(turns[1]) - Start scores = (77, 58). - Player 1 rolls 3 dice and gets outcomes [4, 6, 6]. - End scores = (77, 74) - >>> print(turns[2]) - Start scores = (77, 74). - Player 0 rolls 9 dice and gets outcomes [6, 1, 3, 3, 6, 3, 6, 4, 1]. - End scores = (78, 74) - >>> print(turns[3]) - Start scores = (78, 74). - Player 1 rolls 4 dice and gets outcomes [5, 3, 4, 1]. - End scores = (78, 75) - >>> print(turns[4]) - Start scores = (78, 75). - Player 0 rolls 2 dice and gets outcomes [5, 2]. - End scores = (85, 75) - >>> print(turns[5]) - Start scores = (85, 75). - Player 1 rolls 3 dice and gets outcomes [3, 3, 4]. - End scores = (85, 85) - >>> print(turns[6]) - Start scores = (85, 85). - Player 0 rolls 7 dice and gets outcomes [1, 3, 1, 5, 2, 4, 5]. - End scores = (86, 85) - >>> print(turns[7]) - Start scores = (86, 85). - Player 1 rolls 4 dice and gets outcomes [5, 6, 5, 6]. - End scores = (86, 107) - >>> print(turns[8]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=29276, score0=44, score1=6, goal=85, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (44, 6). - Player 0 rolls 3 dice and gets outcomes [3, 1, 6]. - End scores = (45, 6) - >>> print(turns[1]) - Start scores = (45, 6). - Player 1 rolls 2 dice and gets outcomes [1, 4]. - End scores = (45, 7) - >>> print(turns[2]) - Start scores = (45, 7). - Player 0 rolls 6 dice and gets outcomes [4, 2, 5, 4, 1, 5]. - End scores = (46, 7) - >>> print(turns[3]) - Start scores = (46, 7). - Player 1 rolls 4 dice and gets outcomes [1, 1, 3, 3]. - End scores = (46, 8) - >>> print(turns[4]) - Start scores = (46, 8). - Player 0 rolls 9 dice and gets outcomes [6, 4, 1, 1, 3, 1, 4, 5, 5]. - End scores = (47, 8) - >>> print(turns[5]) - Start scores = (47, 8). - Player 1 rolls 8 dice and gets outcomes [3, 5, 5, 3, 2, 5, 1, 4]. - End scores = (47, 9) - >>> print(turns[6]) - Start scores = (47, 9). - Player 0 rolls 10 dice and gets outcomes [6, 5, 2, 5, 2, 5, 3, 1, 5, 1]. - End scores = (48, 9) - >>> print(turns[7]) - Start scores = (48, 9). - Player 1 rolls 10 dice and gets outcomes [2, 1, 3, 1, 1, 4, 5, 4, 1, 6]. - End scores = (48, 10) - >>> print(turns[8]) - Start scores = (48, 10). - Player 0 rolls 5 dice and gets outcomes [2, 5, 4, 4, 4]. - End scores = (67, 10) - >>> print(turns[9]) - Start scores = (67, 10). - Player 1 rolls 2 dice and gets outcomes [5, 3]. - End scores = (67, 18) - >>> print(turns[10]) - Start scores = (67, 18). - Player 0 rolls 3 dice and gets outcomes [2, 5, 4]. - End scores = (78, 18) - >>> print(turns[11]) - Start scores = (78, 18). - Player 1 rolls 3 dice and gets outcomes [2, 2, 6]. - End scores = (78, 28) - >>> print(turns[12]) - Start scores = (78, 28). - Player 0 rolls 4 dice and gets outcomes [6, 6, 4, 4]. - End scores = (98, 28) - >>> print(turns[13]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=5971, score0=31, score1=81, goal=100, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (31, 81). - Player 0 rolls 6 dice and gets outcomes [4, 1, 4, 5, 3, 4]. - End scores = (32, 81) - >>> print(turns[1]) - Start scores = (32, 81). - Player 1 rolls 2 dice and gets outcomes [2, 4]. - End scores = (32, 89) - >>> print(turns[2]) - Start scores = (32, 89). - Player 0 rolls 4 dice and gets outcomes [4, 6, 1, 2]. - End scores = (37, 89) - >>> print(turns[3]) - Start scores = (37, 89). - Player 1 rolls 6 dice and gets outcomes [4, 2, 5, 2, 3, 1]. - End scores = (37, 90) - >>> print(turns[4]) - Start scores = (37, 90). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (43, 90) - >>> print(turns[5]) - Start scores = (43, 90). - Player 1 rolls 8 dice and gets outcomes [5, 2, 3, 2, 4, 4, 4, 3]. - End scores = (43, 117) - >>> print(turns[6]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=88253, score0=4, score1=10, goal=37, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (4, 10). - Player 0 rolls 6 dice and gets outcomes [1, 4, 4, 2, 4, 2]. - End scores = (5, 10) - >>> print(turns[1]) - Start scores = (5, 10). - Player 1 rolls 3 dice and gets outcomes [4, 3, 4]. - End scores = (5, 23) - >>> print(turns[2]) - Start scores = (5, 23). - Player 0 rolls 9 dice and gets outcomes [5, 2, 3, 5, 5, 5, 3, 1, 5]. - End scores = (7, 23) - >>> print(turns[3]) - Start scores = (7, 23). - Player 1 rolls 3 dice and gets outcomes [3, 1, 5]. - End scores = (7, 24) - >>> print(turns[4]) - Start scores = (7, 24). - Player 0 rolls 6 dice and gets outcomes [4, 1, 5, 4, 4, 5]. - End scores = (11, 24) - >>> print(turns[5]) - Start scores = (11, 24). - Player 1 rolls 5 dice and gets outcomes [2, 4, 6, 3, 5]. - End scores = (11, 44) - >>> print(turns[6]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=53592, score0=7, score1=91, goal=96, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (7, 91). - Player 0 rolls 2 dice and gets outcomes [1, 5]. - End scores = (11, 91) - >>> print(turns[1]) - Start scores = (11, 91). - Player 1 rolls 7 dice and gets outcomes [3, 6, 5, 4, 4, 5, 3]. - End scores = (11, 127) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=61601, score0=39, score1=1, goal=65, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (39, 1). - Player 0 rolls 4 dice and gets outcomes [4, 5, 4, 1]. - End scores = (40, 1) - >>> print(turns[1]) - Start scores = (40, 1). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (40, 10) - >>> print(turns[2]) - Start scores = (40, 10). - Player 0 rolls 3 dice and gets outcomes [4, 4, 6]. - End scores = (54, 10) - >>> print(turns[3]) - Start scores = (54, 10). - Player 1 rolls 8 dice and gets outcomes [5, 5, 6, 5, 1, 2, 1, 2]. - End scores = (54, 11) - >>> print(turns[4]) - Start scores = (54, 11). - Player 0 rolls 5 dice and gets outcomes [6, 2, 4, 2, 3]. - End scores = (71, 11) - >>> print(turns[5]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=61473, score0=14, score1=16, goal=55, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (14, 16). - Player 0 rolls 3 dice and gets outcomes [3, 4, 1]. - End scores = (17, 16) - >>> print(turns[1]) - Start scores = (17, 16). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (17, 31) - >>> print(turns[2]) - Start scores = (17, 31). - Player 0 rolls 8 dice and gets outcomes [3, 1, 6, 5, 6, 2, 2, 2]. - End scores = (18, 31) - >>> print(turns[3]) - Start scores = (18, 31). - Player 1 rolls 8 dice and gets outcomes [1, 3, 1, 2, 4, 2, 2, 4]. - End scores = (18, 32) - >>> print(turns[4]) - Start scores = (18, 32). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (37, 32) - >>> print(turns[5]) - Start scores = (37, 32). - Player 1 rolls 9 dice and gets outcomes [5, 1, 6, 4, 5, 5, 3, 5, 1]. - End scores = (37, 37) - >>> print(turns[6]) - Start scores = (37, 37). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (53, 37) - >>> print(turns[7]) - Start scores = (53, 37). - Player 1 rolls 5 dice and gets outcomes [6, 2, 6, 2, 4]. - End scores = (53, 59) - >>> print(turns[8]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=64089, score0=31, score1=87, goal=88, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (31, 87). - Player 0 rolls 2 dice and gets outcomes [4, 1]. - End scores = (32, 87) - >>> print(turns[1]) - Start scores = (32, 87). - Player 1 rolls 10 dice and gets outcomes [3, 1, 4, 1, 4, 3, 2, 4, 6, 4]. - End scores = (32, 88) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=61086, score0=7, score1=17, goal=18, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (7, 17). - Player 0 rolls 9 dice and gets outcomes [4, 1, 6, 6, 1, 3, 5, 1, 4]. - End scores = (8, 17) - >>> print(turns[1]) - Start scores = (8, 17). - Player 1 rolls 3 dice and gets outcomes [1, 1, 5]. - End scores = (8, 18) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=51837, score0=8, score1=14, goal=17, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (8, 14). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (29, 14) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=42021, score0=2, score1=17, goal=79, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (2, 17). - Player 0 rolls 5 dice and gets outcomes [6, 2, 4, 2, 6]. - End scores = (22, 17) - >>> print(turns[1]) - Start scores = (22, 17). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (22, 32) - >>> print(turns[2]) - Start scores = (22, 32). - Player 0 rolls 4 dice and gets outcomes [6, 3, 2, 5]. - End scores = (38, 32) - >>> print(turns[3]) - Start scores = (38, 32). - Player 1 rolls 7 dice and gets outcomes [2, 4, 4, 2, 6, 2, 6]. - End scores = (38, 58) - >>> print(turns[4]) - Start scores = (38, 58). - Player 0 rolls 6 dice and gets outcomes [1, 1, 4, 1, 2, 6]. - End scores = (39, 58) - >>> print(turns[5]) - Start scores = (39, 58). - Player 1 rolls 4 dice and gets outcomes [1, 5, 5, 6]. - End scores = (39, 59) - >>> print(turns[6]) - Start scores = (39, 59). - Player 0 rolls 7 dice and gets outcomes [6, 2, 3, 6, 5, 3, 1]. - End scores = (40, 59) - >>> print(turns[7]) - Start scores = (40, 59). - Player 1 rolls 7 dice and gets outcomes [6, 6, 3, 5, 1, 6, 6]. - End scores = (40, 60) - >>> print(turns[8]) - Start scores = (40, 60). - Player 0 rolls 5 dice and gets outcomes [6, 4, 4, 2, 2]. - End scores = (58, 60) - >>> print(turns[9]) - Start scores = (58, 60). - Player 1 rolls 3 dice and gets outcomes [2, 5, 6]. - End scores = (58, 73) - >>> print(turns[10]) - Start scores = (58, 73). - Player 0 rolls 9 dice and gets outcomes [4, 5, 2, 2, 3, 5, 4, 2, 1]. - End scores = (59, 73) - >>> print(turns[11]) - Start scores = (59, 73). - Player 1 rolls 7 dice and gets outcomes [1, 1, 2, 6, 1, 5, 4]. - End scores = (59, 74) - >>> print(turns[12]) - Start scores = (59, 74). - Player 0 rolls 9 dice and gets outcomes [4, 6, 4, 2, 3, 6, 6, 3, 6]. - End scores = (99, 74) - >>> print(turns[13]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=62911, score0=5, score1=32, goal=50, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (5, 32). - Player 0 rolls 8 dice and gets outcomes [3, 5, 5, 4, 3, 1, 2, 3]. - End scores = (7, 32) - >>> print(turns[1]) - Start scores = (7, 32). - Player 1 rolls 9 dice and gets outcomes [5, 2, 1, 1, 2, 2, 4, 1, 2]. - End scores = (7, 37) - >>> print(turns[2]) - Start scores = (7, 37). - Player 0 rolls 3 dice and gets outcomes [4, 3, 3]. - End scores = (17, 37) - >>> print(turns[3]) - Start scores = (17, 37). - Player 1 rolls 8 dice and gets outcomes [2, 6, 6, 6, 1, 5, 3, 2]. - End scores = (17, 41) - >>> print(turns[4]) - Start scores = (17, 41). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (29, 41) - >>> print(turns[5]) - Start scores = (29, 41). - Player 1 rolls 9 dice and gets outcomes [2, 2, 4, 1, 6, 6, 1, 2, 2]. - End scores = (29, 42) - >>> print(turns[6]) - Start scores = (29, 42). - Player 0 rolls 10 dice and gets outcomes [6, 6, 4, 1, 4, 3, 6, 1, 6, 6]. - End scores = (30, 42) - >>> print(turns[7]) - Start scores = (30, 42). - Player 1 rolls 5 dice and gets outcomes [6, 3, 1, 3, 5]. - End scores = (30, 43) - >>> print(turns[8]) - Start scores = (30, 43). - Player 0 rolls 7 dice and gets outcomes [1, 6, 4, 6, 3, 2, 5]. - End scores = (31, 43) - >>> print(turns[9]) - Start scores = (31, 43). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (31, 44) - >>> print(turns[10]) - Start scores = (31, 44). - Player 0 rolls 1 dice and gets outcomes [1]. - End scores = (32, 44) - >>> print(turns[11]) - Start scores = (32, 44). - Player 1 rolls 3 dice and gets outcomes [2, 6, 4]. - End scores = (32, 56) - >>> print(turns[12]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=48409, score0=22, score1=10, goal=61, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (22, 10). - Player 0 rolls 8 dice and gets outcomes [6, 1, 3, 3, 3, 2, 2, 6]. - End scores = (23, 10) - >>> print(turns[1]) - Start scores = (23, 10). - Player 1 rolls 5 dice and gets outcomes [6, 4, 6, 6, 2]. - End scores = (23, 37) - >>> print(turns[2]) - Start scores = (23, 37). - Player 0 rolls 2 dice and gets outcomes [3, 2]. - End scores = (28, 37) - >>> print(turns[3]) - Start scores = (28, 37). - Player 1 rolls 4 dice and gets outcomes [2, 1, 5, 1]. - End scores = (28, 41) - >>> print(turns[4]) - Start scores = (28, 41). - Player 0 rolls 9 dice and gets outcomes [6, 3, 3, 5, 1, 4, 1, 3, 2]. - End scores = (29, 41) - >>> print(turns[5]) - Start scores = (29, 41). - Player 1 rolls 9 dice and gets outcomes [4, 4, 5, 1, 5, 2, 4, 5, 3]. - End scores = (29, 42) - >>> print(turns[6]) - Start scores = (29, 42). - Player 0 rolls 2 dice and gets outcomes [5, 1]. - End scores = (30, 42) - >>> print(turns[7]) - Start scores = (30, 42). - Player 1 rolls 8 dice and gets outcomes [6, 3, 3, 4, 4, 6, 5, 6]. - End scores = (30, 79) - >>> print(turns[8]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=50497, score0=8, score1=17, goal=19, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (8, 17). - Player 0 rolls 8 dice and gets outcomes [3, 3, 1, 2, 5, 2, 4, 5]. - End scores = (9, 17) - >>> print(turns[1]) - Start scores = (9, 17). - Player 1 rolls 0 dice and gets outcomes []. - End scores = (9, 38) - >>> print(turns[2]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=52997, score0=15, score1=17, goal=23, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (15, 17). - Player 0 rolls 0 dice and gets outcomes []. - End scores = (27, 17) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=52065, score0=5, score1=34, goal=67, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (5, 34). - Player 0 rolls 10 dice and gets outcomes [5, 2, 6, 2, 4, 4, 5, 3, 1, 4]. - End scores = (7, 34) - >>> print(turns[1]) - Start scores = (7, 34). - Player 1 rolls 2 dice and gets outcomes [3, 5]. - End scores = (7, 42) - >>> print(turns[2]) - Start scores = (7, 42). - Player 0 rolls 3 dice and gets outcomes [2, 2, 4]. - End scores = (17, 42) - >>> print(turns[3]) - Start scores = (17, 42). - Player 1 rolls 7 dice and gets outcomes [5, 2, 6, 2, 3, 2, 3]. - End scores = (17, 67) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=49921, score0=0, score1=5, goal=17, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (0, 5). - Player 0 rolls 4 dice and gets outcomes [1, 1, 2, 4]. - End scores = (1, 5) - >>> print(turns[1]) - Start scores = (1, 5). - Player 1 rolls 3 dice and gets outcomes [6, 1, 5]. - End scores = (1, 6) - >>> print(turns[2]) - Start scores = (1, 6). - Player 0 rolls 6 dice and gets outcomes [3, 1, 5, 5, 1, 4]. - End scores = (2, 6) - >>> print(turns[3]) - Start scores = (2, 6). - Player 1 rolls 6 dice and gets outcomes [6, 4, 4, 4, 4, 3]. - End scores = (2, 31) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=33242, score0=15, score1=34, goal=50, update=hog.simple_update) - >>> print(turns[0]) - Start scores = (15, 34). - Player 0 rolls 10 dice and gets outcomes [6, 3, 1, 5, 5, 6, 4, 4, 4, 2]. - End scores = (16, 34) - >>> print(turns[1]) - Start scores = (16, 34). - Player 1 rolls 10 dice and gets outcomes [3, 5, 6, 5, 4, 5, 5, 1, 5, 2]. - End scores = (16, 35) - >>> print(turns[2]) - Start scores = (16, 35). - Player 0 rolls 10 dice and gets outcomes [4, 6, 1, 5, 4, 4, 2, 6, 2, 6]. - End scores = (17, 35) - >>> print(turns[3]) - Start scores = (17, 35). - Player 1 rolls 3 dice and gets outcomes [6, 4, 6]. - End scores = (17, 51) - >>> print(turns[4]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> turns = tests.play_utils.describe_game(hog, test_number=67024, score0=59, score1=4, goal=60, update=hog.sus_update) - >>> print(turns[0]) - Start scores = (59, 4). - Player 0 rolls 1 dice and gets outcomes [4]. - End scores = (63, 4) - >>> print(turns[1]) - Game Over - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> # Fuzz Testing - >>> # Plays a lot of random games, and calculates a secret value. - >>> # Failing this test means something is wrong, but you should - >>> # look at other tests to see where the problem might be. - >>> # Hint: make sure you're only calling update once per turn! - >>> # - >>> import hog, importlib - >>> # importlib.reload(hog) - >>> import tests.play_utils - """, - 'teardown': r""" - - """, - 'type': 'doctest' - } - ] -} diff --git a/proj/hog/tests/06.py b/proj/hog/tests/06.py deleted file mode 100644 index 71e4164c1..000000000 --- a/proj/hog/tests/06.py +++ /dev/null @@ -1,36 +0,0 @@ -test = { - 'name': 'Question 6', - 'points': 2, - 'suites': [ - { - 'cases': [ - { - 'code': r""" - >>> always_roll(3)(10, 20) - 16e2cf37e8254529473d9e0a36b75fcb - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> always_roll(0)(99, 99) - 962aea5f59fc55bd65ccacf4603c8f22 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - """, - 'teardown': '', - 'type': 'doctest' - } - ] -} diff --git a/proj/hog/tests/07.py b/proj/hog/tests/07.py deleted file mode 100644 index f9b5261f2..000000000 --- a/proj/hog/tests/07.py +++ /dev/null @@ -1,130 +0,0 @@ -test = { - 'name': 'Question 7', - 'points': 2, - 'suites': [ - { - 'cases': [ - { - 'code': r""" - >>> is_always_roll(always_roll_5) - bc6c4798917b91886d7fa5f56e42878f - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> is_always_roll(always_roll(3)) - bc6c4798917b91886d7fa5f56e42878f - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> is_always_roll(catch_up) - d763fd836a7bfb096222e985b161b406 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> def s(x, y): - ... if x == 0 and y == 0: - ... return 0 - ... else: - ... return 1 - >>> is_always_roll(s) - False - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> def s(x, y): - ... if x == 60 and y == 0: - ... return 0 - ... else: - ... return 1 - >>> is_always_roll(s) - False - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> def s(x, y): - ... if x == 0 and y == 60: - ... return 0 - ... else: - ... return 1 - >>> is_always_roll(s) - False - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> def s(x, y): - ... if x == 60 and y == 60: - ... return 0 - ... else: - ... return 1 - >>> is_always_roll(s) - False - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> def s(x, y): - ... if x == 99 and y == 99: - ... return 0 - ... else: - ... return 1 - >>> is_always_roll(s) - False - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> def s(x, y): - ... if x == 150 and y == 125: - ... return 0 - ... else: - ... return 1 - >>> is_always_roll(s, 200) # GOAL is not always 100! - False - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - """, - 'teardown': '', - 'type': 'doctest' - } - ] -} diff --git a/proj/hog/tests/08.py b/proj/hog/tests/08.py deleted file mode 100644 index afa16bc43..000000000 --- a/proj/hog/tests/08.py +++ /dev/null @@ -1,121 +0,0 @@ -test = { - 'name': 'Question 8', - 'points': 2, - 'suites': [ - { - 'cases': [ - { - 'answer': '562542d6415ecc5c5253297f5be4bea1', - 'choices': [ - 'It contains a nested function', - 'It calls a function that is not itself', - 'It takes in a function as an argument', - 'It uses the *args keyword' - ], - 'hidden': False, - 'locked': True, - 'multiline': False, - 'question': 'What is one reason that make_averaged is a higher order function?' - }, - { - 'answer': '159f99fb0e6b0dae968c6b227fa282ee', - 'choices': [ - 'None', - 'Two', - 'An arbitrary amount, which is why we need to use *args to call it' - ], - 'hidden': False, - 'locked': True, - 'multiline': False, - 'question': 'How many arguments does the function passed into make_averaged take?' - } - ], - 'scored': False, - 'type': 'concept' - }, - { - 'cases': [ - { - 'code': r""" - >>> dice = make_test_dice(3, 1, 5, 6) - >>> averaged_dice = make_averaged(dice, 1000) - >>> # Average of calling dice 1000 times - >>> averaged_dice() - ae54f398e6c98b4c11197ca202bbf4fb - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3, 1, 5, 6) - >>> averaged_roll_dice = make_averaged(roll_dice, 1000) - >>> # Average of calling roll_dice 1000 times - >>> # Enter a float (e.g. 1.0) instead of an integer - >>> averaged_roll_dice(2, dice) - 0381158de1e7a3a31f3fcfeb3944e0dc - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - """, - 'teardown': '', - 'type': 'doctest' - }, - { - 'cases': [ - { - 'code': r""" - >>> hundred_range = range(1, 100) - >>> hundred_dice = make_test_dice(*hundred_range) - >>> averaged_hundred_dice = make_averaged(hundred_dice, 5*len(hundred_range)) - >>> correct_average = sum(range(1, 100)) / len(hundred_range) - >>> averaged_hundred_dice() - 50.0 - >>> averaged_hundred_dice() - 50.0 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3, 1, 5, 6) - >>> averaged_roll_dice = make_averaged(roll_dice, 1) - >>> averaged_roll_dice(2, dice) - 1.0 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(3, 1, 5, 6) - >>> averaged_roll_dice = make_averaged(roll_dice, 5) - >>> averaged_roll_dice(2, dice) - 5.0 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - """, - 'teardown': '', - 'type': 'doctest' - } - ] -} diff --git a/proj/hog/tests/09.py b/proj/hog/tests/09.py deleted file mode 100644 index a44d5aaaa..000000000 --- a/proj/hog/tests/09.py +++ /dev/null @@ -1,142 +0,0 @@ -test = { - 'name': 'Question 9', - 'points': 2, - 'suites': [ - { - 'cases': [ - { - 'answer': '98acc434a18370bb040345206aea9e70', - 'choices': [ - 'The lowest num_rolls', - 'The highest num_rolls', - 'A random num_rolls' - ], - 'hidden': False, - 'locked': True, - 'multiline': False, - 'question': r""" - If multiple num_rolls are tied for the highest scoring - average, which should you return? - """ - } - ], - 'scored': False, - 'type': 'concept' - }, - { - 'cases': [ - { - 'code': r""" - >>> dice = make_test_dice(3) # dice always returns 3 - >>> max_scoring_num_rolls(dice, times_called=1000) - 70e71b420a966665c548a3bb2cb30d7d - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 2, 2, 2, 2, 2, 2, 2) - >>> max_scoring_num_rolls(dice, times_called=1000) - 4 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(*([2] * 55 + [1, 2] * 500)) # test that you are not rolling the dice more than necessary - >>> max_scoring_num_rolls(dice, times_called=1) # dice is 2 for the first 55 rolls, then is 1 followed by 2 for 1000 rolls - 10 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - """, - 'teardown': '', - 'type': 'doctest' - }, - { - 'cases': [ - { - 'code': r""" - >>> dice = make_test_dice(2) # dice always rolls 2 - >>> max_scoring_num_rolls(dice, times_called=1000) - 70e71b420a966665c548a3bb2cb30d7d - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1) # dice always rolls 1 - >>> max_scoring_num_rolls(dice, times_called=1000) - 43d176e102c8d95338faf8791aa509b3 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 2) # dice alternates 1 and 2 - >>> max_scoring_num_rolls(dice, times_called=1000) - 43d176e102c8d95338faf8791aa509b3 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> # 100 2s and then 100 1s (don't worry about how this works) - >>> dice = make_test_dice(*([2] * 100 + [1] * 100)) - >>> max_scoring_num_rolls(dice, times_called=1) - 10 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(1, 2, 3, 4, 5) # dice sweeps from 1 through 5 - >>> max_scoring_num_rolls(dice, times_called=1000) - 3 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - }, - { - 'code': r""" - >>> dice = make_test_dice(6, 5, 4, 3, 2, 1) # dice sweeps from 1 through 6 - >>> max_scoring_num_rolls(dice, times_called=1) # ensure times_called is being used - 4 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - """, - 'teardown': '', - 'type': 'doctest' - } - ] -} diff --git a/proj/hog/tests/10.py b/proj/hog/tests/10.py deleted file mode 100644 index a022a73b9..000000000 --- a/proj/hog/tests/10.py +++ /dev/null @@ -1,120 +0,0 @@ -test = { - 'name': 'Question 10', - 'points': 2, - 'suites': [ - { - 'cases': [ - { - 'code': r""" - >>> boar_strategy(40, 51, threshold=7, num_rolls=2) - 962aea5f59fc55bd65ccacf4603c8f22 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_strategy(40, 51, threshold=15, num_rolls=7) - 962aea5f59fc55bd65ccacf4603c8f22 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_strategy(40, 51, threshold=16, num_rolls=7) - c42887e7b9ffe8fc26bb57b61329f916 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_strategy(44, 53, threshold=3, num_rolls=2) - 962aea5f59fc55bd65ccacf4603c8f22 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_strategy(44, 53, threshold=4, num_rolls=2) - 46caef5ffd6d72c8757279cbcf01b12f - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_strategy(40, 31, threshold=9, num_rolls=5) - 962aea5f59fc55bd65ccacf4603c8f22 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_strategy(40, 31, threshold=10, num_rolls=5) - 26f5762c932a578994ea1c8fc7fa6c02 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_strategy(40, 52, threshold=15, num_rolls=2) - 962aea5f59fc55bd65ccacf4603c8f22 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> boar_strategy(40, 52, threshold=16, num_rolls=2) - 46caef5ffd6d72c8757279cbcf01b12f - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> s = 0 - >>> while s < 100: - ... if boar_brawl(90, s) >= 10: - ... assert boar_strategy(90, s, threshold=10, num_rolls=3) == 0 - ... else: - ... assert boar_strategy(90, s, threshold=10, num_rolls=3) == 3 - ... s += 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - """, - 'teardown': '', - 'type': 'doctest' - } - ] -} diff --git a/proj/hog/tests/11.py b/proj/hog/tests/11.py deleted file mode 100644 index 0545a6096..000000000 --- a/proj/hog/tests/11.py +++ /dev/null @@ -1,100 +0,0 @@ -test = { - 'name': 'Question 11', - 'points': 2, - 'suites': [ - { - 'cases': [ - { - 'code': r""" - >>> sus_strategy(31, 21, threshold=10, num_rolls=2) - 46caef5ffd6d72c8757279cbcf01b12f - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> sus_strategy(30, 41, threshold=10, num_rolls=2) - 962aea5f59fc55bd65ccacf4603c8f22 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> sus_strategy(53, 60, threshold=14, num_rolls=2) - 962aea5f59fc55bd65ccacf4603c8f22 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> sus_strategy(53, 60, threshold=15, num_rolls=2) - 46caef5ffd6d72c8757279cbcf01b12f - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> sus_strategy(23, 54, threshold=4, num_rolls=2) - 962aea5f59fc55bd65ccacf4603c8f22 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> sus_strategy(14, 21, threshold=8, num_rolls=2) - 46caef5ffd6d72c8757279cbcf01b12f - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> sus_strategy(14, 21, threshold=12, num_rolls=5) - 26f5762c932a578994ea1c8fc7fa6c02 - # locked - """, - 'hidden': False, - 'locked': True, - 'multiline': False - }, - { - 'code': r""" - >>> s = 0 - >>> while s < 100: - ... if sus_update(0, 20, s) - 20 >= 10: - ... assert sus_strategy(20, s, threshold=10, num_rolls=3) == 0 - ... else: - ... assert sus_strategy(20, s, threshold=10, num_rolls=3) == 3 - ... s += 1 - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': True, - 'setup': r""" - >>> from hog import * - """, - 'teardown': '', - 'type': 'doctest' - } - ] -} diff --git a/proj/hog/tests/12.py b/proj/hog/tests/12.py deleted file mode 100644 index bc4b70abf..000000000 --- a/proj/hog/tests/12.py +++ /dev/null @@ -1,36 +0,0 @@ -test = { - 'name': 'Question 12', - 'points': 0, - 'suites': [ - { - 'cases': [ - { - 'code': r""" - >>> check_strategy(hog.final_strategy) - """, - 'hidden': False, - 'locked': False, - 'multiline': False - } - ], - 'scored': False, - 'setup': r""" - >>> import hog - >>> def check_strategy(strat): - ... for score in range(100): - ... for opp in range(100): - ... num_rolls = strat(score, opp) - ... if not isinstance(num_rolls, int): - ... raise ValueError("final_strategy({0}, {1}) returned {2}, not an int.".format(score, opp, num_rolls)) - >>> def max_scoring_num_rolls(dice=lambda: 1): - ... raise RuntimeError("Your final strategy should not call max_scoring_num_rolls.") - >>> old_max_scoring_num_rolls = hog.max_scoring_num_rolls - >>> hog.max_scoring_num_rolls = max_scoring_num_rolls - """, - 'teardown': r""" - >>> hog.max_scoring_num_rolls = old_max_scoring_num_rolls - """, - 'type': 'doctest' - } - ] -} diff --git a/proj/hog/tests/__init__.py b/proj/hog/tests/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/proj/hog/tests/check_strategy.py b/proj/hog/tests/check_strategy.py deleted file mode 100644 index bf7056508..000000000 --- a/proj/hog/tests/check_strategy.py +++ /dev/null @@ -1,55 +0,0 @@ -from hog import GOAL_SCORE - -def check_strategy_roll(score, opponent_score, num_rolls): - """Raises an error with a helpful message if NUM_ROLLS is an invalid - strategy output. All strategy outputs must be integers from 0 to 10. - - >>> check_strategy_roll(10, 20, num_rolls=100) - Traceback (most recent call last): - ... - AssertionError: strategy(10, 20) returned 100 (invalid number of rolls) - - >>> check_strategy_roll(20, 10, num_rolls=0.1) - Traceback (most recent call last): - ... - AssertionError: strategy(20, 10) returned 0.1 (not an integer) - - >>> check_strategy_roll(0, 0, num_rolls=None) - Traceback (most recent call last): - ... - AssertionError: strategy(0, 0) returned None (not an integer) - """ - msg = 'strategy({}, {}) returned {}'.format( - score, opponent_score, num_rolls) - assert type(num_rolls) == int, msg + ' (not an integer)' - assert 0 <= num_rolls <= 10, msg + ' (invalid number of rolls)' - - -def check_strategy(strategy, goal=GOAL_SCORE): - """Checks the strategy with all valid inputs and verifies that the strategy - returns a valid output. Use `check_strategy_roll` to raise an error with a - helpful message if the strategy returns an invalid output. - - >>> def fail_15_20(score, opponent_score): - ... if score != 15 or opponent_score != 20: - ... return 5 - ... - >>> check_strategy(fail_15_20) - Traceback (most recent call last): - ... - AssertionError: strategy(15, 20) returned None (not an integer) - >>> def fail_102_115(score, opponent_score): - ... if score == 102 and opponent_score == 115: - ... return 100 - ... return 5 - ... - >>> check_strategy(fail_102_115) - >>> fail_102_115 == check_strategy(fail_102_115, 120) - Traceback (most recent call last): - ... - AssertionError: strategy(102, 115) returned 100 (invalid number of rolls) - """ - for score in range(goal): - for opponent_score in range(goal): - num_rolls = strategy(score, opponent_score) - check_strategy_roll(score, opponent_score, num_rolls) \ No newline at end of file diff --git a/proj/hog/tests/construct_check.py b/proj/hog/tests/construct_check.py deleted file mode 100644 index bee096e7e..000000000 --- a/proj/hog/tests/construct_check.py +++ /dev/null @@ -1,180 +0,0 @@ -from ast import parse, NodeVisitor, Name - -# For error messages (student-facing) only -_NAMES = { - 'Add': '+', - 'And': 'and', - 'Assert': 'assert', - 'Assign': '=', - 'AnnAssign': '=', - 'AugAssign': 'op=', - 'BitAnd': '&', - 'BitOr': '|', - 'BitXor': '^', - 'Break': 'break', - 'Recursion': 'recursive call', - 'ClassDef': 'class', - 'Continue': 'continue', - 'Del': 'del', - 'Delete': 'delete', - 'Dict': '{...}', - 'DictComp': '{...}', - 'Div': '/', - 'Ellipsis': '...', - 'Eq': '==', - 'ExceptHandler': 'except', - 'ExtSlice': '[::]', - 'FloorDiv': '//', - 'For': 'for', - 'FunctionDef': 'def', - 'Filter': 'filter', - 'GeneratorExp': '(... for ...)', - 'Global': 'global', - 'Gt': '>', - 'GtE': '>=', - 'If': 'if', - 'IfExp': '...if...else...', - 'Import': 'import', - 'ImportFrom': 'from ... import ...', - 'In': 'in', - 'Index': '...[...]', - 'Invert': '~', - 'Is': 'is', - 'IsNot': 'is not ', - 'LShift': '<<', - 'Lambda': 'lambda', - 'List': '[...]', - 'ListComp': '[...for...]', - 'Lt': '<', - 'LtE': '<=', - 'Mod': '%', - 'Mult': '*', - 'NamedExpr': ':=', - 'Nonlocal': 'nonlocal', - 'Not': 'not', - 'NotEq': '!=', - 'NotIn': 'not in', - 'Or': 'or', - 'Pass': 'pass', - 'Pow': '**', - 'RShift': '>>', - 'Raise': 'raise', - 'Return': 'return', - 'Set': '{ ... } (set)', - 'SetComp': '{ ... for ... } (set)', - 'Slice': '[ : ]', - 'Starred': '', - 'Str': 'str', - 'Sub': '-', - 'Subscript': '[]', - 'Try': 'try', - 'Tuple': '(... , ... )', - 'UAdd': '+', - 'USub': '-', - 'While': 'while', - 'With': 'with', - 'Yield': 'yield', - 'YieldFrom': 'yield from', -} - -def check(source_file, checked_funcs, disallow, source=None): - """Checks that AST nodes whose type names are present in DISALLOW - (an object supporting 'in') are not present in the function(s) named - CHECKED_FUNCS in SOURCE. By default, SOURCE is the contents of the - file SOURCE_FILE. CHECKED_FUNCS is either a string (indicating a single - name) or an object of some other type that supports 'in'. CHECKED_FUNCS - may contain __main__ to indicate an entire module. Prints reports of - each prohibited node and returns True iff none are found. - See ast.__dir__() for AST type names. The special node name 'Recursion' - checks for overtly recursive calls (i.e., calls of the form NAME(...) where - NAME is an enclosing def.""" - return ExclusionChecker(disallow).check(source_file, checked_funcs, source) - -class ExclusionChecker(NodeVisitor): - """An AST visitor that checks that certain constructs are excluded from - parts of a program. ExclusionChecker(EXC) checks that AST node types - whose names are in the sequence or set EXC are not present. Its check - method visits nodes in a given function of a source file checking that the - indicated node types are not used.""" - - def __init__(self, disallow=()): - """DISALLOW is the initial default list of disallowed - node-type names.""" - self._disallow = set(disallow) - self._checking = False - self._errs = 0 - - def generic_visit(self, node): - if self._checking and type(node).__name__ in self._disallow: - self._report(node) - super().generic_visit(node) - - def visit_Module(self, node): - if "__main__" in self._checked_funcs: - self._checking = True - self._checked_name = self._source_file - super().generic_visit(node) - - def visit_Call(self, node): - if 'Recursion' in self._disallow and \ - type(node.func) is Name and \ - node.func.id in self._func_nest: - self._report(node, "should not be recursive") - self.generic_visit(node) - - def visit_FunctionDef(self, node): - self._func_nest.append(node.name) - if self._checking: - self.generic_visit(node) - elif node.name in self._checked_funcs: - self._checked_name = "Function " + node.name - checking0 = self._checking - self._checking = True - super().generic_visit(node) - self._checking = checking0 - self._func_nest.pop() - - def _report(self, node, msg=None): - node_name = _NAMES.get(type(node).__name__, type(node).__name__) - if msg is None: - msg = "should not contain '{}'".format(node_name) - print("{} {}".format(self._checked_name, msg)) - self._errs += 1 - - def errors(self): - """Returns the number of number of prohibited constructs found in - the last call to check.""" - return self._errs - - def check(self, source_file, checked_funcs, disallow=None, source=None): - """Checks that AST nodes whose type names are present in DISALLOW - (an object supporting the contains test) are not present in - the function(s) named CHECKED_FUNCS in SOURCE. By default, SOURCE - is the contents of the file SOURCE_FILE. DISALLOW defaults to the - argument given to the constructor (and resets that value if it is - present). CHECKED_FUNCS is either a string (indicating a single - name) or an object of some other type that supports 'in'. - CHECKED_FUNCS may contain __main__ to indicate an entire module. - Prints reports of each prohibited node and returns True iff none - are found. - See ast.__dir__() for AST type names. The special node name - 'Recursion' checks for overtly recursive calls (i.e., calls of the - form NAME(...) where NAME is an enclosing def.""" - - self._checking = False - self._source_file = source_file - self._func_nest = [] - if type(checked_funcs) is str: - self._checked_funcs = { checked_funcs } - else: - self._checked_funcs = set(checked_funcs) - if disallow is not None: - self._disallow = set(disallow) - if source is None: - with open(source_file, 'r', errors='ignore') as inp: - source = inp.read() - p = parse(source, source_file) - self._errs = 0 - - self.visit(p) - return self._errs == 0 \ No newline at end of file diff --git a/proj/hog/tests/play_utils.py b/proj/hog/tests/play_utils.py deleted file mode 100644 index 4d068b0c4..000000000 --- a/proj/hog/tests/play_utils.py +++ /dev/null @@ -1,120 +0,0 @@ -import random - -SUMMARY = "Start scores = ({s0}, {s1}).\nPlayer {w} rolls {nr} dice and gets outcomes {rv}.\nEnd scores = ({e0}, {e1})" - -def trace_play(play, strategy0, strategy1, update, score0, score1, dice, goal, say): - """Wraps the user's play function and - (1) ensures that strategy0 and strategy1 are called exactly once per turn - (2) records the entire game, returning the result as a list of dictionaries, - each with keys "s0_start", "s1_start", "who", "num_dice", "dice_values" - Returns (s0, s1, trace) where s0, s1 are the return values from play and trace - is the trace as specified above. - This might seem a bit overcomplicated but it will also used to create the game - traces for the fuzz test (when run against the staff solution). - """ - game_trace = [] - - def mod_strategy(who, my_score, opponent_score): - if game_trace: - prev_total_score = game_trace[-1]["s0_start"] + game_trace[-1]["s1_start"] - if prev_total_score == my_score + opponent_score: - # game is still on last turn since the total number of points - # goes up every turn - return game_trace[-1]["num_dice"] - current_num_dice = (strategy0, strategy1)[who](my_score, opponent_score) - current_turn = { - "s0_start": [my_score, opponent_score][who], - "s1_start": [my_score, opponent_score][1 - who], - "who": who, - "num_dice": current_num_dice, - "dice_values": [], # no dice rolled yet - } - game_trace.append(current_turn) - return current_num_dice - - def mod_dice(): - roll = dice() - if not game_trace: - raise RuntimeError("roll_dice called before either strategy function") - game_trace[-1]["dice_values"].append(roll) - return roll - - s0, s1 = play( - lambda a, b: mod_strategy(0, a, b), - lambda a, b: mod_strategy(1, a, b), - update, - score0, - score1, - dice=mod_dice, - goal=goal, - #say=safe(say), - ) - return s0, s1, game_trace - -def safe(commentary): - def new_commentary(score0, score1, leader=None): - try: - leader, message = commentary(score0, score1, leader) - except TypeError as e: - print("Error in commentary function") - return leader, message - return new_commentary - -def describe_game(hog, test_number, score0, score1, goal, update): - strat_seed0, strat_seed1, dice_seed = run_with_seed(test_number, lambda: [random.randrange(2**32) for _ in range(3)]) - strategy0 = random_strat(strat_seed0) - strategy1 = random_strat(strat_seed1) - dice = get_dice(dice_seed) - s0last, s1last, game_trace = trace_play( - hog.play, - strategy0, - strategy1, - update=update, - score0=score0, - score1=score1, - dice=dice, - goal=goal, - say=None - ) - - end_of_turn = [(turn["s0_start"], turn["s1_start"]) for turn in game_trace[1:]] - end_of_turn.append((s0last, s1last)) - summary = [] - for turn, end in zip(game_trace, end_of_turn): - summary.append(SUMMARY.format( - s0=turn["s0_start"], - s1=turn["s1_start"], - w=turn["who"], - nr=turn["num_dice"], - rv=turn["dice_values"], - e0=end[0], - e1=end[1] - )) - summary.append("Game Over") - return summary - -def random_strat(seed): - """ - Makes a random strategy from based on the given seed - """ - def random_strat(score, opponent_score): - # Save the state of the random generator, so strategy calls don't - # impact dice rolls. - # using this because python's hash function is NOT CONSISTENT ACROSS OSs!!!!!!!!!!!!11!!22!!2! - conditional_seed = score * 314159265358979 + opponent_score * 27182818284590452353602874713527 + seed * 161803398874989484820 - return run_with_seed(conditional_seed % (2 ** 32), lambda: random.randrange(0, 11)) - return random_strat - -def run_with_seed(seed, fn): - state = random.getstate() - random.seed(seed) - result = fn() - random.setstate(state) - return result - -def get_dice(seed): - def dice(): - nonlocal seed - seed, value = run_with_seed(seed, lambda: (random.randrange(0, 2**32), random.randrange(1, 7))) - return value - return dice \ No newline at end of file diff --git a/proj/hog/ucb.py b/proj/hog/ucb.py deleted file mode 100644 index b64f1d87a..000000000 --- a/proj/hog/ucb.py +++ /dev/null @@ -1,94 +0,0 @@ -"""The UCB module contains functions specific to 61A projects at UC Berkeley.""" - -import code -import functools -import inspect -import re -import signal -import sys - - -def main(fn): - """Call fn with command line arguments. Used as a decorator. - - The main decorator marks the function that starts a program. For example, - - @main - def my_run_function(): - # function body - - Use this instead of the typical __name__ == "__main__" predicate. - """ - if inspect.stack()[1][0].f_locals['__name__'] == '__main__': - args = sys.argv[1:] # Discard the script name from command line - fn(*args) # Call the main function - return fn - -_PREFIX = '' -def trace(fn): - """A decorator that prints a function's name, its arguments, and its return - values each time the function is called. For example, - - @trace - def compute_something(x, y): - # function body - """ - @functools.wraps(fn) - def wrapped(*args, **kwds): - global _PREFIX - reprs = [repr(e) for e in args] - reprs += [repr(k) + '=' + repr(v) for k, v in kwds.items()] - log('{0}({1})'.format(fn.__name__, ', '.join(reprs)) + ':') - _PREFIX += ' ' - try: - result = fn(*args, **kwds) - _PREFIX = _PREFIX[:-4] - except Exception as e: - log(fn.__name__ + ' exited via exception') - _PREFIX = _PREFIX[:-4] - raise - # Here, print out the return value. - log('{0}({1}) -> {2}'.format(fn.__name__, ', '.join(reprs), result)) - return result - return wrapped - - -def log(message): - """Print an indented message (used with trace).""" - print(_PREFIX + re.sub('\n', '\n' + _PREFIX, str(message))) - - -def log_current_line(): - """Print information about the current line of code.""" - frame = inspect.stack()[1] - log('Current line: File "{f[1]}", line {f[2]}, in {f[3]}'.format(f=frame)) - - -def interact(msg=None): - """Start an interactive interpreter session in the current environment. - - On Unix: - -D exits the interactive session and returns to normal execution. - In Windows: - -Z exits the interactive session and returns to normal - execution. - """ - # evaluate commands in current namespace - frame = inspect.currentframe().f_back - namespace = frame.f_globals.copy() - namespace.update(frame.f_locals) - - # exit on interrupt - def handler(signum, frame): - print() - exit(0) - signal.signal(signal.SIGINT, handler) - - if not msg: - _, filename, line, _, _, _ = inspect.stack()[1] - msg = 'Interacting at File "{0}", line {1} \n'.format(filename, line) - msg += ' Unix: -D continues the program; \n' - msg += ' Windows: -Z continues the program; \n' - msg += ' exit() or -C exits the program' - - code.interact(msg, None, namespace) \ No newline at end of file