0% found this document useful (0 votes)
44 views

Battle Bot Program

This document contains the code for a battle bot program. The main function contains a menu that allows the user to fire a weapon with 5 shots of ammunition, move the bot forward or backward using fuel, or exit the program. Based on the user's selection, it will call different defined functions like fire(), moveBot(), or end() to carry out the selected action. The functions define the specific behavior, like consuming ammunition and checking the distance to determine if an enemy is hit during firing.

Uploaded by

Jason Bock
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Battle Bot Program

This document contains the code for a battle bot program. The main function contains a menu that allows the user to fire a weapon with 5 shots of ammunition, move the bot forward or backward using fuel, or exit the program. Based on the user's selection, it will call different defined functions like fire(), moveBot(), or end() to carry out the selected action. The functions define the specific behavior, like consuming ammunition and checking the distance to determine if an enemy is hit during firing.

Uploaded by

Jason Bock
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

#battle bot program

#
#
def main():
endProgram ='no'
ammo=int(0)
while endProgram == 'no':
    fuel = 200
    fuel = float (fuel)
    print

    #display menu
    print 'Menu Selections: '
    print '1 - Fire Weapon '
    print '2 - Move Forward '
    print '3 - Move Backward '
    print '4 - Exit '

    #check menu selection


    choice = input ('Enter your selection ')
    choice = float (choice)
    if choice == 1:
        print ammo
        ammo=ammo+1
        print ammo
        if ammo <= 5:
            ammo=kill()
        elif ammo > 5:
            print 'You are out of ammunition'
            print ammo
            return ammo
    elif choice == 2:
        move = moveBot(fuel)
    elif choice == 3:
        move = moveBot(fuel)
    elif choice == 4:
        Exit = end()
    elif choice >= 5:
        print 'Not a valid action '
        print 'Please try again '
    else:
        endProgram = raw_input ('Do you want to end program?')
    ('Enter yes or no):')
while not (endProgram == 'yes' or endprogram == 'no'):
        print 'Please enter a yes or no '
        endProgram == raw_input ('Do you want to end program?')

#fire weapion 5 shots only


def fire(ammo):
    print ammo
    ammo = ammo + 1
    print ammo
    if ammo <= 5:
        fire = kill(ammo)
    elif ammo > 5:
        print 'You are out of ammunition! '
        return
    else:
        return

#move bot
def moveBot(fuel):
    fuel = input ('How far would you like to move? ')
   

#kill enemy
def kill():
    print
    print 'How far away is the enemy? '
    killDis = input ('Enter distance in feet now! ')
    #check effect
    if killDis <= 20:
        print 'Enemy has been destroyed! '
        return
    elif killDis <= 40:
        print 'Enemy has been partially disabled. '
        return
    elif killDis >= 41:
        print 'The enemy has been unharmed! '
        return

#end program
def end():
    endProgram = raw_input ('Do you want to end program? yes or no ')

#calls main
main()

You might also like