Question

In: Computer Science

Write an algorithm for resolving a battle among the classic Pokemon types. write the algorithm first...

  1. Write an algorithm for resolving a battle among the classic Pokemon types.
  2. write the algorithm first

       The user should select a type of either fire, water or grass. The computer should randomly select one of those three types as well.

      To determine if the user or computer wins, or if it is a draw: fire is stronger than grass, grass is stronger than water, and water is stronger than fire. Whoever chose the stronger type is the winner. If both chose the same type it is a draw.

python

Solutions

Expert Solution

CODE IN PYTHON:

import random
#taking input from the user
userChoice = input("Enter pokeman type(fire/grass/water)")
#validating the input
if(userChoice!="fire" and userChoice!="grass" and userChoice!="water"):
print("Invalid input... next time please enter valid input...")
exit(0)
#generating the computer choice
n = random.randint(1,4)
computerChoice = " "
if(n==1):
computerChoice = "fire"

elif(n==2):
computerChoice = "grass"
elif(n==3):
computerChoice = "water"
#displaying the winner
print("computer choice is:"+computerChoice)
if(userChoice=="fire" and computerChoice == "grass"):
print("User wins")
elif(computerChoice=="fire" and userChoice == "grass"):
print("Computer wins")
elif(userChoice=="grass" and computerChoice == "water"):
print("User wins")
elif(userChoice=="water" and computerChoice == "grass"):
print("Computer wins")
elif(userChoice=="water" and computerChoice == "fire"):
print("User wins")
elif(userChoice=="fire" and computerChoice == "water"):
print("Computer wins")
else:
print("Its Draw")

OUTPUT:


Related Solutions

Write a method that takes four strings as parameter. The first string should be a pokemon...
Write a method that takes four strings as parameter. The first string should be a pokemon name, the second a pokemon type, the third a pokemon name, and the fourth a pokemon type. The method should print out which pokemon has the advantage over the other based on their type. In this case you can use fire, water, and leaf. Example outputs should be like: Example: Pokemon X (Water) has the advantage over Pokemon Y (fire) Pokemon X (Fire) has...
Write algorithm for LIFO (Last In First Out) Page Replacement Algorithm
Write algorithm for LIFO (Last In First Out) Page Replacement Algorithm
Explain how your selected tools are effective in resolving potential conflicts among managers and stockholders.
Explain how your selected tools are effective in resolving potential conflicts among managers and stockholders.
Python3 Write a program to implement the Pokemon game should ask the user to enter their...
Python3 Write a program to implement the Pokemon game should ask the user to enter their type and compare it with a randomly chosen computer type and correctly display who wins/ties.
Write a Java program that implements the Depth-First Search (DFS) algorithm. Input format: This is a...
Write a Java program that implements the Depth-First Search (DFS) algorithm. Input format: This is a sample input from a user. 3 2 0 1 1 2 The first line (= 3 in the example) indicates that there are three vertices in the graph. You can assume that the first vertex starts from the number 0. The second line (= 2 in the example) represents the number of edges, and following two lines are the edge information. This is the...
Alice wants to sell her Pokemon card collection on eBay. She decides to accept the first...
Alice wants to sell her Pokemon card collection on eBay. She decides to accept the first bid that exceeds 100$. Suppose that each bid that she receives is chosen uniformly at random between 0$ and 110$ (the bids are continuous, i.e., real numbers in that interval). Let X be the number of bids Alice receives (once she accepts a bid, the auction is over and she does not receive any more bids). (a)Is X discrete, continuous, or neither? (b)Find the...
What was the first virus used to battle Ca, in 1910? How are the viruses altered,...
What was the first virus used to battle Ca, in 1910? How are the viruses altered, in order to make them only attack Ca cells? How did the pediatric patient, Emily Whitehead respond to the therapy? Towards the end, what was the percentage of the 39 children, who had complete remission?
A diffraction grating has a chromatic resolving power of 20,000 in first order (m = 1)....
A diffraction grating has a chromatic resolving power of 20,000 in first order (m = 1). (i) What is the number of slits in the grating? (ii) This grating is used to analyze the spectrum of light coming from stars, in the third order (m = 3). The analysis involves resolving wavelengths that are close the spectral wavelength of some element (500.0 nm). What is the range of wavelengths you cannot distinguish from the said spectral wavelength? Hint: Chromatic resolving...
Why is the Confederate battle flag such a controversial symbol? write in 300 words
Why is the Confederate battle flag such a controversial symbol? write in 300 words
Write the following Python script: Pikachu is a well-known character in the Pokemon anime series. Pikachu...
Write the following Python script: Pikachu is a well-known character in the Pokemon anime series. Pikachu can speak, but only 3 syllables: "pi", "ka", and "chu". Therefore Pikachu can only pronounce strings that can be created as a concatenation of one or more syllables he can pronounce. For example, he can pronounce the words "pikapi" and "pikachu". You are given a String word. Your task is to check whether Pikachu can pronounce the string. If the string can be produced...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT