From 42d93f5143a91777c4f0d08c6b4681c6c5a2380d Mon Sep 17 00:00:00 2001 From: Jose Martinez Date: Fri, 26 Mar 2021 10:39:02 +0000 Subject: [PATCH 1/3] My first project --- your-project/.gitignore.txt | 19 ++ .../Soldier & Dice (Risk)-checkpoint.ipynb | 225 ++++++++++++++++++ your-project/README.md | 34 --- your-project/README.md.md | 54 +++++ your-project/Soldier & Dice (Risk).ipynb | 225 ++++++++++++++++++ 5 files changed, 523 insertions(+), 34 deletions(-) create mode 100644 your-project/.gitignore.txt create mode 100644 your-project/.ipynb_checkpoints/Soldier & Dice (Risk)-checkpoint.ipynb delete mode 100644 your-project/README.md create mode 100644 your-project/README.md.md create mode 100644 your-project/Soldier & Dice (Risk).ipynb diff --git a/your-project/.gitignore.txt b/your-project/.gitignore.txt new file mode 100644 index 0000000..152a79d --- /dev/null +++ b/your-project/.gitignore.txt @@ -0,0 +1,19 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/jupyternotebooks +# Edit at https://www.toptal.com/developers/gitignore?templates=jupyternotebooks + +### JupyterNotebooks ### +# gitignore template for Jupyter Notebooks +# website: http://jupyter.org/ + +.ipynb_checkpoints +*/.ipynb_checkpoints/* + +# IPython +profile_default/ +ipython_config.py + +# Remove previous ipynb_checkpoints +# git rm -r .ipynb_checkpoints/ + +# End of https://www.toptal.com/developers/gitignore/api/jupyternotebooks \ No newline at end of file diff --git a/your-project/.ipynb_checkpoints/Soldier & Dice (Risk)-checkpoint.ipynb b/your-project/.ipynb_checkpoints/Soldier & Dice (Risk)-checkpoint.ipynb new file mode 100644 index 0000000..00221be --- /dev/null +++ b/your-project/.ipynb_checkpoints/Soldier & Dice (Risk)-checkpoint.ipynb @@ -0,0 +1,225 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Project Week 1 - Build your own game!" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Soldier & Dice (RISK)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n" + ] + } + ], + "source": [ + "import random\n", + "\n", + "\n", + "\n", + "playagain=True\n", + "\n", + "while (playagain==True):\n", + " \n", + " player=0\n", + " machine=0\n", + " \n", + " diceuser=[]\n", + " dicemachine=[]\n", + " \n", + " print(\"\\n\")\n", + " x=input(\"Enter your number of soldiers for attacking or enter 'quit' if you want to surrend:\") \n", + " \n", + " \n", + " if x.isdigit() == False: \n", + " \n", + " if x.lower() == \"quit\":\n", + " playagain==False\n", + " print(\"\\n\")\n", + " print(\"Thank you for playing! That's all for now, folks!\")\n", + " print(\"------------------------------\")\n", + " break\n", + " else:\n", + " print(\"\\n\")\n", + " print(\"Please, introduce something I can understand if you want to play Risk with me!!\")\n", + " print(\"------------------------------\")\n", + " \n", + " else:\n", + " \n", + " \n", + " x=int(x)\n", + " \n", + " if x == 0:\n", + " print(\"\\n\")\n", + " print(\"How are you going to attack me with 0 soldiers? LOL\")\n", + " print(\"------------------------------\")\n", + " \n", + " if x == 1:\n", + " print(\"\\n\")\n", + " print(\"One soldier is not enough to attack! Don't waste our time!\")\n", + " print(\"------------------------------\")\n", + " \n", + " \n", + " \n", + " if x == 2:\n", + " diceuser.append(random.randint(1,6)) \n", + " dicemachine.append(random.randint(1,6)) \n", + " dicemachine.append(random.randint(1,6))\n", + " print(\"\\n\")\n", + " print(\"This is the best value you got in your dice\",max(diceuser))\n", + " print(\"And I got the following points in my dices :\",dicemachine,\"being my best value:\",max(dicemachine))\n", + " if max(diceuser)>max(dicemachine):\n", + " player=player+1\n", + " if max(dicemachine)>=max(diceuser):\n", + " machine=machine+1\n", + " if player > machine:\n", + " print(\"\\n\")\n", + " print(\"You win the battle! Lucky you, my friend!\")\n", + " print(\"------------------------------\")\n", + " if machine >= player:\n", + " print(\"\\n\")\n", + " print(\"Sayonara, baby! But in life you can always try again ;)\")\n", + " print(\"------------------------------\")\n", + " \n", + " \n", + " \n", + " if x == 3:\n", + " diceuser.append(random.randint(1,6)) \n", + " diceuser.append(random.randint(1,6)) \n", + " dicemachine.append(random.randint(1,6)) \n", + " dicemachine.append(random.randint(1,6))\n", + " print(\"\\n\")\n", + " print(\"You rolled two dices :\",diceuser,\"and your best value on them is:\",max(diceuser))\n", + " print(\"And I got the following points in my dices :\",dicemachine,\"being the best value of them:\",max(dicemachine))\n", + " if max(diceuser)>max(dicemachine):\n", + " player=player+1\n", + " if max(dicemachine)>=max(diceuser):\n", + " machine=machine+1\n", + " if player > machine:\n", + " print(\"\\n\")\n", + " print(\"You win the battle! Well done!\")\n", + " print(\"------------------------------\")\n", + " if machine >= player:\n", + " print(\"\\n\")\n", + " print(\"You lose the battle! :P\")\n", + " print(\"------------------------------\")\n", + " \n", + " \n", + " if x > 3:\n", + " diceuser.append(random.randint(1,6)) \n", + " diceuser.append(random.randint(1,6))\n", + " diceuser.append(random.randint(1,6))\n", + " dicemachine.append(random.randint(1,6)) \n", + " dicemachine.append(random.randint(1,6))\n", + " print(\"\\n\")\n", + " print(\"These are your results of rolling three dices :\",diceuser,\"and your best value is:\",max(diceuser))\n", + " print(\"I've rolled two dices:\",dicemachine,\"being my best value between them:\",max(dicemachine))\n", + " if max(diceuser)>max(dicemachine):\n", + " player=player+1\n", + " if max(dicemachine)>=max(diceuser):\n", + " machine=machine+1\n", + " if player > machine:\n", + " print(\"\\n\")\n", + " print(\"You win the battle! Obviously, with three dices is easier!\")\n", + " print(\"------------------------------\")\n", + " if machine >= player:\n", + " print(\"\\n\")\n", + " print(\"Loser! It's better if you quit now!\")\n", + " print(\"------------------------------\")\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.8.5" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": true + }, + "varInspector": { + "cols": { + "lenName": 16, + "lenType": 16, + "lenVar": 40 + }, + "kernels_config": { + "python": { + "delete_cmd_postfix": "", + "delete_cmd_prefix": "del ", + "library": "var_list.py", + "varRefreshCmd": "print(var_dic_list())" + }, + "r": { + "delete_cmd_postfix": ") ", + "delete_cmd_prefix": "rm(", + "library": "var_list.r", + "varRefreshCmd": "cat(var_dic_list()) " + } + }, + "types_to_exclude": [ + "module", + "function", + "builtin_function_or_method", + "instance", + "_Feature" + ], + "window_display": false + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/your-project/README.md b/your-project/README.md deleted file mode 100644 index 2a8493d..0000000 --- a/your-project/README.md +++ /dev/null @@ -1,34 +0,0 @@ -Ironhack Logo - -# Title of Your Project -*[Your Name]* - -*[Your Cohort, Campus & Date]* - -## Content -- [Project Description](#project-description) -- [Rules](#rules) -- [Workflow](#workflow) -- [Organization](#organization) -- [Links](#links) - -## Project Description -Write a short description of your project. Write 1-2 sentences about the game you chose to build and why. - -## Rules -Briefly describe the rules of the game. - -## Workflow -Outline the workflow you used in your project. What are the steps you went through? - -## Organization -How did you organize your work? Did you use any tools like a kanban board? - -What does your repository look like? Explain your folder and file structure. - -## Links -Include links to your repository, slides and kanban board. Feel free to include any other links associated with your project. - -[Repository](https://github.com/) -[Slides](https://slides.com/) -[Trello](https://trello.com/en) diff --git a/your-project/README.md.md b/your-project/README.md.md new file mode 100644 index 0000000..72e9ad1 --- /dev/null +++ b/your-project/README.md.md @@ -0,0 +1,54 @@ +Ironhack Logo + +# Project Week 1 - Build your own game! Soldier & Dice (RISK) +*[Jose Miguel Martinez Montero]* + +*[DAFT MAR21]* + +## Content +- [Project Description](#project-description) +- [Rules](#rules) +- [Workflow](#workflow) +- [Organization](#organization) +- [Links](#links) + +## Project Description + +In this first project of the **Data Analytics Bootcamp** we will create a basic game software from scratch, applying the knowledge about *Python functions* we were learning during the first week. + +I’ve chosen the game named **Soldier & Dice, as well known as Risk**, because this was my favourite board game since I was a child, and I thought It would be a beautiful challenge for me. + +## Rules + +Risk is a classic board game where two or more armies **will fight in order to dominate the whole world** reflected in the board by **continents and countries**. + +**To fight** against the player who controls a territory beside yours, **you have to roll any number of dices according with the number of soldiers you have**in the attacking territory. + +The defender player will roll some dices to defend, and then **the values between the biggest dices will be compared** in order to determine who is the winner and if the territory is conquered. + + +## Workflow + +First of all, I must **adapt the rules of the original game for more simplified ones**, ir order to code an usable software for this occasion. + +I’ve started simplifying the experience of the game into the main basic feature of the game: fighting with dices. + +Starting from a basic software of **generating random values for the dices**, the workflow was improving the game experience, including an input for the user, sophisticating the inner code and the visual result, and adding some funny different responses for every possible outcome. + +The last step was **checking some bugs and errors** in the program. + + + +## Organization + +First of all, I’ve planned my work with a ***Kanban board** using the platform named Trello. There, you can plan every task of the project beforehand and set some deadlines for each one. + +I’ve created this **GitHub repository**, including an updated Readme.md file and a .gitigonore file, well structured and functional. + + + +## Links + +[Repository](https://github.com/JoseMtnz/Project-Week-1-Build-Your-Own-Game) +[Slides](https://docs.google.com/presentation/d/1isMlPjJKHorkVztUK9MTdQjGEe-mFsR4zONfv_lh8FU/edit?usp=sharing) +[Trello](https://trello.com/b/bRxbx5Ky/project-week-1-build-your-own-game) diff --git a/your-project/Soldier & Dice (Risk).ipynb b/your-project/Soldier & Dice (Risk).ipynb new file mode 100644 index 0000000..00221be --- /dev/null +++ b/your-project/Soldier & Dice (Risk).ipynb @@ -0,0 +1,225 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Project Week 1 - Build your own game!" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Soldier & Dice (RISK)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n" + ] + } + ], + "source": [ + "import random\n", + "\n", + "\n", + "\n", + "playagain=True\n", + "\n", + "while (playagain==True):\n", + " \n", + " player=0\n", + " machine=0\n", + " \n", + " diceuser=[]\n", + " dicemachine=[]\n", + " \n", + " print(\"\\n\")\n", + " x=input(\"Enter your number of soldiers for attacking or enter 'quit' if you want to surrend:\") \n", + " \n", + " \n", + " if x.isdigit() == False: \n", + " \n", + " if x.lower() == \"quit\":\n", + " playagain==False\n", + " print(\"\\n\")\n", + " print(\"Thank you for playing! That's all for now, folks!\")\n", + " print(\"------------------------------\")\n", + " break\n", + " else:\n", + " print(\"\\n\")\n", + " print(\"Please, introduce something I can understand if you want to play Risk with me!!\")\n", + " print(\"------------------------------\")\n", + " \n", + " else:\n", + " \n", + " \n", + " x=int(x)\n", + " \n", + " if x == 0:\n", + " print(\"\\n\")\n", + " print(\"How are you going to attack me with 0 soldiers? LOL\")\n", + " print(\"------------------------------\")\n", + " \n", + " if x == 1:\n", + " print(\"\\n\")\n", + " print(\"One soldier is not enough to attack! Don't waste our time!\")\n", + " print(\"------------------------------\")\n", + " \n", + " \n", + " \n", + " if x == 2:\n", + " diceuser.append(random.randint(1,6)) \n", + " dicemachine.append(random.randint(1,6)) \n", + " dicemachine.append(random.randint(1,6))\n", + " print(\"\\n\")\n", + " print(\"This is the best value you got in your dice\",max(diceuser))\n", + " print(\"And I got the following points in my dices :\",dicemachine,\"being my best value:\",max(dicemachine))\n", + " if max(diceuser)>max(dicemachine):\n", + " player=player+1\n", + " if max(dicemachine)>=max(diceuser):\n", + " machine=machine+1\n", + " if player > machine:\n", + " print(\"\\n\")\n", + " print(\"You win the battle! Lucky you, my friend!\")\n", + " print(\"------------------------------\")\n", + " if machine >= player:\n", + " print(\"\\n\")\n", + " print(\"Sayonara, baby! But in life you can always try again ;)\")\n", + " print(\"------------------------------\")\n", + " \n", + " \n", + " \n", + " if x == 3:\n", + " diceuser.append(random.randint(1,6)) \n", + " diceuser.append(random.randint(1,6)) \n", + " dicemachine.append(random.randint(1,6)) \n", + " dicemachine.append(random.randint(1,6))\n", + " print(\"\\n\")\n", + " print(\"You rolled two dices :\",diceuser,\"and your best value on them is:\",max(diceuser))\n", + " print(\"And I got the following points in my dices :\",dicemachine,\"being the best value of them:\",max(dicemachine))\n", + " if max(diceuser)>max(dicemachine):\n", + " player=player+1\n", + " if max(dicemachine)>=max(diceuser):\n", + " machine=machine+1\n", + " if player > machine:\n", + " print(\"\\n\")\n", + " print(\"You win the battle! Well done!\")\n", + " print(\"------------------------------\")\n", + " if machine >= player:\n", + " print(\"\\n\")\n", + " print(\"You lose the battle! :P\")\n", + " print(\"------------------------------\")\n", + " \n", + " \n", + " if x > 3:\n", + " diceuser.append(random.randint(1,6)) \n", + " diceuser.append(random.randint(1,6))\n", + " diceuser.append(random.randint(1,6))\n", + " dicemachine.append(random.randint(1,6)) \n", + " dicemachine.append(random.randint(1,6))\n", + " print(\"\\n\")\n", + " print(\"These are your results of rolling three dices :\",diceuser,\"and your best value is:\",max(diceuser))\n", + " print(\"I've rolled two dices:\",dicemachine,\"being my best value between them:\",max(dicemachine))\n", + " if max(diceuser)>max(dicemachine):\n", + " player=player+1\n", + " if max(dicemachine)>=max(diceuser):\n", + " machine=machine+1\n", + " if player > machine:\n", + " print(\"\\n\")\n", + " print(\"You win the battle! Obviously, with three dices is easier!\")\n", + " print(\"------------------------------\")\n", + " if machine >= player:\n", + " print(\"\\n\")\n", + " print(\"Loser! It's better if you quit now!\")\n", + " print(\"------------------------------\")\n", + " \n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.8.5" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": true + }, + "varInspector": { + "cols": { + "lenName": 16, + "lenType": 16, + "lenVar": 40 + }, + "kernels_config": { + "python": { + "delete_cmd_postfix": "", + "delete_cmd_prefix": "del ", + "library": "var_list.py", + "varRefreshCmd": "print(var_dic_list())" + }, + "r": { + "delete_cmd_postfix": ") ", + "delete_cmd_prefix": "rm(", + "library": "var_list.r", + "varRefreshCmd": "cat(var_dic_list()) " + } + }, + "types_to_exclude": [ + "module", + "function", + "builtin_function_or_method", + "instance", + "_Feature" + ], + "window_display": false + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From 38872721cac2c2793a3d753467ead8d1699f58e0 Mon Sep 17 00:00:00 2001 From: Jose Martinez Date: Fri, 26 Mar 2021 11:04:18 +0000 Subject: [PATCH 2/3] My first project --- .../Soldier & Dice (Risk)-checkpoint.ipynb | 43 +++++++++++++++++++ your-project/{README.md.md => README.md} | 0 your-project/Soldier & Dice (Risk).ipynb | 7 +++ 3 files changed, 50 insertions(+) rename your-project/{README.md.md => README.md} (100%) diff --git a/your-project/.ipynb_checkpoints/Soldier & Dice (Risk)-checkpoint.ipynb b/your-project/.ipynb_checkpoints/Soldier & Dice (Risk)-checkpoint.ipynb index 00221be..f80f075 100644 --- a/your-project/.ipynb_checkpoints/Soldier & Dice (Risk)-checkpoint.ipynb +++ b/your-project/.ipynb_checkpoints/Soldier & Dice (Risk)-checkpoint.ipynb @@ -23,6 +23,49 @@ "name": "stdout", "output_type": "stream", "text": [ + "\n", + "\n", + "Enter your number of soldiers for attacking or enter 'quit' if you want to surrend:k\n", + "\n", + "\n", + "Please, introduce something I can understand if you want to play Risk with me!!\n", + "------------------------------\n", + "\n", + "\n", + "Enter your number of soldiers for attacking or enter 'quit' if you want to surrend:0\n", + "\n", + "\n", + "How are you going to attack me with 0 soldiers? LOL\n", + "------------------------------\n", + "\n", + "\n", + "Enter your number of soldiers for attacking or enter 'quit' if you want to surrend:1\n", + "\n", + "\n", + "One soldier is not enough to attack! Don't waste our time!\n", + "------------------------------\n", + "\n", + "\n", + "Enter your number of soldiers for attacking or enter 'quit' if you want to surrend:2\n", + "\n", + "\n", + "This is the best value you got in your dice 6\n", + "And I got the following points in my dices : [5, 4] being my best value: 5\n", + "\n", + "\n", + "You win the battle! Lucky you, my friend!\n", + "------------------------------\n", + "\n", + "\n", + "Enter your number of soldiers for attacking or enter 'quit' if you want to surrend:2\n", + "\n", + "\n", + "This is the best value you got in your dice 5\n", + "And I got the following points in my dices : [2, 1] being my best value: 2\n", + "\n", + "\n", + "You win the battle! Lucky you, my friend!\n", + "------------------------------\n", "\n", "\n" ] diff --git a/your-project/README.md.md b/your-project/README.md similarity index 100% rename from your-project/README.md.md rename to your-project/README.md diff --git a/your-project/Soldier & Dice (Risk).ipynb b/your-project/Soldier & Dice (Risk).ipynb index 00221be..30a64b6 100644 --- a/your-project/Soldier & Dice (Risk).ipynb +++ b/your-project/Soldier & Dice (Risk).ipynb @@ -23,6 +23,13 @@ "name": "stdout", "output_type": "stream", "text": [ + "\n", + "\n", + "Enter your number of soldiers for attacking or enter 'quit' if you want to surrend: \n", + "\n", + "\n", + "Please, introduce something I can understand if you want to play Risk with me!!\n", + "------------------------------\n", "\n", "\n" ] From 44e8964cfc3c301ccb37bcbd86c99545016f0979 Mon Sep 17 00:00:00 2001 From: Jose Martinez Date: Fri, 26 Mar 2021 11:11:20 +0000 Subject: [PATCH 3/3] My first project (final) --- .../Soldier & Dice (Risk)-checkpoint.ipynb | 268 ------------------ 1 file changed, 268 deletions(-) delete mode 100644 your-project/.ipynb_checkpoints/Soldier & Dice (Risk)-checkpoint.ipynb diff --git a/your-project/.ipynb_checkpoints/Soldier & Dice (Risk)-checkpoint.ipynb b/your-project/.ipynb_checkpoints/Soldier & Dice (Risk)-checkpoint.ipynb deleted file mode 100644 index f80f075..0000000 --- a/your-project/.ipynb_checkpoints/Soldier & Dice (Risk)-checkpoint.ipynb +++ /dev/null @@ -1,268 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Project Week 1 - Build your own game!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Soldier & Dice (RISK)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "\n", - "Enter your number of soldiers for attacking or enter 'quit' if you want to surrend:k\n", - "\n", - "\n", - "Please, introduce something I can understand if you want to play Risk with me!!\n", - "------------------------------\n", - "\n", - "\n", - "Enter your number of soldiers for attacking or enter 'quit' if you want to surrend:0\n", - "\n", - "\n", - "How are you going to attack me with 0 soldiers? LOL\n", - "------------------------------\n", - "\n", - "\n", - "Enter your number of soldiers for attacking or enter 'quit' if you want to surrend:1\n", - "\n", - "\n", - "One soldier is not enough to attack! Don't waste our time!\n", - "------------------------------\n", - "\n", - "\n", - "Enter your number of soldiers for attacking or enter 'quit' if you want to surrend:2\n", - "\n", - "\n", - "This is the best value you got in your dice 6\n", - "And I got the following points in my dices : [5, 4] being my best value: 5\n", - "\n", - "\n", - "You win the battle! Lucky you, my friend!\n", - "------------------------------\n", - "\n", - "\n", - "Enter your number of soldiers for attacking or enter 'quit' if you want to surrend:2\n", - "\n", - "\n", - "This is the best value you got in your dice 5\n", - "And I got the following points in my dices : [2, 1] being my best value: 2\n", - "\n", - "\n", - "You win the battle! Lucky you, my friend!\n", - "------------------------------\n", - "\n", - "\n" - ] - } - ], - "source": [ - "import random\n", - "\n", - "\n", - "\n", - "playagain=True\n", - "\n", - "while (playagain==True):\n", - " \n", - " player=0\n", - " machine=0\n", - " \n", - " diceuser=[]\n", - " dicemachine=[]\n", - " \n", - " print(\"\\n\")\n", - " x=input(\"Enter your number of soldiers for attacking or enter 'quit' if you want to surrend:\") \n", - " \n", - " \n", - " if x.isdigit() == False: \n", - " \n", - " if x.lower() == \"quit\":\n", - " playagain==False\n", - " print(\"\\n\")\n", - " print(\"Thank you for playing! That's all for now, folks!\")\n", - " print(\"------------------------------\")\n", - " break\n", - " else:\n", - " print(\"\\n\")\n", - " print(\"Please, introduce something I can understand if you want to play Risk with me!!\")\n", - " print(\"------------------------------\")\n", - " \n", - " else:\n", - " \n", - " \n", - " x=int(x)\n", - " \n", - " if x == 0:\n", - " print(\"\\n\")\n", - " print(\"How are you going to attack me with 0 soldiers? LOL\")\n", - " print(\"------------------------------\")\n", - " \n", - " if x == 1:\n", - " print(\"\\n\")\n", - " print(\"One soldier is not enough to attack! Don't waste our time!\")\n", - " print(\"------------------------------\")\n", - " \n", - " \n", - " \n", - " if x == 2:\n", - " diceuser.append(random.randint(1,6)) \n", - " dicemachine.append(random.randint(1,6)) \n", - " dicemachine.append(random.randint(1,6))\n", - " print(\"\\n\")\n", - " print(\"This is the best value you got in your dice\",max(diceuser))\n", - " print(\"And I got the following points in my dices :\",dicemachine,\"being my best value:\",max(dicemachine))\n", - " if max(diceuser)>max(dicemachine):\n", - " player=player+1\n", - " if max(dicemachine)>=max(diceuser):\n", - " machine=machine+1\n", - " if player > machine:\n", - " print(\"\\n\")\n", - " print(\"You win the battle! Lucky you, my friend!\")\n", - " print(\"------------------------------\")\n", - " if machine >= player:\n", - " print(\"\\n\")\n", - " print(\"Sayonara, baby! But in life you can always try again ;)\")\n", - " print(\"------------------------------\")\n", - " \n", - " \n", - " \n", - " if x == 3:\n", - " diceuser.append(random.randint(1,6)) \n", - " diceuser.append(random.randint(1,6)) \n", - " dicemachine.append(random.randint(1,6)) \n", - " dicemachine.append(random.randint(1,6))\n", - " print(\"\\n\")\n", - " print(\"You rolled two dices :\",diceuser,\"and your best value on them is:\",max(diceuser))\n", - " print(\"And I got the following points in my dices :\",dicemachine,\"being the best value of them:\",max(dicemachine))\n", - " if max(diceuser)>max(dicemachine):\n", - " player=player+1\n", - " if max(dicemachine)>=max(diceuser):\n", - " machine=machine+1\n", - " if player > machine:\n", - " print(\"\\n\")\n", - " print(\"You win the battle! Well done!\")\n", - " print(\"------------------------------\")\n", - " if machine >= player:\n", - " print(\"\\n\")\n", - " print(\"You lose the battle! :P\")\n", - " print(\"------------------------------\")\n", - " \n", - " \n", - " if x > 3:\n", - " diceuser.append(random.randint(1,6)) \n", - " diceuser.append(random.randint(1,6))\n", - " diceuser.append(random.randint(1,6))\n", - " dicemachine.append(random.randint(1,6)) \n", - " dicemachine.append(random.randint(1,6))\n", - " print(\"\\n\")\n", - " print(\"These are your results of rolling three dices :\",diceuser,\"and your best value is:\",max(diceuser))\n", - " print(\"I've rolled two dices:\",dicemachine,\"being my best value between them:\",max(dicemachine))\n", - " if max(diceuser)>max(dicemachine):\n", - " player=player+1\n", - " if max(dicemachine)>=max(diceuser):\n", - " machine=machine+1\n", - " if player > machine:\n", - " print(\"\\n\")\n", - " print(\"You win the battle! Obviously, with three dices is easier!\")\n", - " print(\"------------------------------\")\n", - " if machine >= player:\n", - " print(\"\\n\")\n", - " print(\"Loser! It's better if you quit now!\")\n", - " print(\"------------------------------\")\n", - " \n", - " \n", - " \n", - "\n", - "\n", - "\n", - "\n", - "\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.8.5" - }, - "toc": { - "base_numbering": 1, - "nav_menu": {}, - "number_sections": true, - "sideBar": true, - "skip_h1_title": false, - "title_cell": "Table of Contents", - "title_sidebar": "Contents", - "toc_cell": false, - "toc_position": {}, - "toc_section_display": true, - "toc_window_display": true - }, - "varInspector": { - "cols": { - "lenName": 16, - "lenType": 16, - "lenVar": 40 - }, - "kernels_config": { - "python": { - "delete_cmd_postfix": "", - "delete_cmd_prefix": "del ", - "library": "var_list.py", - "varRefreshCmd": "print(var_dic_list())" - }, - "r": { - "delete_cmd_postfix": ") ", - "delete_cmd_prefix": "rm(", - "library": "var_list.r", - "varRefreshCmd": "cat(var_dic_list()) " - } - }, - "types_to_exclude": [ - "module", - "function", - "builtin_function_or_method", - "instance", - "_Feature" - ], - "window_display": false - } - }, - "nbformat": 4, - "nbformat_minor": 4 -}