diff --git a/Hangman Game Project.pdf b/Hangman Game Project.pdf new file mode 100644 index 0000000..ad2373f Binary files /dev/null and b/Hangman Game Project.pdf differ diff --git a/your-project/.gitignore b/your-project/.gitignore new file mode 100644 index 0000000..6ececc8 --- /dev/null +++ b/your-project/.gitignore @@ -0,0 +1,30 @@ +# Created by https://www.toptal.com/developers/gitignore/api/windows +# Edit at https://www.toptal.com/developers/gitignore?templates=windows + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/windows \ No newline at end of file diff --git a/your-project/.ipynb_checkpoints/Hangman-checkpoint.ipynb b/your-project/.ipynb_checkpoints/Hangman-checkpoint.ipynb new file mode 100644 index 0000000..82f876e --- /dev/null +++ b/your-project/.ipynb_checkpoints/Hangman-checkpoint.ipynb @@ -0,0 +1,155 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Hangman" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Instructions\n", + "The goal is to guess the word to save the hangman from death. Enter one letter at a time to see if it’s in the word. If you have guessed correctly, the letter will appear in the blank spaces. If the letter is not in the word, you loose a life. The initial number of lifes is 7. If the word is not guessed before spending all 7 lifes, the game ends and you loose. If you guess the whole word, you win!!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Pseudocode\n", + "\n", + "\n", + "# First, the user will be shown a number of blank spaces ( _ ),\n", + "# that represent the number of letters the word to guess has. The word will be randomly selected from a tuple, and displayed\n", + "# to the user as blank spaces. \n", + "\n", + "# For this, the \"random\" library will be imported, and with random.choice(tuple), the word will be selected.\n", + "# Then, a user defined function will be created that converts the word into a set of \"_\" separated with spaces. (sep = \" \")?\n", + "\n", + "# The user then will be asked to introduce a letter (input function). If the letter belongs to the word (if loop), \n", + "# the program will return the letter in the position it belongs together with the rest of the rest of blank spaces.\n", + "# If the letter does not belong to the word, then the program will return a message saying: \n", + "# \"you lost one life, x lives remaining\"\n", + "# and the program will substract one life from the life counter, which starts with 7 lives.\n", + " \n", + "# If the life counter reaches 0, the game will end, the program will stop, and return the message: \"Game Over\".\n", + "\n", + "# If the user continues to guess letters correctly until he has the whole word, he will receive points equal to the \n", + "# number of remaining lives(points list). Then, a new different word will appear and the life counter will restart. " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "def check_letter(word, guesses):\n", + " failed = 0 \n", + "\n", + " for letter in word:\n", + " # compares the letter with the letter in guesses\n", + " if letter in guesses:\n", + " print(letter, end = \" \")\n", + " else:\n", + " print(\"_\", end = \" \")\n", + " failed += 1\n", + "\n", + " if failed == 0:\n", + " # user will win the game if fail is 0\n", + " print(\"You Win. The word is: \", word)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "def vidas(x):\n", + " words = (\"music\", \"destination\", \"electricity\", \"television\", \"laptop\", \"berlin\", \"amazon\", \"guitar\", \"love\", \"seagull\",\n", + " \"karate\", \"party\", \"hangman\", \"python\", \"teacher\", \"uncle\", \"car\", \"science\", \"screen\", \"chair\")\n", + " word = random.choice(words) # chooses a word randomly from the tuple \"words\"\n", + " guesses = str() # This is a string to which the letters entered by user will be added.\n", + " \n", + " while x > 0:\n", + "\n", + "\n", + " check_letter(word,guesses)\n", + "\n", + " guess = input(\"Guess a letter: \")\n", + "\n", + " # letters are stored in guesses\n", + " guesses += guess\n", + "\n", + " # check input with the letter in word\n", + " if guess not in word:\n", + " x -= 1\n", + " # if the letter is wrong then the following is printed\n", + " print(\"The letter does not belong in the word\")\n", + " print(\"You have\", + x, 'lives left')\n", + " if x == 0:\n", + " print(\"GAME OVER\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "_ _ _ _ _ Guess a letter: a\n", + "_ a _ _ _ Guess a letter: d\n", + "The letter does not belong in the word\n", + "You have 6 lives left\n", + "_ a _ _ _ Guess a letter: f\n", + "The letter does not belong in the word\n", + "You have 5 lives left\n", + "_ a _ _ _ " + ] + } + ], + "source": [ + "vidas(7)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "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" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/your-project/Hangman.ipynb b/your-project/Hangman.ipynb new file mode 100644 index 0000000..82f876e --- /dev/null +++ b/your-project/Hangman.ipynb @@ -0,0 +1,155 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Hangman" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Instructions\n", + "The goal is to guess the word to save the hangman from death. Enter one letter at a time to see if it’s in the word. If you have guessed correctly, the letter will appear in the blank spaces. If the letter is not in the word, you loose a life. The initial number of lifes is 7. If the word is not guessed before spending all 7 lifes, the game ends and you loose. If you guess the whole word, you win!!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Pseudocode\n", + "\n", + "\n", + "# First, the user will be shown a number of blank spaces ( _ ),\n", + "# that represent the number of letters the word to guess has. The word will be randomly selected from a tuple, and displayed\n", + "# to the user as blank spaces. \n", + "\n", + "# For this, the \"random\" library will be imported, and with random.choice(tuple), the word will be selected.\n", + "# Then, a user defined function will be created that converts the word into a set of \"_\" separated with spaces. (sep = \" \")?\n", + "\n", + "# The user then will be asked to introduce a letter (input function). If the letter belongs to the word (if loop), \n", + "# the program will return the letter in the position it belongs together with the rest of the rest of blank spaces.\n", + "# If the letter does not belong to the word, then the program will return a message saying: \n", + "# \"you lost one life, x lives remaining\"\n", + "# and the program will substract one life from the life counter, which starts with 7 lives.\n", + " \n", + "# If the life counter reaches 0, the game will end, the program will stop, and return the message: \"Game Over\".\n", + "\n", + "# If the user continues to guess letters correctly until he has the whole word, he will receive points equal to the \n", + "# number of remaining lives(points list). Then, a new different word will appear and the life counter will restart. " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "def check_letter(word, guesses):\n", + " failed = 0 \n", + "\n", + " for letter in word:\n", + " # compares the letter with the letter in guesses\n", + " if letter in guesses:\n", + " print(letter, end = \" \")\n", + " else:\n", + " print(\"_\", end = \" \")\n", + " failed += 1\n", + "\n", + " if failed == 0:\n", + " # user will win the game if fail is 0\n", + " print(\"You Win. The word is: \", word)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "def vidas(x):\n", + " words = (\"music\", \"destination\", \"electricity\", \"television\", \"laptop\", \"berlin\", \"amazon\", \"guitar\", \"love\", \"seagull\",\n", + " \"karate\", \"party\", \"hangman\", \"python\", \"teacher\", \"uncle\", \"car\", \"science\", \"screen\", \"chair\")\n", + " word = random.choice(words) # chooses a word randomly from the tuple \"words\"\n", + " guesses = str() # This is a string to which the letters entered by user will be added.\n", + " \n", + " while x > 0:\n", + "\n", + "\n", + " check_letter(word,guesses)\n", + "\n", + " guess = input(\"Guess a letter: \")\n", + "\n", + " # letters are stored in guesses\n", + " guesses += guess\n", + "\n", + " # check input with the letter in word\n", + " if guess not in word:\n", + " x -= 1\n", + " # if the letter is wrong then the following is printed\n", + " print(\"The letter does not belong in the word\")\n", + " print(\"You have\", + x, 'lives left')\n", + " if x == 0:\n", + " print(\"GAME OVER\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "_ _ _ _ _ Guess a letter: a\n", + "_ a _ _ _ Guess a letter: d\n", + "The letter does not belong in the word\n", + "You have 6 lives left\n", + "_ a _ _ _ Guess a letter: f\n", + "The letter does not belong in the word\n", + "You have 5 lives left\n", + "_ a _ _ _ " + ] + } + ], + "source": [ + "vidas(7)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "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" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/your-project/README.md b/your-project/README.md index 2a8493d..37e53cf 100644 --- a/your-project/README.md +++ b/your-project/README.md @@ -1,9 +1,9 @@ Ironhack Logo -# Title of Your Project -*[Your Name]* +# Hangman Game +*Alberto Ranz* -*[Your Cohort, Campus & Date]* +*[DA FT, Remote, May 2021]* ## Content - [Project Description](#project-description) @@ -13,22 +13,32 @@ - [Links](#links) ## Project Description -Write a short description of your project. Write 1-2 sentences about the game you chose to build and why. +I chose the Hangman game because it's a game I know very well and the rules are very simple. In this game the user has to guess a word by introducing the possible letters that build the word, only having 7 tries. ## Rules -Briefly describe the rules of the game. +The goal is to guess the word to save the hangman from death. Enter one letter at a time to see if it’s in the word. If you have guessed correctly, the letter will appear in the blank spaces. If the letter is not in the word, you loose a life. The initial number of lifes is 7. If the word is not guessed before spending all 7 lifes, the game ends and you loose. If you guess the whole word, you win! + ## Workflow -Outline the workflow you used in your project. What are the steps you went through? +The development of the game was divided in steps: +- Game choice: I chose one of the possibilities given. +- Download files: I cloned the repo from github. +- Research: I visited the link of the game, read the rules and played for a while to understand the behaviour of the programm. +- Pseudocode: I wrote a pseudocode for the programm. +- Code: whole code writing. +- Test: I tried out the game several times in all its possibilities to confirm it worked correctly. +- Update Readme and create .gitignore. +- Preparation of presentation. + ## Organization -How did you organize your work? Did you use any tools like a kanban board? +To organize my work I used a trello board, in which I created several cards with the different tasks. -What does your repository look like? Explain your folder and file structure. +My repo is in a folder which includes 3 files: .gitignore, README.md, and Hangman.ipynb. It also includes a folder called .ipynb_checkpoints. ## 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) +[Hangman Game](https://www.coolmathgames.com/0-hangman) +[Repository](https://github.com/albertoranz/Project-Week-1-Build-Your-Own-Game) +[Slides]() +[Trello](https://trello.com/b/0ZYfaXZH/hangman-project-1)