May-13-2022, 07:00 PM
I'm still looking forward to others contributing to the thread. Until that moment, here is another interpretation of an original entry into that contest. A sub hunt game in 24 lines. I think the next version will need graphics.
import random print("There is a sub in your patrol area, a 10x10x10 grid numbered 0-9\nFlush it out by launching depth chargers. Bullseye the sub and you") print("will be the hero of the day. Allow the sub to escape and you will\nswabbing the decks for the rest of your career.") sub = {"x": random.randint(0,9), "y": random.randint(0,9), "depth": random.randint(0,9)} charges, sunk = 20, False print("You have",charges,"charges. Good luck!") print(sub) while charges > 0 and not sunk: chg = {"x": int(input(" x: ")), "y": int(input(" y: ")), "depth": int(input(" depth: "))} dist = ((sub["x"]-chg["x"])**2 + (sub["y"]-chg["y"])**2 + (sub["depth"]-chg["depth"])**2)**0.5 if chg == sub: print("\nA massive explosion breaks the surface. Debis of the destroyed sub floats above the bubbles.") sunk = True elif dist <= 4: print("\nThe sub was rocked by the charge before slipping away\nBubbles in the water show the sub was at",sub,"\nwas rocked by the charge before slipping away\n") sub = {"x": sub["x"] + random.randint(-1,1), "y": sub["y"] + random.randint(-1,1), "depth": sub["depth"] + random.randint(-1,1)} else: print("The sub silently waits. You have",charges,"charges remaining.\n") charges = charges - 1 if sunk == True: print("You sunk the sub. Lunch with the president and the metal of hour awaits") else: print("The sub escaped. Your commander hands you a mop and tells you to get started")