Überarbeitung

Überarbeitung des Codes (Optimierung) und kleine Features Hinzugefügt (Multiplikator + Counter)
This commit is contained in:
2025-12-04 17:31:22 +00:00
parent ff42ee7dee
commit 89e85d8cab
2 changed files with 373 additions and 0 deletions

211
Game/game.ipynb Normal file
View File

@@ -0,0 +1,211 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "c74a7a8e-6e0a-4f42-a18f-46b1aa7fddb1",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Zahl\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Zahl\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Zahl\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Kopf (1x)\n",
"\n",
"Du hast 5.5 Coins (+ 0.5)\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Zahl\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Zahl\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Zahl\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Kopf (1x)\n",
"\n",
"Du hast 6.0 Coins (+ 0.5)\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Kopf (2x)\n",
"\n",
"Du hast 7.0 Coins (+ 1.0)\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Zahl\n"
]
}
],
"source": [
"#import menu\n",
"import random\n",
"\n",
"propability = 40\n",
"coins_per_head = 0.5\n",
"coins = 5\n",
"coins_amount = 1\n",
"\n",
"def coin_flip(propability, coins, coins_per_head, coins_amount):\n",
" while True:\n",
" result = random.randint(0, 100)\n",
" if result in range(0,propability):\n",
" print(f'Kopf ({coins_amount}x)') \n",
" coins_amount += 1 #Anzahl an hintereinander geworfenen \"Köpfen\"\n",
" if coins_amount >=3:\n",
" coins_per_head += 0.5 #Coin-Boost für mehrfaches werfen von Kopf hintereinander\n",
" else:\n",
" coins_per_head = 0.5\n",
" coins += coins_per_head\n",
" print('')\n",
" print(f'Du hast {coins} Coins (+ {coins_per_head})')\n",
" input()\n",
" elif result in range(propability,100):\n",
" print('Zahl')\n",
" coins_amount = 1\n",
" input()\n",
"\n",
"\n",
"coin_flip(propability, coins, coins_per_head, coins_amount)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e0acbe2a-a8d1-4928-8e49-dd39a75d2b83",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

162
Game/menu.ipynb Normal file
View File

@@ -0,0 +1,162 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 29,
"id": "bff3a30a-d5dc-493d-94fd-886ea464a554",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Herzlich Willkommen zu\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"Druecke eine beliebige Taste \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"M U E N Z E N W E R F E R\n",
"\n",
"Druecke [1] um ein Spiel zu starten und [2] um das Spiel zu beenden\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" 1\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Nun Gut!\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Du weisst, wie man spielt, oder?\n",
"\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Lies nochmal die README.txt und druecke [Enter], wenn du fertig bist\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
" \n"
]
}
],
"source": [
"import sys \n",
"def title_screen():\n",
" print('Herzlich Willkommen zu')\n",
" input('Druecke eine beliebige Taste')\n",
" print(*'MUENZENWERFER')\n",
" print('')\n",
"\n",
"def end_game_or_start_question():\n",
" while True:\n",
" print('Druecke [1] um ein Spiel zu starten und [2] um das Spiel zu beenden')\n",
" a = input()\n",
" try:\n",
" a = int(a)\n",
" if a in (1, 2):\n",
" break\n",
" else:\n",
" print('1 oder 2!')\n",
" except ValueError:\n",
" print('Du sollst nur Zahlen eingeben')\n",
" \n",
" return a\n",
"\n",
"def menu_navigation(a):\n",
" if a == 1:\n",
" print('Nun Gut!')\n",
" input('')\n",
" print('Du weisst, wie man spielt, oder?')\n",
" print('')\n",
" playknowledge = input('')\n",
" if playknowledge in ('Ja', 'ja'):\n",
" print('Super!')\n",
" print('')\n",
" print('Dann kann es ja losgehen')\n",
" else:\n",
" print('Nein? Dann lies nochmal die README.txt und druecke [Enter], wenn du fertig bist')\n",
" input('')\n",
" elif a == 2:\n",
" print('Schade, es gibt kein Zurueck mehr jetzt')\n",
" input()\n",
" sys.exit()\n",
" \n",
"title_screen()\n",
"a = end_game_or_start_question()\n",
"menu_navigation(a)\n",
" \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "261c5908-bfdd-45d3-bef4-97030bd28e85",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}