Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1). You are to create an IPython notebook file entitled ChaseSimulation.ipynb with an obvious cell that performs a simulation of the imp-golem chase to the

1). You are to create an IPython notebook file entitled ChaseSimulation.ipynb with an obvious cell that performs a simulation of the imp-golem chase to the surface. Assume the following rules: i. The tunnel is 50 feet in length (beginning at foot 0, ending at foot 50). The golem starts at the beginning (foot 0), while the imp has a short head-start (at foot 5). ii. While in the tunnel, the imp moves a bit awkwardly between 1 and 7 feet (randomly) every second, while the golem moves at a slow but steady 3-4 feet (randomly) every second. iii. If the imp reaches foot 50 (the exit to the surface) it can use its wings to easily escape. But if the golems position overtakes the imps position beforehand, the imp is captured and its fun ends. iv. You are to simulate every second of the chase by incrementing the golems and imps position according to the rules in part ii. above, culminating with one of the scenarios described in part iii. You must print details regarding each seconds passing (where the golem and imp are), up until the concluding second at which point you should simply print the outcome. (See examples below.)

Ex 1 (The imp escapes): G----I--------------------------------------------X 0s

----G-------I-------------------------------------X 1s

--------G---------I-------------------------------X 2s

-----------G----------I---------------------------X 3s

---------------G----------I-----------------------X 4s

------------------G-----------I-------------------X 5s

----------------------G-----------I---------------X 6s

--------------------------G--------------I--------X 7s

------------------------------G----------------I--X 8s

THE IMP HAS ESCAPED TO FREEDOM AFTER 9 SECONDS. MISCHIEF AND TRICKERY AWAIT!

Ex 2 (The golem captures the imp): G----I--------------------------------------------X 0s
----G---I-----------------------------------------X 1s
-------G---I--------------------------------------X 2s
-----------G--I-----------------------------------X 3s
---------------G-I--------------------------------X 4s
SADLY, ITS BACK TO THE TOWER FOR THE IMP AFTER A 5 SECOND-CHASE.

Make your output print format match or closely resemble the above (i.e. instead of simply printing the positions as simple integers with every second.)

2) You are to define Python function chaseSimple() within a standard python file ChaseSimple.py that simulates the chase from problem 1 but prints nothing and instead returns True (if the imp escapes) or False (if it is recaptured). However, instead of using fixed positions and speeds, your function must accept the following parameters: 1. impSpd: A two-element tuple where element 1 is the min # feet per second and element 2 is the max # for the imp (instead of the static 1 and 7, respectively). 2. golemSpd: A two-element tuple identical to impSpd, but gives the golems movement in feet per second. 3. headStart: a single integer indicating the initial position of the imp in feet. 4. exitPosition: A single integer indicating the foot at which the exit appears.

The parameters must be passed to function chaseSimple in the above order. Its signature should therefore be chaseSimple(impSpd, golemSpd, headStart, exitPosition). The actual simulation is identical to that of problem 1, but should substitute the parameters in place of the fixed values.

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

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions