hog-calc
¶
This contains methods used to compare strategies for Hog.
Running Locally¶
Create a venv and install dependencies.
$ python3 -m venv env
$ env/bin/pip install -r requirements.txt
Run env/bin/python main.py
to start the Flask server, then make a POST request
to http://localhost:5000/api/compare_strategies
to start comparing strategies.
Main¶
This file compares Hog strategies and outputs strategy win rates.
Process Input¶
This file contains methods for validating and recording Hog strategies.
-
docs.hog_calc.process_input.
validate_strat
(received_strat)[source]¶ This function validates that the strategy inputted gives out a number of rolls for each pair of score values that is within the acceptable range of rolls. It then returns the strategy.
- Parameters
received_strat (dict) – the strategy that was submitted by a student
- Returns
list of lists with the strategy’s number of rolls for given scores
-
docs.hog_calc.process_input.
record_strat
(name, group, received_strat)[source]¶ This function takes in a submitted strategy and validates it, then encodes it in JSON format along with the name, a hash of the strategy, and the email of one of the users in the group, and stores it on the CS61A database.
- Parameters
evaluated and stored on the database :type received_strat: dict
- Returns
the hash of the received strategy
Runner¶
This file contains methods for matching and scoring two given Hog strategies.
-
docs.hog_calc.runner.
make_strat_str
(strat_0, strat_1)[source]¶ Takes in two separate strategies and converts them both into a string separating each num_roll of dice by a newline.
-
docs.hog_calc.runner.
match
(strat_0, strat_1, *, use_contest=True)[source]¶ Plays a match between two strategies.