Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 3: Pikachu in the Wild Suppose you have a Pikachu that is standing in the middle of an image, at coordinates (75, 75) Assume

image text in transcribed
image text in transcribed
Part 3: Pikachu in the Wild Suppose you have a Pikachu that is standing in the middle of an image, at coordinates (75, 75) Assume the top left corner of the board is (0,0) like in an image. You are going to read input from the user ten times. Though you do not have to use a loop for this part, it will considerably shorten your code to use one and it is highly recommended. However using a loop in place of simple list functions such as sorting will incur penalties during grading Each user input will be an action taken by Pikachu. You are going to execute each command as it is entered, and then print Pikachu's current location and direction. At the same time, you are going to put all the given commands in a list, sort this resulting list at the end of the program and print it as is (no other formatting) Everything Pikachu does affects Pikachu's energy. Moving (or attempting to move when at a boundary) costs 1 energy. Attacking costs 5 energy. Pikachu starts with 10 energy and energy cannot go below 0. Here are the allowed commands: .One of E, N, w, S will move Pikachu 20 steps in the specified direction. Pikachu can only move if it has enough energy. e attack will print a message, but keep Pikachu at its current location. Pikachu will only attack if it has some energy, If Pikachu has at least 5 energy the attack succeeds. Otherwise it fails. Either way Pikachu loses up to 5 energy with the caveat that its energy cannot go below 0. rest will turn recharge Pikachu back to its initial energy level of 10 If user enters an incorrect command, you should treat it as a move with respect to checking energy level and decreasing energy, but nothing else happens. You should accept commands in a case insensitive way (N, e, W RESt, Rest, rest) should all work 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. You must implement at least one function for this program: move (x,y,direction) will return the next location of the Pikachu as an (x,y) tuple. You can use the following code to test your move function. Feel free to write other functions if you want, but be sure to test them to make sure they work as expected

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

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions