Answered step by step
Verified Expert Solution
Link Copied!

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 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...
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions