import random
# Game variables
player_health = 100
enemy_health = 50
score = 0
# Simulate user input
actions = [ "1" , "1" , "2" , "1" , "3" ] # Example actions
# Game loop
for action in actions:
# Display game state
print ( "Score: {}, Player Health: {}, Enemy Health: {}" .format ( score, player_health, enemy_health) )
if action == "1" :
# Attack enemy
enemy_damage = random .randint ( 10 , 20 )
enemy_health -= enemy_damage
print ( "You attacked the enemy for {} damage!" .format ( enemy_damage) )
# Enemy counterattack
if enemy_health > 0 :
player_damage = random .randint ( 5 , 15 )
player_health -= player_damage
print ( "Enemy counterattacked for {} damage!" .format ( player_damage) )
elif action == "2" :
# Heal player
heal_amount = random .randint ( 10 , 20 )
player_health += heal_amount
print ( "You healed for {} health!" .format ( heal_amount) )
elif action == "3" :
# Run away
print ( "You ran away!" )
break
# Check game over
if player_health <= 0 :
print ( "Game Over! Enemy wins." )
break
elif enemy_health <= 0 :
print ( "Game Over! You win." )
score += 100
break
aW1wb3J0IHJhbmRvbQoKIyBHYW1lIHZhcmlhYmxlcwpwbGF5ZXJfaGVhbHRoID0gMTAwCmVuZW15X2hlYWx0aCA9IDUwCnNjb3JlID0gMAoKIyBTaW11bGF0ZSB1c2VyIGlucHV0CmFjdGlvbnMgPSBbIjEiLCAiMSIsICIyIiwgIjEiLCAiMyJdICAjIEV4YW1wbGUgYWN0aW9ucwoKIyBHYW1lIGxvb3AKZm9yIGFjdGlvbiBpbiBhY3Rpb25zOgogICAgIyBEaXNwbGF5IGdhbWUgc3RhdGUKICAgIHByaW50KCJTY29yZToge30sIFBsYXllciBIZWFsdGg6IHt9LCBFbmVteSBIZWFsdGg6IHt9Ii5mb3JtYXQoc2NvcmUsIHBsYXllcl9oZWFsdGgsIGVuZW15X2hlYWx0aCkpCgogICAgaWYgYWN0aW9uID09ICIxIjoKICAgICAgICAjIEF0dGFjayBlbmVteQogICAgICAgIGVuZW15X2RhbWFnZSA9IHJhbmRvbS5yYW5kaW50KDEwLCAyMCkKICAgICAgICBlbmVteV9oZWFsdGggLT0gZW5lbXlfZGFtYWdlCiAgICAgICAgcHJpbnQoIllvdSBhdHRhY2tlZCB0aGUgZW5lbXkgZm9yIHt9IGRhbWFnZSEiLmZvcm1hdChlbmVteV9kYW1hZ2UpKQoKICAgICAgICAjIEVuZW15IGNvdW50ZXJhdHRhY2sKICAgICAgICBpZiBlbmVteV9oZWFsdGggPiAwOgogICAgICAgICAgICBwbGF5ZXJfZGFtYWdlID0gcmFuZG9tLnJhbmRpbnQoNSwgMTUpCiAgICAgICAgICAgIHBsYXllcl9oZWFsdGggLT0gcGxheWVyX2RhbWFnZQogICAgICAgICAgICBwcmludCgiRW5lbXkgY291bnRlcmF0dGFja2VkIGZvciB7fSBkYW1hZ2UhIi5mb3JtYXQocGxheWVyX2RhbWFnZSkpCgogICAgZWxpZiBhY3Rpb24gPT0gIjIiOgogICAgICAgICMgSGVhbCBwbGF5ZXIKICAgICAgICBoZWFsX2Ftb3VudCA9IHJhbmRvbS5yYW5kaW50KDEwLCAyMCkKICAgICAgICBwbGF5ZXJfaGVhbHRoICs9IGhlYWxfYW1vdW50CiAgICAgICAgcHJpbnQoIllvdSBoZWFsZWQgZm9yIHt9IGhlYWx0aCEiLmZvcm1hdChoZWFsX2Ftb3VudCkpCgogICAgZWxpZiBhY3Rpb24gPT0gIjMiOgogICAgICAgICMgUnVuIGF3YXkKICAgICAgICBwcmludCgiWW91IHJhbiBhd2F5ISIpCiAgICAgICAgYnJlYWsKCiAgICAjIENoZWNrIGdhbWUgb3ZlcgogICAgaWYgcGxheWVyX2hlYWx0aCA8PSAwOgogICAgICAgIHByaW50KCJHYW1lIE92ZXIhIEVuZW15IHdpbnMuIikKICAgICAgICBicmVhawogICAgZWxpZiBlbmVteV9oZWFsdGggPD0gMDoKICAgICAgICBwcmludCgiR2FtZSBPdmVyISBZb3Ugd2luLiIpCiAgICAgICAgc2NvcmUgKz0gMTAwCiAgICAgICAgYnJlYWs=
stdout
Score: 0, Player Health: 100, Enemy Health: 50
You attacked the enemy for 13 damage!
Enemy counterattacked for 12 damage!
Score: 0, Player Health: 88, Enemy Health: 37
You attacked the enemy for 20 damage!
Enemy counterattacked for 5 damage!
Score: 0, Player Health: 83, Enemy Health: 17
You healed for 16 health!
Score: 0, Player Health: 99, Enemy Health: 17
You attacked the enemy for 12 damage!
Enemy counterattacked for 9 damage!
Score: 0, Player Health: 90, Enemy Health: 5
You ran away!