Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 2: Pikachu in the Wild (40 pts) Suppose you have a pikacla that is standing in the middle of an image, at coordinates (75,

image text in transcribed
image text in transcribed
Part 2: Pikachu in the Wild (40 pts) Suppose you have a pikacla that is standing in the middle of an image, at coordinates (75, 75) Assume the top left corner of the board is (0,0) likke in an inage. We are going to walk a pikachu around the image looking for other pokemon. This is a type of simpk simalatio First, we will set the parameters of the sinlation by asking the wser e the number of turns, turns, to un the sialation (staating at tu1), the name, name, of youur piachs a how often, often, we run into another pokemon At this poist we ester a sinmlation loop (while). Your pikacb walks 5 steps per turn in one of (N)orth, (S)outh, (E)ast or (W)est. Every tu, ask the user for a direction for your pikachu to walk and move your pikachu in that direction. You should igmore directions other than N, S, E, W. Every often turus, you meet another polmon. Ask the user for a type ((G)round or (W)ater). If it is a ground type, 'G',your pikachu loees 1 turns and runs 10 steps in the direction opposite to the direction in which it was mowing before it saw another pokemon. (If the last direction was not a valid direction, your pikachbu doesn't move. If it is a water type, W", your pikacha wins and takes 1 step forward. Anything else means you did sot actually see another poemon. Keep track of wins, losses, and "No Pokenon" in a list At the end of tur turns report on where your pikacns ended up and print out its record You st implemeat at least oe function for this program: sove pokemon(Co, colum, direction, steps) tlat returns the next location of the pilauchu as a (rou, columa) tuple. There is a fence along the boundary of the image. No coordinate can be less than 0 or greater than 150 0 and 150 are allowed. Make sure your sove pokemon) fanction does not return positions outside of this range You can use the following code to test your move.pokeon) function. Feel free to functions if you want, best be sure to test them to make sure they work as expected write other from hw3-part2 import move pokemon eolumn10 print (iaore-pokemon ( (row, column), ,n", 20)) should print (0, 10) print (ove pokemon((ow, colum' 20)) should print (3, 30) print (move-Pokemon ( (row, column), 's". 20)) 8hould print (35, 10) print (move-pokemon ((row, column) w20)) should print (15, 0) column140 print (inove.Pokemon ( (row, column). ,N. 20)) should print (115. 140 print (move.Pokemon (( row, column). .E". 20)) 8h0v/d Print (135150) print move pokemon(ro colum S. 20)) should print (150. 140) print (more .Pokemon ( (row, column). W", 20))should print (135-120) 5 Now, write some code that will call these functions for each command entered and update the location of the pikachu accordingly Two examples of the program run lhow it will look wben you ran it using Wing IDE 101) are provided in files hw3.part2 output,01.txt and hu3.part2 output 02.txt (can be found inside the hu03.files.zip fileIn h3 part2 output.01.txt, mote that f is an inwalid direction, so it has no efect on the pilkcl's state, and ris an invalid pokemon type wich gets flagged as a No Pokemon in the rsults list hw3_part2-output.02.txt How many turns? > 15 15 s What is the name of your pikachu?> Achoo ?se Achoo How often do we see a Pokemon (turns)75 hStarting simulation, turn 1 Achoo at (75, 75) What direction does Achoo walk?rn What direction does Achoo walk?n What direction does Achoo walk?n What direction does Achoo walk?n What direction does Achoo walk? > n Turn 5, Achoo at (50, 75) What type of pokemon do you meet (W)ater, (G) round?W Achoo wins and moves to (49, 75) What direction does Achoo walk?>N what direction does Achoo walk?n What directiod does Achoo walk?N What direction does Achoo walk?N What direction does Achoo walk? n Turn 10, Achoo at (24, 75) what type of pokemon do you meet (Water. (G) round? w Achoo wins and moves to (23, 75) What direction does Achoo walk? N What direction does Achoo walk? n What direction does Achoo walk? What direction does Achoo walk?n What direction does Achoo walk?n Turn 15, Achoo at (e, 75) what type of pokemon do you meet (W)ater, (G) round?w Achoo wins and moves to (e, 75) Achoo ends up at (0, 75), Record: ['Win', 'Win', 'Win'1

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

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

More Books

Students also viewed these Databases questions