Skip to content

Add a way for end users to test their strategies #28

@amortization

Description

@amortization

I think that it would be useful if end users and developer had a way to test their strategies and ensure that they are working correctly without having to write Python tests for them.

How I picture this, is a function creating a CSV file with these fields.

  • Table Point
  • For each bet type chosen, that starting amount (ex. Starting PassLine, Starting Field, etc.)
  • Dice 1
  • Dice 2
  • for each bet type chosen, the ending amount (ex. Ending PassLine, Ending Field, etc.)

so the user could run

create_strategy_test_file(file='test_risk_12.csv', bet_types=(PassLine, Field, Place6, Place8))

which would create the blank CSV file with the headers: Table Point, Starting Bankroll, Starting PassLine, Starting Field, Starting Place6, Starting Place8, Dice1, Dice2, Ending Bankroll, Ending PassLine, Ending Field, Ending Place6, Ending Place8

Then the user would just need to enter their test into the CSV file, ex. if they wanted to simulate what happens for a Risk12 if the point is off and they roll a 4 they could do:

Off, 5, 5, 0, 0, 2, 2, 5, 0, 6, 6

This would show that for the point being off and rolling a 2, 2 the player would win the field bet and place the 6 and the 8 making the place6=6, the place8=8, and leaving the passline at 5.

then they could run the tests with

run_strategy_test_file(file='test_risk_12.csv', bet_types=(PassLine, Field, Place6, Place8), strategy=Risk12)

Which would give messages on tests that fail.

I would also envision this being run from the command prompt via argparse so users don't need to do any code. ex:

python crapssim.py create_strategy_test_file test_risk_12.csv --bet_types PassLine Field Place6 Place8
python crapssim.py run_strategy_test_file test_risk_12.csv -- --bet_types PassLine Field Place6 Place8

I think that this would be a useful way for players to write tests for their strategies without having to write any code.

I also think that it would be useful for development testing since in theory one could simulate entire games of running the strategies, record the outcomes to a CSV, and have integration tests (or even unit tests depending on how many and the length) running the entire games of each default Strategy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions