Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in pseudocode for a robot battlebot that satisfies these conditi

ID: 3623676 • Letter: W

Question

Write a program in pseudocode for a robot battlebot that satisfies these conditions:

1. the battlebot should have the following command menu selections: Fire a weapon, move forward, move backward, exit.

2. If the fire weapon command is given, the user should be prompted to enter how far away (in feet) the opponent battlebot is. If the opponent is within 20 feet, a message should be displayed that the opponent is destroyed; if it is within 40 feet, the message should say it is partially disabled; and if it is over 40 feet away, the message should say it is unharmed. the battlebot has enough ammo to fire its weapon five times in total. if it is out of ammo, it should display a message that it cannot fire anymore when the fire weapon command is given.

3. the battlebot has 5 shots.

4. if the move forward command is given, the user should be prompted to enter how far they want to go and then how far away (in feet) it should dispaly a message that it can move the entire distance and state the distance.

5. The move backward command should work the same way as the move forward command.

6. the battlebot should keep track of how far it travels. it has enough fuel to travel 200 feet in total. if it runs out of fuel, it should display a message that it is out of fuel when the move forward or move backward command is given.

7. the oponent should be randomly placed between 500 and 100 feet away.

Explanation / Answer

def main():
    fuel = 200
    choice = 0
    
    opponentDistance = opponentMoving()
    while choice != 4:
        print 'Menu Selections:'
        print 'Enter 1 for Fire Weapon'
        print 'Enter 2 for Move Forward'
        print 'Enter 3 for Move Backward'
        print 'Enter 4 for Exit'
        print 'Enter your selection'

        choice = input('Enter now ->')
        if choice == 1:
            fireWeapon()
        elif choice == 2:
            userInput = getPosition(opponentDistance)
            fuel = updateFuel (fuel, userInput)
            moveForward(opponentDistance,userInput)
            
        elif choice == 3:
            userInput = getPosition(opponentDistance)
            fuel = updateFuel (fuel, userInput)
            moveBackward(opponentDistance,userInput)
            
        elif choice == 4:
            print "Goodbye"
        else:
            print "Invalid input - please try again."
       
def getPosition(opponentDistance):
    endMovement = 'no'
    print "Your opponent is at ",opponentDistance
    userInput = input('How far do you want to go, Caution with obstacle? Enter in feet from 1 to 300:')
    while userInput >= 1 and userInput <= 300:
        while endMovement == 'no'or 'No' or 'NO':
            if userInput >= (opponentDistance - 100) and userInput <= (opponentDistance + 100):
               print'Opponent is too close!!!!'
            elif userInput >= (opponentDistance - 200) and userInput <= (opponentDistance + 200):
               print 'Opponent is within Range'
            elif userInput >= (opponentDistance - 300) and userInput <= (opponentDistance + 300):
               print' You have and obstacle forward '
            else:
               userInput > 300
               print "You are clear of obstacle move forward"
            endMovement = raw_input('Would you like to END Movement? ENTER yes or no:')
            print "Distance Entered",userInput
        return userInput

def updateFuel (fuel, userInput):
    fuelUsed = 0
    userFuel = 0

    userFuel = userInput * .20
    fuel = fuel - userFuel
    fuelUsed = fuelUsed + userFuel
    print "FUEL AVAlLlABLE ",fuel
    print "FUEL USED ",fuelUsed
    return fuel

def moveForward(opponentDistance,userInput):
    
    print "Opponent is at ",opponentDistance
    if opponentDistance <= 100:
        print "You are within shooting Range"
    closerDistance = opponentDistance - userInput
    
    print "Distance between",closerDistance
   def moveBackward(opponentDistance,userInput):
    print "Opponent is at ",opponentDistance
    if opponentDistance >= 400:
        print "You have moved too far"
    closerDistance = opponentDistance + userInput
    
    print "Distance between",closerDistance," feet"
    
def fireWeapon():
    ammunition = 0
    howFarFire = 0
    endFire = 'no'
    opponentRange = random.randint(1,100)

    
    print "You have 5 attemps"
    while ammunition < 5:
        while endFire == 'no'or 'No' or 'NO':
            howFarFire= input('How far do you want to FIRE WEAPON? Enter in feet from 1 to 100:')
            if howFarFire >= (opponentRange - 10) and howFarFire <= (opponentRange + 10):
               print'Opponent is destroyed!!!!'
            elif howFarFire >= (opponentRange - 20) and howFarFire <= (opponentRange + 20):
               print 'Partially disabled'
            elif howFarFire >= (opponentRange - 30) and howFarFire <= (opponentRange + 30):
               print' Enemy Unharmed '
            else:
               print " Too Far"
            endFire = raw_input('Would you like to END fire? Enter yes or no:')
            ammunition = ammunition + 1
            print "Attempt number ",ammunition


def opponentMoving():
    opponentDistance = random.randint(1,500)
    return opponentDistance




    
main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote