Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 8 ( 1 pt ) . A strategy can also take advantage of the Swine swap rule. Implement which Rolls 0 if it would
Problem pt A strategy can also take advantage of the Swine swap rule. Implement
which
Rolls if it would cause a beneficial swap that gains points.
Rolls BASELINENUMROLLS if rolling would cause a harmful swap that loses points.
If rolling would not cause a swap, then do so if it would give at least points and roll BASELINENUMROLLS otherwise.
Test your implementation before moving on:
python hoggrader.py
Once you have implemented this strategy, update to evaluate your new strategy against the baseline. You should find that it performs even better than on average.
At this point, run the entire autograder to see if there are any tests that don't pass.
python hoggrader.pydef swapstrategyscore opponentscore:
mThis strategy rolls dice when it would result in a beneficial swap and rolls BASELINENUMROLLS if it would result in a harmful swap. It also rolls dice if that gives at least BACONMARGIN points and rolls BASELINENUMROLLS otherwise.
trategy #max : Beneficial swap
trategy #max : Harmful swap
trategy #max : Lots free bacon
trategy # Baseline
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started