Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 2: Pikachu in the Wild (40 pts) Sappose you have a pikacha that is standing in the middle o aa image, at coordinates (75,

image text in transcribed
Part 2: Pikachu in the Wild (40 pts) Sappose you have a pikacha that is standing in the middle o aa image, at coordinates (75, 75) Assuane the top left coener of the board is (0,0) like in an image. We are going to walk a piliclu around the image looking for other poon. This is a type of simple simulation. First, we will set the paramseters of the simulation by asking the user foe the number of turns, turns, to ran the simulation (starting at turn 1), the mame, name, of your pikachu and how often, often, we run into another polkemon. At this pointwe enter a simalatioa loop (while). Your pikacu walks 5 steps per turn in one of (N)orth, (S)outh (E)ast or West. Every turn. ask tbe usor for a direction for your pikachu to alk aad move your peladu in that direction. You should igapore directions other than N, S, E. W. Every often turas, you meet another pokro Ask the user for a type ((G)round or (W)ater). If it is a ground type, "G'. your pikacha lses. It turns and runs 10 steps in the direction opposite to the direction in which it was moving before it saw another pokemon. (If the last direction was not a valid direction, your pilacia doesn't move If it is a water type, W",your pilachu wins and takes 1 step Sorward. Anything else means you did not actually see another pokennon. Keep track of wins, kmes, at dNo Poketon. in alist. At the end of turn turns report on where your pilkacent eaded up and peint out its zecoed You mst implet at least one function Soe this program move.pokemon(Crou, colum), direction, steps,) that returns the next location of the pikecn as a (ro, column) tuple. There is a fence along the boundary of the image. No coordinate can be loss than 0 cr geeater thon 130 0 and 150 are allowed. Make sure your 0ve_pokenoaC) function does nox return postions outside of this raEge, You can use the following code to test your 0ve-Pokenon()actia. Fel free to write other functions if you want, but be sure to test them to make sure they work as expected from hw3 part2 import move-pokemos row15 column10 print (more-pokemon (( row. column). "n". 20)) Print(snove,pokemon (( row. column). "e,-20)) print(tnove-Pokemon (( row, column). "s'. 20)} print (move-Pokemon ((row, column), "w.. 20)) #should prin1 # ahos/d print #should print #should print (0, 10) (15, 30) (35. 10) (15, 0) column 140 print(tnove "pokemon ( (row, print( tnove,pokemon (( row. print (move-Pokemo(( row. print (move-pokennon(( row, column). column). column). column) "N'. "E'. "S'. 'W.. 20)) 20)) 20)) 20)) #should #should # should #should print Print print Print r115. 110) (135-150) (150, 140) (135-120) Now, write some code that will call these functions for each commmand entered and update the location of the pikachu accordingly. Two examples of the program ran (how it will look when you n it using Wing IDE 101) are provided in files bu3.part2 output 01.txt and bu3.part2 output 02.txt (can be found inside the hwo3.files.zip fie) In h3 part2,output 01.txt, note that f is an invalid direction, so it has no effect on the pikac's state, and r is an alid polmon type which gets lagred as a "No Pokemonin the results list

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

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions

Question

to encourage a drive for change by developing new ideas;

Answered: 1 week ago

Question

4 What are the alternatives to the competences approach?

Answered: 1 week ago