Files
inf-kswo/IO/Frankengewinnspiel.py
Janis Hutz ede0ee318b Format
There really is no hope of making this code even half-way decent without
spending the time to rewrite them all properly. Don't want to do any of
that
2025-11-03 17:08:35 +01:00

118 lines
3.0 KiB
Python
Executable File

# FRANKENGEWINNSPIEL
# -------------------------------------------------
# Import of Modules and setup variables
# import turtle
# Definition of Turtle instances
# Preparations, so setup of the game output window and choice of diffrent gamemodes
programchoice = 200
while (programchoice < 1) or (programchoice > 99):
programchoice = programchoice = int(
input(
"Welcher Modus? 1 = Normales Spiel, 2 = Liste aller Gewinne mit angabe des Höchsten, 3 = angabe des höchsten Gewinnes, 4 = andgabe des höchsten erreichbaren Feldes: "
)
)
if (programchoice < 1) or (programchoice > 99):
print("Number not within designated range. Try again")
print("Willkommen")
# MAINGAME
# -----------------------
def playgame(field):
global winning
winning = 0
while field > 1:
if (field % 2) == 1:
next = field * 3 + 1
winning += next
field = next
else:
next = field / 2
winning += next
field = next
# GAMEMODE 1
# -------------------------
def gamemode1():
s = 200
while (s < 1) or (s > 99):
s = int(input("Zahl: "))
if (s < 1) or (s > 99):
print("Number not within designated range. Try again")
print("Ok")
fieldint = s
playgame(fieldint)
global winning
print("Your winnings:", winning)
# GAMEMODE 2
# --------------------------
def gamemode2():
fieldascending = 1
for i in range(99):
playgame(fieldascending)
print("You win", winning, "with startpoint", fieldascending)
fieldascending += 1
# GAMEMODE 3
# --------------------------
def gamemode3():
fieldascending = 1
global winning
currentwinning = 0
currentfield = 0
for i in range(99):
playgame(fieldascending)
if winning > currentwinning:
currentwinning = winning
currentfield = fieldascending
fieldascending += 1
print("Biggest possible winning is", currentwinning, "on field", currentfield)
# GAMEMODE 4
# -----------------------------
def gamemode4():
fieldascending = 1
global winning
currentwinning = 0
currentfield = 0
biggestfield = 0
for i in range(99):
field = fieldascending
while field > 1:
if (field % 2) == 1:
next = field * 3 + 1
field = next
if next > biggestfield:
biggestfield = next
currentfield = fieldascending
else:
next = field / 2
field = next
fieldascending += 1
print("Biggest possible field is", biggestfield, "on startfield", currentfield)
# RUN
# -------------------------
if programchoice == 1:
gamemode1()
elif programchoice == 2:
gamemode2()
elif programchoice == 3:
gamemode3()
else:
gamemode4()