Question: Problem 8 ( 1 pt ) . A strategy can also take advantage of the Swine swap rule. Implement which Rolls 0 if it would

Problem 8(1 pt). A strategy can also take advantage of the Swine swap rule. Implement
which
Rolls 0 if it would cause a beneficial swap that gains points.
Rolls BASELINE_NUM_ROLLS if rolling 0 would cause a harmful swap that loses points.
If rolling 0 would not cause a swap, then do so if it would give at least points and roll BASELINE_NUM_ROLLS otherwise.
Test your implementation before moving on:
python3 hog_grader.py -98
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.
python3 hog_grader.pydef swap_strategy(score, opponent_score):
"m"This strategy rolls 0 dice when it would result in a beneficial swap and rolls BASELINE_NUM_ROLLS if it would result in a harmful swap. It also rolls 0 dice if that gives at least BACON_MARGIN points and rolls BASELINE_NUM_ROLLS otherwise.
>>swapstrategy (23,60)#23+(1+max(6,0))=30 : Beneficial swap
0
>>swapstrategy (27,18)#27+(1+max(1,8))=36 : Harmful swap
5
>swapstrategy (50,80)#(1+max(8,0))=9 : Lots of free bacon
0
>>swapstrategy (12,12)??# Baseline
5
m...
 Problem 8(1 pt). A strategy can also take advantage of the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!