Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Hangman Game Project.pdf
Binary file not shown.
30 changes: 30 additions & 0 deletions your-project/.gitignore
Original file line number Diff line number Diff line change
@@ -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
155 changes: 155 additions & 0 deletions your-project/.ipynb_checkpoints/Hangman-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
155 changes: 155 additions & 0 deletions your-project/Hangman.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
34 changes: 22 additions & 12 deletions your-project/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<img src="https://bit.ly/2VnXWr2" alt="Ironhack Logo" width="100"/>

# Title of Your Project
*[Your Name]*
# Hangman Game
*Alberto Ranz*

*[Your Cohort, Campus & Date]*
*[DA FT, Remote, May 2021]*

## Content
- [Project Description](#project-description)
Expand All @@ -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)