From 2016757dbfaa41e78c24db61a213017328bdb9b7 Mon Sep 17 00:00:00 2001 From: lauratll Date: Wed, 2 Jun 2021 19:18:08 +0200 Subject: [PATCH 01/16] moved readme and create project --- .DS_Store | Bin 0 -> 6148 bytes your-project/README.md => README.md | 0 your-project/The_hangfolk_game_vlau.ipynb | 79 ++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 .DS_Store rename your-project/README.md => README.md (100%) create mode 100644 your-project/The_hangfolk_game_vlau.ipynb diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..bd6ddc8af4626348f3bc86eeb38d5eb78b397a8d GIT binary patch literal 6148 zcmeHK-A)rh6h2c5OpAtIn1~l9d&3B8lO`7;;WC^PM?!zM0Io+nF6A60Lr+Ow=GEiK4MmL-hyK{kq(+ zii=DGg&t!kQwMRTVzl*uZ2!Lk`q@>fNr#kDG4cF1(bxQC%q(P%UL)&(PUsoEq0jg= z>6DTQ*7ph413Du`ed>bML9OVR+8AYGHu3atdGVmvac|j=xRa&5!uNlQ%2aiFW>(6& ztUs)O3XjwvETW>{Yen4;y0se>N3rwYDwSRNQT#4#5B3_5wp3n3Y2NM{a+lJ~-29W8mo^%Wof^R>~aCLb>@Z|v-!o}CXb zMwefWf+X-iF*fgT4Bz0~s??XTn`bINM9!E$<}tDYtN<%;7X{p2BIoWxW)3UB3fyZ2 z^#0(XXbc>d7R}ay%3J|}RfLVfH=q7MPX~a3!_p!mFkz`cOBL>lA>7SDSUUOxmtR`6 zbP{G}jN@h&?uH`V#Y1=|okU=fYgT|2xURsIZ8r4z|LXSp|8)|#SOHexUMV1|+u?Q# zOLAxHjm7D+) Date: Wed, 2 Jun 2021 20:32:11 +0200 Subject: [PATCH 02/16] list of words added --- your-project/medicine_list.txt | 45 +++++ your-project/nature_list.txt | 51 ++++++ your-project/sports_list.txt | 321 +++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+) create mode 100644 your-project/medicine_list.txt create mode 100644 your-project/nature_list.txt create mode 100644 your-project/sports_list.txt diff --git a/your-project/medicine_list.txt b/your-project/medicine_list.txt new file mode 100644 index 0000000..10b3b1b --- /dev/null +++ b/your-project/medicine_list.txt @@ -0,0 +1,45 @@ +Surgeon +Anesthesiologist +Cardiologist +Traumatologist +Orthopedist +Gastroenterologist +Dermatologist +Gynaecologist +Urologist +Ophthalmologist +Therapist +Nurse +Paediatrician +Physician +Doctor +Family doctor +Chronic +Benign +Terminal +Treat +Cure +Sickness +Cold +Flu +Virus +Remedy +Wound +Burn +Fracture +Heal +Injury +Trauma +Disease +Exam +Diagnosis +Prescription +Urine sample +Blood sample +Hypertension +Cast +Vein +Syringe +Painkiller +Numb +Dosage diff --git a/your-project/nature_list.txt b/your-project/nature_list.txt new file mode 100644 index 0000000..12d19eb --- /dev/null +++ b/your-project/nature_list.txt @@ -0,0 +1,51 @@ +Canal +Bridge +Dam +Lighthouse +Island +Bay +Riverbank +Beach +Sea +Ocean +Coast +Ground +Dune +Desert +Cliff +Park +Meadow +Jungle +Forest +Glacier +Land +Hill +Field +Grass +Soil +Seashell +Mushroom +Pebble +Rock +Stone +Smoke +Pond +River +Wave +Sky +Water +Tree +Plant +Moss +Flower +Bush +Sand +Mud +Stars +Planet +Mine +Path +Road +Tunnel +Volcano +Cave \ No newline at end of file diff --git a/your-project/sports_list.txt b/your-project/sports_list.txt new file mode 100644 index 0000000..030e509 --- /dev/null +++ b/your-project/sports_list.txt @@ -0,0 +1,321 @@ +aerobics +archer +archery +arrow +athlete +athletics +badminton +ball +base +baseball +basketball +bat +baton +batter +batting +biathlon +bicycle +bicycling +bike +biking +billiards +bobsleigh +bocce +boomerang +boules +bow +bowler +bowling +boxer +boxing +bronze medal +bunt +canoe +canoeing +catch +catcher +champion +championship +cleats +club +coach +compete +competing +competition +C cont. +competitor +crew +cricket +croquet +cross country +cue +curling +cycle +cycling +cyclist +dart +dartboard +deadlifting +decathlon +defense +diamond +discus +dive +diver +diving +dodgeball +doubleheader +dugout +epee +equestrian +equipment +exercise +fencing +field +fielder +field hockey +fielding +figure skating +fitness +football +forward +free throw +frisbee +game +gear +geocaching + + + +go +goal +goalie +golf +golfer +golfing +guard +gym +gymnast +gymnastics +gymnasium +halftime +hammer throw +handball +hang gliding +hardball +helmet +heptathlon +high jump +hitter +hockey +hole-in-one +home +home plate +home run +home team +hoop +horseshoes +huddle +hurdle +ice hockey +ice rink +ice skates +ice skating +infield +infielder +inline skates +inning +jai-alai +javelin +jog +jogger +judo +jump +jumper +jumping +jump rope +karate +kayak +kayaker +kayaking +kickball +kneepads +king fu +kite +lacrosse +lawn bowling +league +long jump +lose +loser +luge +lutz +major league +mallet +martial arts +mat +medal +minor league +mitt +mouthguard +move +movement +MVP +net +no-hitter +Nordic skiing +offense +ollie +Olympics +orienteering +out +outfield +outfielder +paddle +paddleball +paddling +paintball +parasailing +parkour +P Cont. +pentathlon +pickleball +ping pong +pitch +pitcher +play +player +playing +playoffs +pogo stick +pole +pole vault +polo +pool +puck +quarter +quarterback +quiver +race +racer +racewalking +racing +racket +racquetball +rafting +referee +relay +ride +riding +rink +rock climbing +roller skates +roller skating +row +rower +rowing +rugby +run +runner +running +sailing +score +scoreboard +scuba +scull +S Cont. +sculling +shortstop +shot put +silver medal +skate +skating rink +skeleton +ski +skier +skiing +slalom +sled +sledder +sledding +snorkling + + +snowboard +snowboarder +snowboarding +snowshoeing +soccer +softball +somersault +speed skating +sport +sportsmanship +squash +stadium +stick +strike +stroke +Sumo wrestling +surfer +surfing +swim +swimmer +swimming +synchronized swimming +table tennis +taekwondo +tag +target +team +teammate +tee +telemark skiing +tennis +tetherball +throw +T Cont. +throwing +tie +toboggan +track and field +trampoline +triathlon +triathlete +triple jump +triple play +tug of war +ultramarathon +ultramarathoner +umpire +unicycle +unicyclist +uniform +vaulter +vaulting +visiting team +volley +volley ball +wakeboarding +walk +walker +walking +water polo +waterski +waterskier +waterskiing +weightlifter +weightlifting +weights +wetsuit +white water rafting +wicket +win +windsurfer +windsurfing +winner +winning +World Cup +World Series +wrestler +wrestling \ No newline at end of file From 1829104a298494366d920edcf5d8362dc2a92de9 Mon Sep 17 00:00:00 2001 From: lauratll Date: Wed, 2 Jun 2021 20:32:42 +0200 Subject: [PATCH 03/16] list sports modified --- your-project/sports_list.txt | 61 ++++++++++-------------------------- 1 file changed, 16 insertions(+), 45 deletions(-) diff --git a/your-project/sports_list.txt b/your-project/sports_list.txt index 030e509..8c76a6a 100644 --- a/your-project/sports_list.txt +++ b/your-project/sports_list.txt @@ -28,7 +28,6 @@ bowler bowling boxer boxing -bronze medal bunt canoe canoeing @@ -42,7 +41,6 @@ coach compete competing competition -C cont. competitor crew cricket @@ -84,9 +82,6 @@ frisbee game gear geocaching - - - go goal goalie @@ -108,24 +103,18 @@ heptathlon high jump hitter hockey -hole-in-one -home -home plate -home run -home team hoop horseshoes huddle hurdle -ice hockey -ice rink -ice skates -ice skating +icehockey +icerink +iceskates +iceskating infield infielder inline skates inning -jai-alai javelin jog jogger @@ -133,37 +122,34 @@ judo jump jumper jumping -jump rope +jumprope karate kayak kayaker kayaking kickball kneepads -king fu +kingfu kite lacrosse -lawn bowling +bowling league long jump lose loser luge lutz -major league mallet -martial arts +martialarts mat medal -minor league mitt mouthguard move movement MVP net -no-hitter -Nordic skiing +Nordicskiing offense ollie Olympics @@ -177,19 +163,16 @@ paddling paintball parasailing parkour -P Cont. pentathlon pickleball -ping pong +pingpong pitch pitcher play player playing playoffs -pogo stick pole -pole vault polo pool puck @@ -208,9 +191,9 @@ relay ride riding rink -rock climbing -roller skates -roller skating +climbing +rollerskates +rollerskating row rower rowing @@ -223,14 +206,9 @@ score scoreboard scuba scull -S Cont. sculling shortstop -shot put -silver medal skate -skating rink -skeleton ski skier skiing @@ -239,8 +217,6 @@ sled sledder sledding snorkling - - snowboard snowboarder snowboarding @@ -248,7 +224,6 @@ snowshoeing soccer softball somersault -speed skating sport sportsmanship squash @@ -256,29 +231,25 @@ stadium stick strike stroke -Sumo wrestling +Sumo surfer surfing swim swimmer swimming -synchronized swimming -table tennis +tabletennis taekwondo tag target team teammate tee -telemark skiing tennis tetherball throw -T Cont. throwing tie toboggan -track and field trampoline triathlon triathlete @@ -308,7 +279,7 @@ weightlifter weightlifting weights wetsuit -white water rafting +rafting wicket win windsurfer From e62584d98982f94c01c74fe14b1ac2b824a8fe16 Mon Sep 17 00:00:00 2001 From: lauratll Date: Wed, 2 Jun 2021 20:33:26 +0200 Subject: [PATCH 04/16] Game coding part 1 --- your-project/The_hangfolk_game_vlau.ipynb | 275 +++++++++++++++++++++- 1 file changed, 269 insertions(+), 6 deletions(-) diff --git a/your-project/The_hangfolk_game_vlau.ipynb b/your-project/The_hangfolk_game_vlau.ipynb index 542b014..6f4675e 100644 --- a/your-project/The_hangfolk_game_vlau.ipynb +++ b/your-project/The_hangfolk_game_vlau.ipynb @@ -13,7 +13,17 @@ "id": "f3e09790", "metadata": {}, "source": [ - "## Welcome" + "## Welcome " + ] + }, + { + "cell_type": "markdown", + "id": "a5cc6f6a", + "metadata": {}, + "source": [ + "In this section we will just ask the player for the name and welcome her/him. \n", + "
\n", + "After, we will explain a bit how the game works." ] }, { @@ -36,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "id": "16bd62a4", "metadata": {}, "outputs": [ @@ -44,15 +54,268 @@ "name": "stdout", "output_type": "stream", "text": [ - "Please, enter your name:laura\n", - "Welcome, laura\n" + "Please, enter your name: Laura\n", + "Hello, Laura\n" + ] + } + ], + "source": [ + "player_name = input(\"Please, enter your name: \")\n", + "print(\"Hello,\",player_name)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "5d1fbec7", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You probably know the game... In can you don't, I will quickly explain how it works...\n" + ] + } + ], + "source": [ + "print(\"You probably know the game... In can you don't, I will quickly explain how it works...\")" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "7c6a5020", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You will have to guess the choosen word, picking in eacht turn a letter from the alphabet.If you fail, a line will be added to the draw.\n" + ] + } + ], + "source": [ + "print(\"You will have to guess the choosen word, picking in eacht turn a letter from the alphabet.If you fail, a line will be added to the draw.\")" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "530fb986", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "If you fail too much, you will be hanged\n" + ] + } + ], + "source": [ + "print(\"If you fail too much, you will be hanged\")" + ] + }, + { + "cell_type": "markdown", + "id": "5a2c2c3c", + "metadata": {}, + "source": [ + "## Choosing a topic" + ] + }, + { + "cell_type": "markdown", + "id": "e2428500", + "metadata": {}, + "source": [ + "Now is thime for the player to choose for a topic and for a level of difficulty that will depend on how many letters the word to play will have." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "04505ed8", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Now I will display a list of topics and you will hace to pick one:\n" + ] + } + ], + "source": [ + "print(\"Now I will display a list of topics and you will hace to pick one:\")" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "c6d155bc", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "sports\n", + "medicine\n", + "nature\n" + ] + } + ], + "source": [ + "list_topics = [\"sports\", \"medicine\", \"nature\"]\n", + "\n", + "for topics in list_topics:\n", + " print(topics)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "a405c7e7", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Please, enter the topic you have choosen:sports\n", + "Great! You have choosen: sports\n" + ] + } + ], + "source": [ + "player_topic = input(\"Please, enter the topic you have choosen:\")\n", + "\n", + "check_topic= True\n", + "\n", + "while check_topic:\n", + " if player_topic in list_topics:\n", + " print(\"Great! You have choosen: \", player_topic)\n", + " check_topic=False\n", + " else:\n", + " player_topic = input(\"Please, enter the topic you have choosen correctly/from the list before:\") \n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "f58331d8", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "There are three levels of difficulty:\n", + "- In the easy level you play with words with less than 4 letters\n", + "- In the difficult level you play with words with more than 6 letters\n" + ] + } + ], + "source": [ + "print(\"There are three levels of difficulty:\")\n", + "\n", + "dic_difficulty = {\"less than 4\":\"easy\",\"more than 6\":\"medium\",\"more than 6\":\"difficult\"}\n", + "\n", + "#Why it does not print the medium one?\n", + "for letters,level in dic_difficulty.items():\n", + " print(f\"- In the {level} level you play with words with {letters} letters\")" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "f52dd6fe", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Please, enter the difficulty you would like:easy\n", + "Great! You have choosen: easy\n" ] } ], "source": [ - "player_name = input(\"Please, enter your name:\")\n", - "print(\"Welcome,\",player_name)" + "player_difficulty = input(\"Please, enter the difficulty you would like:\")\n", + "player_difficulty = str(player_difficulty)\n", + "\n", + "check_difficulty= True\n", + "\n", + "while check_difficulty:\n", + " if player_topic in dic_difficulty.values():\n", + " print(\"Great! You have choosen: \", player_difficulty)\n", + " check_difficulty=False\n", + " else:\n", + " player_difficulty = input(\"Please, enter the level correctly: \")\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "ef29601e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dic_words= {\"sports\": [\"aerobics\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "91b2f326", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4ff8234d", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ced89c46", + "metadata": {}, + "outputs": [], + "source": [ + "sports_words = []" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0227e73f", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From 03b154ad9bd728f78a2954f6f6081047e48ac874 Mon Sep 17 00:00:00 2001 From: lauratll Date: Wed, 2 Jun 2021 20:38:43 +0200 Subject: [PATCH 05/16] added gitignore file --- .../The_hangfolk_game_vlau-checkpoint.ipynb | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb diff --git a/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb b/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb new file mode 100644 index 0000000..fe9495d --- /dev/null +++ b/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb @@ -0,0 +1,89 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "1515067d", + "metadata": {}, + "source": [ + "# The hangfolk game version lau.0" + ] + }, + { + "cell_type": "markdown", + "id": "f3e09790", + "metadata": {}, + "source": [ + "## Welcome " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "7b1bd5ed", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Welcome to the hangfolk game version lau.0\n" + ] + } + ], + "source": [ + "print(\"Welcome to the hangfolk game version lau.0\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "16bd62a4", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Please, enter your name:5\n", + "Hello, 5\n" + ] + } + ], + "source": [ + "player_name = input(\"Please, enter your name:\")\n", + "print(\"Hello,\",player_name)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "dc74298e", + "metadata": {}, + "outputs": [], + "source": [ + "pr" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Laura1Env", + "language": "python", + "name": "laura1env" + }, + "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.9.2" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From b35df4bd2ace72e9acf8113233f21721dd76376b Mon Sep 17 00:00:00 2001 From: lauratll Date: Wed, 2 Jun 2021 23:54:14 +0200 Subject: [PATCH 06/16] topics implementation --- your-project/The_hangfolk_game_vlau.ipynb | 251 +++++++++++----------- 1 file changed, 126 insertions(+), 125 deletions(-) diff --git a/your-project/The_hangfolk_game_vlau.ipynb b/your-project/The_hangfolk_game_vlau.ipynb index 6f4675e..3752e6d 100644 --- a/your-project/The_hangfolk_game_vlau.ipynb +++ b/your-project/The_hangfolk_game_vlau.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "markdown", - "id": "a5cc6f6a", + "id": "b6149d2d", "metadata": {}, "source": [ "In this section we will just ask the player for the name and welcome her/him. \n", @@ -28,37 +28,20 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "7b1bd5ed", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Welcome to the hangfolk game version lau.0\n" - ] - } - ], + "outputs": [], "source": [ "print(\"Welcome to the hangfolk game version lau.0\")" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "16bd62a4", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Please, enter your name: Laura\n", - "Hello, Laura\n" - ] - } - ], + "outputs": [], "source": [ "player_name = input(\"Please, enter your name: \")\n", "print(\"Hello,\",player_name)" @@ -66,61 +49,37 @@ }, { "cell_type": "code", - "execution_count": 3, - "id": "5d1fbec7", + "execution_count": null, + "id": "4144b2fa", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You probably know the game... In can you don't, I will quickly explain how it works...\n" - ] - } - ], + "outputs": [], "source": [ "print(\"You probably know the game... In can you don't, I will quickly explain how it works...\")" ] }, { "cell_type": "code", - "execution_count": 4, - "id": "7c6a5020", + "execution_count": null, + "id": "569c5ea9", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You will have to guess the choosen word, picking in eacht turn a letter from the alphabet.If you fail, a line will be added to the draw.\n" - ] - } - ], + "outputs": [], "source": [ "print(\"You will have to guess the choosen word, picking in eacht turn a letter from the alphabet.If you fail, a line will be added to the draw.\")" ] }, { "cell_type": "code", - "execution_count": 5, - "id": "530fb986", + "execution_count": null, + "id": "630b4e4d", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "If you fail too much, you will be hanged\n" - ] - } - ], + "outputs": [], "source": [ "print(\"If you fail too much, you will be hanged\")" ] }, { "cell_type": "markdown", - "id": "5a2c2c3c", + "id": "140fdf03", "metadata": {}, "source": [ "## Choosing a topic" @@ -128,7 +87,7 @@ }, { "cell_type": "markdown", - "id": "e2428500", + "id": "6a6dec77", "metadata": {}, "source": [ "Now is thime for the player to choose for a topic and for a level of difficulty that will depend on how many letters the word to play will have." @@ -136,26 +95,18 @@ }, { "cell_type": "code", - "execution_count": 6, - "id": "04505ed8", + "execution_count": null, + "id": "9c2ba170", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Now I will display a list of topics and you will hace to pick one:\n" - ] - } - ], + "outputs": [], "source": [ "print(\"Now I will display a list of topics and you will hace to pick one:\")" ] }, { "cell_type": "code", - "execution_count": 7, - "id": "c6d155bc", + "execution_count": 32, + "id": "0c6388fa", "metadata": {}, "outputs": [ { @@ -177,8 +128,8 @@ }, { "cell_type": "code", - "execution_count": 8, - "id": "a405c7e7", + "execution_count": 33, + "id": "79db5868", "metadata": { "scrolled": true }, @@ -208,101 +159,151 @@ }, { "cell_type": "code", - "execution_count": 9, - "id": "f58331d8", + "execution_count": null, + "id": "926706f4", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "There are three levels of difficulty:\n", - "- In the easy level you play with words with less than 4 letters\n", - "- In the difficult level you play with words with more than 6 letters\n" - ] - } - ], + "outputs": [], "source": [ - "print(\"There are three levels of difficulty:\")\n", + "# print(\"There are three levels of difficulty:\")\n", "\n", - "dic_difficulty = {\"less than 4\":\"easy\",\"more than 6\":\"medium\",\"more than 6\":\"difficult\"}\n", + "# dic_difficulty = {\"less than 4\":\"easy\",\"more than 6\":\"medium\",\"more than 6\":\"difficult\"}\n", "\n", - "#Why it does not print the medium one?\n", - "for letters,level in dic_difficulty.items():\n", - " print(f\"- In the {level} level you play with words with {letters} letters\")" + "# #Why it does not print the medium one?\n", + "# for letters,level in dic_difficulty.items():\n", + "# print(f\"- In the {level} level you play with words with {letters} letters\")" ] }, { "cell_type": "code", - "execution_count": 13, - "id": "f52dd6fe", + "execution_count": 1, + "id": "2ab35097", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Please, enter the difficulty you would like:easy\n", - "Great! You have choosen: easy\n" + "Please, enter the difficulty you would like:easy\n" + ] + }, + { + "ename": "NameError", + "evalue": "name 'player_topic' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;32mwhile\u001b[0m \u001b[0mcheck_difficulty\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0mplayer_topic\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mdic_difficulty\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Great! You have choosen: \"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mplayer_difficulty\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mcheck_difficulty\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mNameError\u001b[0m: name 'player_topic' is not defined" ] } ], "source": [ - "player_difficulty = input(\"Please, enter the difficulty you would like:\")\n", - "player_difficulty = str(player_difficulty)\n", + "# player_difficulty = input(\"Please, enter the difficulty you would like:\")\n", + "# player_difficulty = str(player_difficulty)\n", "\n", - "check_difficulty= True\n", + "# check_difficulty= True\n", "\n", - "while check_difficulty:\n", - " if player_topic in dic_difficulty.values():\n", - " print(\"Great! You have choosen: \", player_difficulty)\n", - " check_difficulty=False\n", - " else:\n", - " player_difficulty = input(\"Please, enter the level correctly: \")\n", + "# while check_difficulty:\n", + "# if player_topic in dic_difficulty.values():\n", + "# print(\"Great! You have choosen: \", player_difficulty)\n", + "# check_difficulty=False\n", + "# else:\n", + "# player_difficulty = input(\"Please, enter the level correctly: \")\n", " " ] }, { "cell_type": "code", - "execution_count": 12, - "id": "ef29601e", + "execution_count": 34, + "id": "03418514", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ - "dic_words= {\"sports\": [\"aerobics\n" + "sports_file = open(\"sports_list.txt\")\n", + "medicine_file = open(\"medicine_list.txt\")\n", + "nature_file = open(\"nature_list.txt\")" ] }, { "cell_type": "code", - "execution_count": null, - "id": "91b2f326", + "execution_count": 35, + "id": "cc90d03d", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "def clean_list(list1, drop=\"\\n\"):\n", + " clean_list = []\n", + " for element in list1:\n", + " element = element.lower()\n", + " element = element.replace(drop,\"\")\n", + " clean_list.append(element)\n", + " return clean_list\n", + " \n" + ] }, { "cell_type": "code", - "execution_count": null, - "id": "4ff8234d", + "execution_count": 36, + "id": "426a3dcf", + "metadata": {}, + "outputs": [], + "source": [ + "sports_list = clean_list(sports_file)\n", + "medicine_list = clean_list(medicine_file)\n", + "nature_list = clean_list(nature_file)" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "c147ab4b", "metadata": {}, "outputs": [], + "source": [ + "dic_words = {}\n", + "\n", + "dic_words[\"sports\"] = sports_list\n", + "dic_words[\"medicine\"] = medicine_list\n", + "dic_words[\"nature\"] = nature_list" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "be9709a9", + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "def choose_word(topic):\n", + " chosen_word = random.choice(dic_words[\"sports\"])\n", + " return chosen_word\n", + "\n", + "chosen_word = choose_word(player_topic)" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "b0bae742", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "canoeing\n" + ] + } + ], "source": [] }, { "cell_type": "code", "execution_count": null, - "id": "ced89c46", + "id": "b1416359", "metadata": {}, "outputs": [], "source": [ @@ -312,7 +313,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0227e73f", + "id": "af16f6ac", "metadata": {}, "outputs": [], "source": [] From b8a3e1c68516a74031570b6366164a8339a95298 Mon Sep 17 00:00:00 2001 From: lauratll Date: Thu, 3 Jun 2021 10:06:15 +0200 Subject: [PATCH 07/16] script MVP game --- your-project/hangfolk.py | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 your-project/hangfolk.py diff --git a/your-project/hangfolk.py b/your-project/hangfolk.py new file mode 100644 index 0000000..4eeafa6 --- /dev/null +++ b/your-project/hangfolk.py @@ -0,0 +1,59 @@ + + + + +def generate_word_display(hidden_word, used_letters): + result = str() + for character in hidden_word: + if character in used_letters: + result = result + character + else: + result = result + "*" + return result + +def print_current_game(used_letters,encrypted_word): + print("Those are the letters you have used:", used_letters) + print("This is the word:", encrypted_word) + +def player_input_letter(): + input_letter = input("Please,enter a letter: ") + return input_letter + +def player_win(word,used_letters): + for character in word: + if character not in used_letters: + return False + return True + +def player_loose(lives): + if lives == 0: + return True + else: + False + + +def print_result(player_won, word): + if player_won: + print(f"Cool! You have won! The word was: {word}") + else: + print("Sorry, you have used all your lives. You are hanged!") + +ongoing = True +used_letters = [] +lives = 11 +player_won= False +word = "terrible" +while ongoing: + word_display = generate_word_display(word,used_letters) + print_current_game(used_letters, word_display) + player_letter = player_input_letter() + used_letters.append(player_letter) + if player_letter in word: + if player_win(word, used_letters): #a letter from the word is not in the list of letters + ongoing = False + player_won = True + else: + lives -= 1 + if player_loose(lives): + ongoing = False +print_result(player_won,word) From dbc0baf114dcf3e64381eaad82b7789f4599157a Mon Sep 17 00:00:00 2001 From: lauratll Date: Thu, 3 Jun 2021 10:16:39 +0200 Subject: [PATCH 08/16] first modified Readme --- README.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2a8493d..74fe558 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ Ironhack Logo -# Title of Your Project -*[Your Name]* +# The hangfolk game vlau.0 +*Laura* -*[Your Cohort, Campus & Date]* +*Data Analysis Bootcamp, May 2021, Remote* ## Content - [Project Description](#project-description) @@ -22,13 +22,22 @@ Briefly describe the rules of the game. 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. +Phases of the project + +I have used a Trello board to organize my task. +- The first phase was for creating the kanban board with all task required and flesible deadlines. During the first day I started with the desgin of the game and pseudocode. +- The second one for finished the pseudocode and started coding. +- The third phase to review the code, test the game, debug and prepare the presentation. +If extra times, some extra ideas can be implemented. + +The reposirtory + +The repository includes this Readme file and a gitignote. Inside of the folder your code, it includes a python file with the script of the game and a jupyter notebook. ## Links -Include links to your repository, slides and kanban board. Feel free to include any other links associated with your project. +Links to the repository, slides and kanban board of this project. [Repository](https://github.com/) [Slides](https://slides.com/) -[Trello](https://trello.com/en) +[Trello](https://trello.com/b/wEj7kAZd/project-1-built-your-own-game) From 1dbd1cc06485061389f0f2bbbbc1d3add7c77c5a Mon Sep 17 00:00:00 2001 From: lauratll Date: Thu, 3 Jun 2021 16:34:12 +0200 Subject: [PATCH 09/16] changed code and gitignore file added --- .gitignore | 34 ++++++++++++++++++++ your-project/hangfolk.py | 68 +++++++++++++++++++--------------------- 2 files changed, 67 insertions(+), 35 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..adde4b6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/macos +# Edit at https://www.toptal.com/developers/gitignore?templates=macos + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# End of https://www.toptal.com/developers/gitignore/api/macos \ No newline at end of file diff --git a/your-project/hangfolk.py b/your-project/hangfolk.py index 4eeafa6..d9a47e9 100644 --- a/your-project/hangfolk.py +++ b/your-project/hangfolk.py @@ -1,4 +1,16 @@ +def player_input_letter(letters) : #list of letters + while True: + input_letter = input("Please,enter a letter: ") + if input_letter not in letters and input_letter.isdigit() == False: + print("Hola") + break + elif input_letter in letters: + print("Please,.....") + elif input_letter.isdigit(): + print("Please....") + + return input_letter @@ -15,45 +27,31 @@ def print_current_game(used_letters,encrypted_word): print("Those are the letters you have used:", used_letters) print("This is the word:", encrypted_word) -def player_input_letter(): - input_letter = input("Please,enter a letter: ") - return input_letter -def player_win(word,used_letters): - for character in word: - if character not in used_letters: - return False - return True -def player_loose(lives): - if lives == 0: - return True - else: - False +def main(): + ongoing = True + used_letters = [] + lives = 11 + word = "terrible" + player_wins = False + while ongoing: + player_letter = player_input_letter() + used_letters.append(player_letter) + word_display = generate_word_display(word, used_letters) + if player_letter not in word: + lives -= 1 + if lives == 0: + ongoing = False -def print_result(player_won, word): - if player_won: + if "*" not in word_display: + ongoing= False + player_wins= True + + print_current_game(used_letters, word_display) + + if player_wins: print(f"Cool! You have won! The word was: {word}") else: print("Sorry, you have used all your lives. You are hanged!") - -ongoing = True -used_letters = [] -lives = 11 -player_won= False -word = "terrible" -while ongoing: - word_display = generate_word_display(word,used_letters) - print_current_game(used_letters, word_display) - player_letter = player_input_letter() - used_letters.append(player_letter) - if player_letter in word: - if player_win(word, used_letters): #a letter from the word is not in the list of letters - ongoing = False - player_won = True - else: - lives -= 1 - if player_loose(lives): - ongoing = False -print_result(player_won,word) From 827a59e71b2a63c1289bc6149df041979daea2d9 Mon Sep 17 00:00:00 2001 From: lauratll Date: Thu, 3 Jun 2021 16:37:48 +0200 Subject: [PATCH 10/16] cleaning repo --- .DS_Store | Bin 6148 -> 6148 bytes .gitignore | 34 ------- Kick-Off.md | 94 ------------------ your-project/.DS_Store | Bin 0 -> 6148 bytes .../The_hangfolk_game_vlau-checkpoint.ipynb | 89 ----------------- 5 files changed, 217 deletions(-) delete mode 100644 .gitignore delete mode 100644 Kick-Off.md create mode 100644 your-project/.DS_Store delete mode 100644 your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb diff --git a/.DS_Store b/.DS_Store index bd6ddc8af4626348f3bc86eeb38d5eb78b397a8d..040e5086fc688e7f43e5ea8d87018e5718fb4648 100644 GIT binary patch delta 56 zcmZoMXffDe&ZNxA5X9ih;K<;@;0vVn7;+g>Jah7slXCKt7#J7?7#JA4H^(upWS!W+ KvYDOZFFyceBMp%N delta 57 zcmZoMXffDe&ZN%G;LVW9kj#+Hpv&OTkOqW$47m&`o;mr+NjdpR3=9kcK)il)6w^x9 J&Fmb1`2ly?4ZQ#W diff --git a/.gitignore b/.gitignore deleted file mode 100644 index adde4b6..0000000 --- a/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/macos -# Edit at https://www.toptal.com/developers/gitignore?templates=macos - -### macOS ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -# End of https://www.toptal.com/developers/gitignore/api/macos \ No newline at end of file diff --git a/Kick-Off.md b/Kick-Off.md deleted file mode 100644 index f784834..0000000 --- a/Kick-Off.md +++ /dev/null @@ -1,94 +0,0 @@ -Ironhack Logo - -# Build your own game! - -## Content -- [Project Description](#project-description) -- [Games](#games) -- [Project Goals](#project-goals) -- [Requirements & Deliverables](#requirements-&-deliverables) -- [Mentoring](#mentoring) -- [Schedule](#schedule) -- [Presentation](#presentation) - -## Project Description -In this project, you will create your first software! -You are tasked with creating a **game** that interacts with the user, using functions and other basic python resources you have learned during the week. Your game will be able to take an input from the user and provide an output. - -You will also present your game to the class. - -## Games -You will be assigned one of the following games: - -* [Strong Random Password Generator](https://strongpasswordgenerator.com/) -* [Guess The Number](https://www.funbrain.com/games/guess-the-number) -* [Hangman](https://www.coolmathgames.com/0-hangman) -* [Message Encryption & Decryption](https://www.base64decode.org/) -* [Mastermind](https://www.webgamesonline.com/mastermind/) -* [Tic Tac Toe](https://www.google.com/search?q=tic+tac+toe&oq=tic+tac+toe&aqs=chrome..69i57j0l5.1876j0j4&sourceid=chrome&ie=UTF-8) -* [Blackjack](https://bicyclecards.com/how-to-play/blackjack/) -* [Soldier & Dice (Risk)](https://en.wikipedia.org/wiki/Risk_(game)#Attack_and_defense) - -## Project Goals -During this project you will: -* Fork and manage your own git repository. -* Build your own code from scratch. -* Put into practice the basic python concepts learned during the week. -* Get used to public presentations. - -## Requirements & Deliverables -The **mandatory** requirements that this project needs to satisfy are: -* The project must be planned. That is why creating a Kanban board is important. You can either do it manually (e.g. with post-its) or use an online tool like Trello. You can find a template for Trello [here](https://trello.com/b/pc2CNZTo/project-1-build-your-own-game). Remember that you **CAN'T CODE** until your project is planned. -* Your repository must be clean and organized; this means that it must include a *.gitignore* file and a README file and also have a functional file structure. You can easily create a *.gitignore* template [here](https://www.toptal.com/developers/gitignore). -* Your code must include at least one function. -* The project needs to be presented to your colleagues on the day of the presentation. - -The **mandatory** deliverables that you must turn in are: -* Link to the repository you used while working on your project. The repository must include all the files you used to build your game. Remember to commit often to avoid trouble in case you mess up: this means more than 1 commit! -* Link to Trello or picture of your Kanban Board. Include the link or the picture in the README file. - -The **deadline** to turn in the deliverables is right before the project presentations. - -## Mentoring -One of the TAs will be your mentor! - -Your mentor will: -* Keep track of your project in general terms. Your mentor will be the second person that knows more about the project, after you. -* Check if you are following your plan: are you keeping up with your tasks and deadlines? Do you have any obstacles blocking you? -* Help/support you with specific questions. - -Your mentor is **not** meant to: -* Know everything. -* Be your manager. You have to be responsible of your own tasks! - -## Schedule - -**Please note** that the following schedule is simply a guideline. Feel free to organize your work as you see fit. - -**Wednesday** -* Choose the game that you are going to code. -* Plan your project. Remember that we are providing you with a Trello [template](https://trello.com/b/pc2CNZTo/project-1-build-your-own-game). Remember that you **CAN'T CODE** until your project is planned. -* Fork the repository and edit the README overview. You can find a [template](https://github.com/ta-data-bcn/Project-Week-1-Build-Your-Own-Game/blob/master/your-project/README.md) for your README file in this repository. Remember to keep the README up-to-date. -* Once you finish, start coding! Remember to use functions. - -**Thursday** -* Finish the coding and possibly check for bugs in the program (e.g. check what happens if the player gives unexpected inputs to the program). -* In the evening, start preparing the slides for Friday's presentation. - -**Friday** -* Presentation time at **3PM**! There will be a 15-minute break during the presentations. - -## Presentation -You will have **3 minutes** to present your project to the class and then **2 minutes** for Q&A. - -The slides of your presentation must include the content listed below and a demo of your game: - -* Title of the project + Student name -* Description and rules of your game -* Workflow -* Challenges you encountered during the process -* Learnings -* Possible future improvements -* Demo of the game (remember to save time for it) - -Tip: you have only 3 minutes for this presentation so keep it simple! diff --git a/your-project/.DS_Store b/your-project/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d200fef07aadd08cbab582c10ebacb30ba64a366 GIT binary patch literal 6148 zcmeHKyG{c!5S)b+k!Vs56#QVQjjuKC-=t2$9Y+*0{k7R(L=+%HADN?h!7@yvNmm z-{Ogp6;FJ&y;roHZ*hW0Z1Bc=nzOdMZQ8Ek8Tx>8`tgSuXKATGDv%1K0;xbMuuB20 zy|n3pV~(jnDv%0%E1=(pLRYMTy`z0PI9LlnoG@(0x%Cpnq5)zJ>>U}QiBpMAm1r@< z>5P}itAV|v(;;><&xxBQIux Date: Thu, 3 Jun 2021 17:12:23 +0200 Subject: [PATCH 11/16] readme modified --- README.md | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 74fe558..2b08911 100644 --- a/README.md +++ b/README.md @@ -13,31 +13,48 @@ - [Links](#links) ## Project Description -Write a short description of your project. Write 1-2 sentences about the game you chose to build and why. + +In this project I will create a version of the hangman game called "The hangfolk vlau.0". It is a really funny game that I used to play at school when I was a child on the board. My own version will make it even more fun (specially after all the work behind)! ## Rules -Briefly describe the rules of the game. + +This game consists in guessing an unknown word picked randomly from a list of words. I will provide three topics to choose. +In each turn the player will pick a letter that, hopefully, the unknown word will contain. If this is the case, it will be shown on screen in which position is located together with a list of letters that have been already used.  +The player has 11 lives. That mean that you can just be wrong with your letter this amount of time, or you will be hanged! ## Workflow -Outline the workflow you used in your project. What are the steps you went through? + +The general workflow is the following: +- The player is welcome. +- The player inputs a letter. +- This word is added to the a list of already used letters. +- A display is generated showing the encrypted word and the list of letters that the player have already used. +- If the letter chosen by the player was in the word it will be placed in its correct position on the word display. +- The game will ask the player to input more letters until all letters are guessed or the player failes 11(the number of lives you will start with) times in guessing a letter. +- The game is finshed and a message is shown to see if the player has won. + ## Organization -Phases of the project +**Phases of the project** + +I have used a Trello board to organize my tasks. They where organized is three phases: + +- The first phase was for creating the kanban board with all tasks required and set flexible deadlines. It was as well the moment to start with the design of the game an the pseudocode. -I have used a Trello board to organize my task. -- The first phase was for creating the kanban board with all task required and flesible deadlines. During the first day I started with the desgin of the game and pseudocode. - The second one for finished the pseudocode and started coding. + - The third phase to review the code, test the game, debug and prepare the presentation. -If extra times, some extra ideas can be implemented. -The reposirtory +If I have extra time, I will implement extra fun on my game. + +**The repository** -The repository includes this Readme file and a gitignote. Inside of the folder your code, it includes a python file with the script of the game and a jupyter notebook. +The repository includes this Readme file and a gitignote. Inside of the folder your code, it includes a python file with the script of the game, a jupyter notebook where the code is commented, and 3 text files whith the lists f word for the 3 topics provided. ## Links Links to the repository, slides and kanban board of this project. -[Repository](https://github.com/) +[Repository](https://github.com/lauratll/Project-Week-1-Build-Your-Own-Game) [Slides](https://slides.com/) [Trello](https://trello.com/b/wEj7kAZd/project-1-built-your-own-game) From 717c3aa4a7046099025b6a27b1a1bcaaf0c9421a Mon Sep 17 00:00:00 2001 From: lauratll Date: Thu, 3 Jun 2021 20:14:14 +0200 Subject: [PATCH 12/16] code almost finished, change on the list --- .../The_hangfolk_game_vlau-checkpoint.ipynb | 321 +++++++++++++++ your-project/The_hangfolk_game_vlau.ipynb | 388 +++++++++--------- your-project/hangfolk.py | 192 +++++++-- your-project/sports_list.txt | 12 +- 4 files changed, 663 insertions(+), 250 deletions(-) create mode 100644 your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb diff --git a/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb b/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb new file mode 100644 index 0000000..bb3c683 --- /dev/null +++ b/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb @@ -0,0 +1,321 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "1515067d", + "metadata": {}, + "source": [ + "# The hangfolk game version lau.0" + ] + }, + { + "cell_type": "markdown", + "id": "8bbca474", + "metadata": {}, + "source": [ + "## Welcome" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "id": "a1a712bd", + "metadata": {}, + "outputs": [], + "source": [ + "def welcome():\n", + " '''\n", + " This function welcomes the player asking for her/his name.\n", + " It has no return, it just prints\n", + " '''\n", + "\n", + " player_name = input(\"Please, enter your name: \")\n", + " print(\"Hello,\",player_name)\n", + " print(\"You probably know the game... In can you don't, I will quickly explain how it works...\")\n", + " print(\"You will have to guess the choosen word, picking in each turn a letter from the alphabet.If you fail, you will loose one of the 11 lives you have\")\n", + " print(\"If you fail too much, you will be hanged\")" + ] + }, + { + "cell_type": "markdown", + "id": "fb48a160", + "metadata": {}, + "source": [ + "## Choosing a topic" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "id": "ad7f46ba", + "metadata": {}, + "outputs": [], + "source": [ + "def choose_a_topic():\n", + " '''\n", + " This function is for choosing a topic from the provided ones.\n", + " The player inputs the topic. The functions makes sures the topic is one of the given ones.\n", + " It returns the topic chosen by the player\n", + " '''\n", + "\n", + " print(\"Now I will display a list of topics and you will hace to pick one:\")\n", + " list_topics = [\"sports\", \"medicine\", \"nature\"]\n", + "\n", + " for topics in list_topics:\n", + " print(topics)\n", + "\n", + " player_topic = input(\"Please, enter the topic you have choosen:\")\n", + "\n", + " check_topic = True\n", + "\n", + " while check_topic:\n", + " if player_topic in list_topics:\n", + " print(\"Great! You have choosen: \", player_topic)\n", + " check_topic = False\n", + " else:\n", + " player_topic = input(\"Please, enter the topic you have choosen correctly/from the list before:\")\n", + "\n", + " return player_topic" + ] + }, + { + "cell_type": "markdown", + "id": "25b0fe0e", + "metadata": {}, + "source": [ + "## Providing a word" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8242c231", + "metadata": {}, + "outputs": [], + "source": [ + "def clean_list(list1, drop=\"\\n\"):\n", + " '''\n", + " This function cleans a list from escape sequences and transforms the elements/strings\n", + " in lower case.\n", + " The input is a list and drop can be modified with more special characters.\n", + " A new clean list is returned.\n", + " '''\n", + "\n", + " clean_list = []\n", + " for element in list1:\n", + " element = element.lower()\n", + " element = element.replace(drop, \"\")\n", + " clean_list.append(element)\n", + " return clean_list" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "id": "526880f8", + "metadata": {}, + "outputs": [], + "source": [ + "def choose_word(list1):\n", + " '''\n", + " This function selects randomly an element.\n", + " The input must be a list and the output is the selected element\n", + " '''\n", + " chosen_word = random.choice(list1)\n", + " return chosen_word" + ] + }, + { + "cell_type": "markdown", + "id": "6169bccf", + "metadata": {}, + "source": [ + "## Player inputs letter" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d6ca27fe", + "metadata": {}, + "outputs": [], + "source": [ + "def player_input_letter(letters) :\n", + " '''\n", + " This function ask the player for the letter to play. It also\n", + " makes sures that is not a repeated letter and is not a digit. It will ask untill\n", + " it get the right input.\n", + " The input must be a list and the output is the output a single character.\n", + " In this case the list of used letters.\n", + " '''\n", + "\n", + " while True:\n", + " input_letter = input(\"Please,enter a letter: \")\n", + " if input_letter not in letters and input_letter.isdigit() == False:\n", + " break\n", + " elif input_letter in letters:\n", + " print(\"Please,enter another letter. This one you have already used\")\n", + " elif input_letter.isdigit():\n", + " print(\"Please, enter a letter, not a digit\")\n", + "\n", + " return input_letter" + ] + }, + { + "cell_type": "markdown", + "id": "523369e2", + "metadata": {}, + "source": [ + "## Display of the game" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "id": "cec0f518", + "metadata": {}, + "outputs": [], + "source": [ + "def generate_word_display(hidden_word, list_letters):\n", + " '''\n", + " This function generates a display of the encrypted word. It creates\n", + " an empty string where the letters present on the list are concatenated with *,\n", + " for the letters that are not present in the list but in the word.\n", + " In this way, we just show the played letters.\n", + " the inputs are a string (the word) and a list (the used_letters)\n", + " '''\n", + " result = str()\n", + " for character in hidden_word:\n", + " if character in list_letters:\n", + " result = result + character\n", + " else:\n", + " result = result + \"*\"\n", + " return result" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "id": "cd2516f7", + "metadata": {}, + "outputs": [], + "source": [ + "def print_current_game(list_letters,hidden_word):\n", + " '''\n", + " This function prints the list of used letters and the encrypted word.\n", + " It will be print every turn, so it will show the advances on the game.\n", + " The inputs are a list of letter(the used letters) and a string (encrypted word)\n", + " '''\n", + " print(\"Those are the letters you have used:\", list_letters)\n", + " print(\"This is the word:\", hidden_word)" + ] + }, + { + "cell_type": "markdown", + "id": "2f42a1b8", + "metadata": {}, + "source": [ + "## Main function - Game" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "id": "5f02be38", + "metadata": {}, + "outputs": [], + "source": [ + "def main():\n", + " '''\n", + " This function is the one who is gonna make run the game as many times as the player wants\n", + " '''\n", + " print(\"Welcome to the hangfolk game version lau.0\")\n", + " while True:\n", + " welcome()\n", + "\n", + " player_topic = choose_a_topic()\n", + "\n", + " sports_file = open(\"/Users/lauratll/Documents/Data_Analysis/IronHack/Week_1/Project_week1/Project-Week-1-Build-Your-Own-Game/your-project/sports_list.txt\")\n", + " medicine_file = open(\"/Users/lauratll/Documents/Data_Analysis/IronHack/Week_1/Project_week1/Project-Week-1-Build-Your-Own-Game/your-project/medicine_list.txt\")\n", + " nature_file = open(\"/Users/lauratll/Documents/Data_Analysis/IronHack/Week_1/Project_week1/Project-Week-1-Build-Your-Own-Game/your-project/nature_list.txt\")\n", + " sports_list = clean_list(sports_file)\n", + " medicine_list = clean_list(medicine_file)\n", + " nature_list = clean_list(nature_file)\n", + "\n", + " dic_words = {}\n", + " dic_words[\"sports\"] = sports_list\n", + " dic_words[\"medicine\"] = medicine_list\n", + " dic_words[\"nature\"] = nature_list\n", + " word = choose_word(dic_words[player_topic])\n", + "\n", + " ongoing = True\n", + " used_letters = []\n", + " lives = 11\n", + " player_wins = False\n", + "\n", + " while ongoing:\n", + " player_letter = player_input_letter(used_letters)\n", + " used_letters.append(player_letter)\n", + " word_display = generate_word_display(word, used_letters)\n", + " if player_letter not in word:\n", + " lives -= 1\n", + " if lives == 0:\n", + " ongoing = False\n", + "\n", + " if \"*\" not in word_display:\n", + " ongoing= False\n", + " player_wins= True\n", + "\n", + " print_current_game(used_letters, word_display)\n", + "\n", + " if player_wins:\n", + " print(f\"Cool! You have won! The word was: {word}\")\n", + " else:\n", + " print(\"Sorry, you have used all your lives. You are hanged!\")\n", + "\n", + " play_again = input(\"Would you like to play again?(Yes/No)\")\n", + " if play_again == \"No\":\n", + " break" + ] + }, + { + "cell_type": "markdown", + "id": "c4995949", + "metadata": {}, + "source": [ + "## Starts the game!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ba6e077e", + "metadata": {}, + "outputs": [], + "source": [ + "main()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Laura1Env", + "language": "python", + "name": "laura1env" + }, + "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.9.2" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/your-project/The_hangfolk_game_vlau.ipynb b/your-project/The_hangfolk_game_vlau.ipynb index 3752e6d..bb3c683 100644 --- a/your-project/The_hangfolk_game_vlau.ipynb +++ b/your-project/The_hangfolk_game_vlau.ipynb @@ -10,313 +10,291 @@ }, { "cell_type": "markdown", - "id": "f3e09790", + "id": "8bbca474", "metadata": {}, "source": [ - "## Welcome " - ] - }, - { - "cell_type": "markdown", - "id": "b6149d2d", - "metadata": {}, - "source": [ - "In this section we will just ask the player for the name and welcome her/him. \n", - "
\n", - "After, we will explain a bit how the game works." + "## Welcome" ] }, { "cell_type": "code", - "execution_count": null, - "id": "7b1bd5ed", + "execution_count": 54, + "id": "a1a712bd", "metadata": {}, "outputs": [], "source": [ - "print(\"Welcome to the hangfolk game version lau.0\")" + "def welcome():\n", + " '''\n", + " This function welcomes the player asking for her/his name.\n", + " It has no return, it just prints\n", + " '''\n", + "\n", + " player_name = input(\"Please, enter your name: \")\n", + " print(\"Hello,\",player_name)\n", + " print(\"You probably know the game... In can you don't, I will quickly explain how it works...\")\n", + " print(\"You will have to guess the choosen word, picking in each turn a letter from the alphabet.If you fail, you will loose one of the 11 lives you have\")\n", + " print(\"If you fail too much, you will be hanged\")" ] }, { - "cell_type": "code", - "execution_count": null, - "id": "16bd62a4", + "cell_type": "markdown", + "id": "fb48a160", "metadata": {}, - "outputs": [], "source": [ - "player_name = input(\"Please, enter your name: \")\n", - "print(\"Hello,\",player_name)" + "## Choosing a topic" ] }, { "cell_type": "code", - "execution_count": null, - "id": "4144b2fa", + "execution_count": 55, + "id": "ad7f46ba", "metadata": {}, "outputs": [], "source": [ - "print(\"You probably know the game... In can you don't, I will quickly explain how it works...\")" + "def choose_a_topic():\n", + " '''\n", + " This function is for choosing a topic from the provided ones.\n", + " The player inputs the topic. The functions makes sures the topic is one of the given ones.\n", + " It returns the topic chosen by the player\n", + " '''\n", + "\n", + " print(\"Now I will display a list of topics and you will hace to pick one:\")\n", + " list_topics = [\"sports\", \"medicine\", \"nature\"]\n", + "\n", + " for topics in list_topics:\n", + " print(topics)\n", + "\n", + " player_topic = input(\"Please, enter the topic you have choosen:\")\n", + "\n", + " check_topic = True\n", + "\n", + " while check_topic:\n", + " if player_topic in list_topics:\n", + " print(\"Great! You have choosen: \", player_topic)\n", + " check_topic = False\n", + " else:\n", + " player_topic = input(\"Please, enter the topic you have choosen correctly/from the list before:\")\n", + "\n", + " return player_topic" ] }, { - "cell_type": "code", - "execution_count": null, - "id": "569c5ea9", + "cell_type": "markdown", + "id": "25b0fe0e", "metadata": {}, - "outputs": [], "source": [ - "print(\"You will have to guess the choosen word, picking in eacht turn a letter from the alphabet.If you fail, a line will be added to the draw.\")" + "## Providing a word" ] }, { "cell_type": "code", "execution_count": null, - "id": "630b4e4d", + "id": "8242c231", "metadata": {}, "outputs": [], "source": [ - "print(\"If you fail too much, you will be hanged\")" - ] - }, - { - "cell_type": "markdown", - "id": "140fdf03", - "metadata": {}, - "source": [ - "## Choosing a topic" - ] - }, - { - "cell_type": "markdown", - "id": "6a6dec77", - "metadata": {}, - "source": [ - "Now is thime for the player to choose for a topic and for a level of difficulty that will depend on how many letters the word to play will have." + "def clean_list(list1, drop=\"\\n\"):\n", + " '''\n", + " This function cleans a list from escape sequences and transforms the elements/strings\n", + " in lower case.\n", + " The input is a list and drop can be modified with more special characters.\n", + " A new clean list is returned.\n", + " '''\n", + "\n", + " clean_list = []\n", + " for element in list1:\n", + " element = element.lower()\n", + " element = element.replace(drop, \"\")\n", + " clean_list.append(element)\n", + " return clean_list" ] }, { "cell_type": "code", - "execution_count": null, - "id": "9c2ba170", + "execution_count": 56, + "id": "526880f8", "metadata": {}, "outputs": [], "source": [ - "print(\"Now I will display a list of topics and you will hace to pick one:\")" + "def choose_word(list1):\n", + " '''\n", + " This function selects randomly an element.\n", + " The input must be a list and the output is the selected element\n", + " '''\n", + " chosen_word = random.choice(list1)\n", + " return chosen_word" ] }, { - "cell_type": "code", - "execution_count": 32, - "id": "0c6388fa", + "cell_type": "markdown", + "id": "6169bccf", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "sports\n", - "medicine\n", - "nature\n" - ] - } - ], - "source": [ - "list_topics = [\"sports\", \"medicine\", \"nature\"]\n", - "\n", - "for topics in list_topics:\n", - " print(topics)" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "id": "79db5868", - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Please, enter the topic you have choosen:sports\n", - "Great! You have choosen: sports\n" - ] - } - ], "source": [ - "player_topic = input(\"Please, enter the topic you have choosen:\")\n", - "\n", - "check_topic= True\n", - "\n", - "while check_topic:\n", - " if player_topic in list_topics:\n", - " print(\"Great! You have choosen: \", player_topic)\n", - " check_topic=False\n", - " else:\n", - " player_topic = input(\"Please, enter the topic you have choosen correctly/from the list before:\") \n", - " " + "## Player inputs letter" ] }, { "cell_type": "code", "execution_count": null, - "id": "926706f4", + "id": "d6ca27fe", "metadata": {}, "outputs": [], "source": [ - "# print(\"There are three levels of difficulty:\")\n", + "def player_input_letter(letters) :\n", + " '''\n", + " This function ask the player for the letter to play. It also\n", + " makes sures that is not a repeated letter and is not a digit. It will ask untill\n", + " it get the right input.\n", + " The input must be a list and the output is the output a single character.\n", + " In this case the list of used letters.\n", + " '''\n", "\n", - "# dic_difficulty = {\"less than 4\":\"easy\",\"more than 6\":\"medium\",\"more than 6\":\"difficult\"}\n", + " while True:\n", + " input_letter = input(\"Please,enter a letter: \")\n", + " if input_letter not in letters and input_letter.isdigit() == False:\n", + " break\n", + " elif input_letter in letters:\n", + " print(\"Please,enter another letter. This one you have already used\")\n", + " elif input_letter.isdigit():\n", + " print(\"Please, enter a letter, not a digit\")\n", "\n", - "# #Why it does not print the medium one?\n", - "# for letters,level in dic_difficulty.items():\n", - "# print(f\"- In the {level} level you play with words with {letters} letters\")" + " return input_letter" ] }, { - "cell_type": "code", - "execution_count": 1, - "id": "2ab35097", + "cell_type": "markdown", + "id": "523369e2", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Please, enter the difficulty you would like:easy\n" - ] - }, - { - "ename": "NameError", - "evalue": "name 'player_topic' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;32mwhile\u001b[0m \u001b[0mcheck_difficulty\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0mplayer_topic\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mdic_difficulty\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Great! You have choosen: \"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mplayer_difficulty\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mcheck_difficulty\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mNameError\u001b[0m: name 'player_topic' is not defined" - ] - } - ], "source": [ - "# player_difficulty = input(\"Please, enter the difficulty you would like:\")\n", - "# player_difficulty = str(player_difficulty)\n", - "\n", - "# check_difficulty= True\n", - "\n", - "# while check_difficulty:\n", - "# if player_topic in dic_difficulty.values():\n", - "# print(\"Great! You have choosen: \", player_difficulty)\n", - "# check_difficulty=False\n", - "# else:\n", - "# player_difficulty = input(\"Please, enter the level correctly: \")\n", - " " + "## Display of the game" ] }, { "cell_type": "code", - "execution_count": 34, - "id": "03418514", + "execution_count": 57, + "id": "cec0f518", "metadata": {}, "outputs": [], "source": [ - "sports_file = open(\"sports_list.txt\")\n", - "medicine_file = open(\"medicine_list.txt\")\n", - "nature_file = open(\"nature_list.txt\")" + "def generate_word_display(hidden_word, list_letters):\n", + " '''\n", + " This function generates a display of the encrypted word. It creates\n", + " an empty string where the letters present on the list are concatenated with *,\n", + " for the letters that are not present in the list but in the word.\n", + " In this way, we just show the played letters.\n", + " the inputs are a string (the word) and a list (the used_letters)\n", + " '''\n", + " result = str()\n", + " for character in hidden_word:\n", + " if character in list_letters:\n", + " result = result + character\n", + " else:\n", + " result = result + \"*\"\n", + " return result" ] }, { "cell_type": "code", - "execution_count": 35, - "id": "cc90d03d", + "execution_count": 58, + "id": "cd2516f7", "metadata": {}, "outputs": [], "source": [ - "def clean_list(list1, drop=\"\\n\"):\n", - " clean_list = []\n", - " for element in list1:\n", - " element = element.lower()\n", - " element = element.replace(drop,\"\")\n", - " clean_list.append(element)\n", - " return clean_list\n", - " \n" + "def print_current_game(list_letters,hidden_word):\n", + " '''\n", + " This function prints the list of used letters and the encrypted word.\n", + " It will be print every turn, so it will show the advances on the game.\n", + " The inputs are a list of letter(the used letters) and a string (encrypted word)\n", + " '''\n", + " print(\"Those are the letters you have used:\", list_letters)\n", + " print(\"This is the word:\", hidden_word)" ] }, { - "cell_type": "code", - "execution_count": 36, - "id": "426a3dcf", + "cell_type": "markdown", + "id": "2f42a1b8", "metadata": {}, - "outputs": [], "source": [ - "sports_list = clean_list(sports_file)\n", - "medicine_list = clean_list(medicine_file)\n", - "nature_list = clean_list(nature_file)" + "## Main function - Game" ] }, { "cell_type": "code", - "execution_count": 37, - "id": "c147ab4b", + "execution_count": 59, + "id": "5f02be38", "metadata": {}, "outputs": [], "source": [ - "dic_words = {}\n", + "def main():\n", + " '''\n", + " This function is the one who is gonna make run the game as many times as the player wants\n", + " '''\n", + " print(\"Welcome to the hangfolk game version lau.0\")\n", + " while True:\n", + " welcome()\n", "\n", - "dic_words[\"sports\"] = sports_list\n", - "dic_words[\"medicine\"] = medicine_list\n", - "dic_words[\"nature\"] = nature_list" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "id": "be9709a9", - "metadata": {}, - "outputs": [], - "source": [ - "import random\n", + " player_topic = choose_a_topic()\n", + "\n", + " sports_file = open(\"/Users/lauratll/Documents/Data_Analysis/IronHack/Week_1/Project_week1/Project-Week-1-Build-Your-Own-Game/your-project/sports_list.txt\")\n", + " medicine_file = open(\"/Users/lauratll/Documents/Data_Analysis/IronHack/Week_1/Project_week1/Project-Week-1-Build-Your-Own-Game/your-project/medicine_list.txt\")\n", + " nature_file = open(\"/Users/lauratll/Documents/Data_Analysis/IronHack/Week_1/Project_week1/Project-Week-1-Build-Your-Own-Game/your-project/nature_list.txt\")\n", + " sports_list = clean_list(sports_file)\n", + " medicine_list = clean_list(medicine_file)\n", + " nature_list = clean_list(nature_file)\n", + "\n", + " dic_words = {}\n", + " dic_words[\"sports\"] = sports_list\n", + " dic_words[\"medicine\"] = medicine_list\n", + " dic_words[\"nature\"] = nature_list\n", + " word = choose_word(dic_words[player_topic])\n", + "\n", + " ongoing = True\n", + " used_letters = []\n", + " lives = 11\n", + " player_wins = False\n", + "\n", + " while ongoing:\n", + " player_letter = player_input_letter(used_letters)\n", + " used_letters.append(player_letter)\n", + " word_display = generate_word_display(word, used_letters)\n", + " if player_letter not in word:\n", + " lives -= 1\n", + " if lives == 0:\n", + " ongoing = False\n", + "\n", + " if \"*\" not in word_display:\n", + " ongoing= False\n", + " player_wins= True\n", "\n", - "def choose_word(topic):\n", - " chosen_word = random.choice(dic_words[\"sports\"])\n", - " return chosen_word\n", + " print_current_game(used_letters, word_display)\n", "\n", - "chosen_word = choose_word(player_topic)" + " if player_wins:\n", + " print(f\"Cool! You have won! The word was: {word}\")\n", + " else:\n", + " print(\"Sorry, you have used all your lives. You are hanged!\")\n", + "\n", + " play_again = input(\"Would you like to play again?(Yes/No)\")\n", + " if play_again == \"No\":\n", + " break" ] }, { - "cell_type": "code", - "execution_count": 40, - "id": "b0bae742", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "canoeing\n" - ] - } - ], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b1416359", + "cell_type": "markdown", + "id": "c4995949", "metadata": {}, - "outputs": [], "source": [ - "sports_words = []" + "## Starts the game!" ] }, { "cell_type": "code", "execution_count": null, - "id": "af16f6ac", + "id": "ba6e077e", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "main()" + ] } ], "metadata": { diff --git a/your-project/hangfolk.py b/your-project/hangfolk.py index d9a47e9..abd1fe7 100644 --- a/your-project/hangfolk.py +++ b/your-project/hangfolk.py @@ -1,57 +1,179 @@ +#######Welcome######### + +import random + + +def welcome(): + ''' + This function welcomes the player asking for her/his name and explain the basic rules. + It has no return, it just prints + ''' + + player_name = input("Please, enter your name: ") + print("Hello,",player_name) + print("You probably know the game... In can you don't, I will quickly explain how it works...") + print("You will have to guess the choosen word, picking in each turn a letter from the alphabet.If you fail, you will loose one of the 11 lives you have") + print("If you fail too much, you will be hanged") + + + +###############Chossing a topic############ +def choose_a_topic(): + ''' + This function is for choosing a topic from the provided ones. + The player inputs the topic. The functions makes sures the topic is one of the given ones. + It returns the topic chosen by the player + ''' + + print("Now I will display a list of topics and you will have to pick one:") + list_topics = ["sports", "medicine", "nature"] + + for topics in list_topics: + print(topics) + + player_topic = input("Please, enter the topic you have choosen:") + + check_topic = True + + while check_topic: + if player_topic in list_topics: + print("Great! You have choosen: ", player_topic) + check_topic = False + else: + player_topic = input("Please, enter the topic you have choosen correctly/from the list before:") + + return player_topic + + + +###################Providing a word############### + +def clean_list(list1, drop="\n"): + ''' + This function cleans a list from escape sequences and transforms the elements/strings + in lower case. + The input is a list and drop can be modified with more special characters. + A new clean list is returned. + ''' + + clean_list = [] + for element in list1: + element = element.lower() + element = element.replace(drop, "") + clean_list.append(element) + return clean_list + + + +def choose_word(list1): + ''' + This function selects randomly an element. + The input must be a list and the output is the selected element + ''' + chosen_word = random.choice(list1) + return chosen_word + + +#######Player inputs letters#################### + +def player_input_letter(letters) : + ''' + This function ask the player for the letter to play. It also + makes sures that is not a repeated letter and is not a digit. It will ask untill + it get the right input. + The input must be a list and the output is the output a single character. + In this case the list of used letters. + ''' -def player_input_letter(letters) : #list of letters while True: input_letter = input("Please,enter a letter: ") if input_letter not in letters and input_letter.isdigit() == False: - print("Hola") break elif input_letter in letters: - print("Please,.....") + print("Please,enter another letter. This one you have already used") elif input_letter.isdigit(): - print("Please....") + print("Please, enter a letter, not a digit") return input_letter +######Displa - -def generate_word_display(hidden_word, used_letters): +def generate_word_display(hidden_word, list_letters): + ''' + This function generates a display of the encrypted word. It creates + an empty string where the letters present on the list are concatenated with *, + for the letters that are not present in the list but in the word. + In this way, we just show the played letters. + the inputs are a string (the word) and a list (the used_letters) + ''' result = str() for character in hidden_word: - if character in used_letters: + if character in list_letters: result = result + character else: result = result + "*" return result -def print_current_game(used_letters,encrypted_word): - print("Those are the letters you have used:", used_letters) - print("This is the word:", encrypted_word) +def print_current_game(list_letters,hidden_word): + ''' + This function prints the list of used letters and the encrypted word. + It will be print every turn, so it will show the advances on the game. + The inputs are a list of letter(the used letters) and a string (encrypted word) + ''' + print("Those are the letters you have used:", list_letters) + print("This is the word:", hidden_word) def main(): - ongoing = True - used_letters = [] - lives = 11 - word = "terrible" - player_wins = False - - while ongoing: - player_letter = player_input_letter() - used_letters.append(player_letter) - word_display = generate_word_display(word, used_letters) - if player_letter not in word: - lives -= 1 - if lives == 0: - ongoing = False - - if "*" not in word_display: - ongoing= False - player_wins= True - - print_current_game(used_letters, word_display) - - if player_wins: - print(f"Cool! You have won! The word was: {word}") - else: - print("Sorry, you have used all your lives. You are hanged!") + ''' + This function is the one who is gonna make run the game as many times as the player wants + ''' + print("Welcome to the hangfolk game version lau.0") + while True: + welcome() + + player_topic = choose_a_topic() + + sports_file = open("/Users/lauratll/Documents/Data_Analysis/IronHack/Week_1/Project_week1/Project-Week-1-Build-Your-Own-Game/your-project/sports_list.txt") + medicine_file = open("/Users/lauratll/Documents/Data_Analysis/IronHack/Week_1/Project_week1/Project-Week-1-Build-Your-Own-Game/your-project/medicine_list.txt") + nature_file = open("/Users/lauratll/Documents/Data_Analysis/IronHack/Week_1/Project_week1/Project-Week-1-Build-Your-Own-Game/your-project/nature_list.txt") + sports_list = clean_list(sports_file) + medicine_list = clean_list(medicine_file) + nature_list = clean_list(nature_file) + + dic_words = {} + dic_words["sports"] = sports_list + dic_words["medicine"] = medicine_list + dic_words["nature"] = nature_list + word = choose_word(dic_words[player_topic]) + + ongoing = True + used_letters = [] + lives = 11 + player_wins = False + + while ongoing: + player_letter = player_input_letter(used_letters) + used_letters.append(player_letter) + word_display = generate_word_display(word, used_letters) + if player_letter not in word: + lives -= 1 + if lives == 0: + ongoing = False + + if "*" not in word_display: + ongoing= False + player_wins= True + + print_current_game(used_letters, word_display) + + if player_wins: + print(f"Cool! You have won! The word was: {word}") + else: + print("Sorry, you have used all your lives. You are hanged!") + + play_again = input("Would you like to play again?(Yes/No)") + if play_again == "No": + break +main() \ No newline at end of file diff --git a/your-project/sports_list.txt b/your-project/sports_list.txt index 8c76a6a..8c78c5f 100644 --- a/your-project/sports_list.txt +++ b/your-project/sports_list.txt @@ -45,7 +45,6 @@ competitor crew cricket croquet -cross country cue curling cycle @@ -71,9 +70,8 @@ exercise fencing field fielder -field hockey +hockey fielding -figure skating fitness football forward @@ -94,9 +92,8 @@ gymnast gymnastics gymnasium halftime -hammer throw handball -hang gliding +hangliding hardball helmet heptathlon @@ -134,7 +131,6 @@ kite lacrosse bowling league -long jump lose loser luge @@ -147,8 +143,6 @@ mitt mouthguard move movement -MVP -net Nordicskiing offense ollie @@ -286,7 +280,5 @@ windsurfer windsurfing winner winning -World Cup -World Series wrestler wrestling \ No newline at end of file From 02c765cd609cec8f1587dbcab91187e5c05c852d Mon Sep 17 00:00:00 2001 From: lauratll Date: Thu, 3 Jun 2021 21:21:41 +0200 Subject: [PATCH 13/16] change in last print, add the word --- .../.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb | 2 +- your-project/The_hangfolk_game_vlau.ipynb | 2 +- your-project/hangfolk.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb b/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb index bb3c683..a04adfe 100644 --- a/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb +++ b/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb @@ -271,7 +271,7 @@ " if player_wins:\n", " print(f\"Cool! You have won! The word was: {word}\")\n", " else:\n", - " print(\"Sorry, you have used all your lives. You are hanged!\")\n", + " print(f\"Sorry! You are hanged! The word was: {word}\")\n", "\n", " play_again = input(\"Would you like to play again?(Yes/No)\")\n", " if play_again == \"No\":\n", diff --git a/your-project/The_hangfolk_game_vlau.ipynb b/your-project/The_hangfolk_game_vlau.ipynb index bb3c683..a04adfe 100644 --- a/your-project/The_hangfolk_game_vlau.ipynb +++ b/your-project/The_hangfolk_game_vlau.ipynb @@ -271,7 +271,7 @@ " if player_wins:\n", " print(f\"Cool! You have won! The word was: {word}\")\n", " else:\n", - " print(\"Sorry, you have used all your lives. You are hanged!\")\n", + " print(f\"Sorry! You are hanged! The word was: {word}\")\n", "\n", " play_again = input(\"Would you like to play again?(Yes/No)\")\n", " if play_again == \"No\":\n", diff --git a/your-project/hangfolk.py b/your-project/hangfolk.py index abd1fe7..733ccc3 100644 --- a/your-project/hangfolk.py +++ b/your-project/hangfolk.py @@ -171,7 +171,7 @@ def main(): if player_wins: print(f"Cool! You have won! The word was: {word}") else: - print("Sorry, you have used all your lives. You are hanged!") + print(f"Sorry! You are hanged! The word was: {word}") play_again = input("Would you like to play again?(Yes/No)") if play_again == "No": From 3cde0e94f1f2e49357d4934db2eb7ce6dd967a0e Mon Sep 17 00:00:00 2001 From: lauratll Date: Thu, 3 Jun 2021 21:44:20 +0200 Subject: [PATCH 14/16] link to the presentation in the readme added --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b08911..3b1ba89 100644 --- a/README.md +++ b/README.md @@ -56,5 +56,5 @@ The repository includes this Readme file and a gitignote. Inside of the folder y Links to the repository, slides and kanban board of this project. [Repository](https://github.com/lauratll/Project-Week-1-Build-Your-Own-Game) -[Slides](https://slides.com/) +[Slides](https://drive.google.com/file/d/1m77y7zY-pr_Tz0wQ3pKA55tHAnHH0Lcy/view?usp=sharing) [Trello](https://trello.com/b/wEj7kAZd/project-1-built-your-own-game) From a293a64db7bffcf96a3aaad9957e8827fc8ea800 Mon Sep 17 00:00:00 2001 From: lauratll Date: Thu, 3 Jun 2021 23:56:33 +0200 Subject: [PATCH 15/16] added display lives left --- .../The_hangfolk_game_vlau-checkpoint.ipynb | 10 ++++++---- your-project/The_hangfolk_game_vlau.ipynb | 10 ++++++---- your-project/hangfolk.py | 9 ++++++--- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb b/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb index a04adfe..733ee59 100644 --- a/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb +++ b/your-project/.ipynb_checkpoints/The_hangfolk_game_vlau-checkpoint.ipynb @@ -200,14 +200,16 @@ "metadata": {}, "outputs": [], "source": [ - "def print_current_game(list_letters,hidden_word):\n", + "def print_current_game(list_letters,hidden_word,fails_left):\n", " '''\n", " This function prints the list of used letters and the encrypted word.\n", " It will be print every turn, so it will show the advances on the game.\n", - " The inputs are a list of letter(the used letters) and a string (encrypted word)\n", + " The inputs are a list of letter(the used letters), string (encrypted word) and\n", + " an integer(number of lives left)\n", " '''\n", " print(\"Those are the letters you have used:\", list_letters)\n", - " print(\"This is the word:\", hidden_word)" + " print(\"This is the word:\", hidden_word)\n", + " print(f\"You have {fails_left} lives left\")" ] }, { @@ -266,7 +268,7 @@ " ongoing= False\n", " player_wins= True\n", "\n", - " print_current_game(used_letters, word_display)\n", + " print_current_game(used_letters, word_display,lives)\n", "\n", " if player_wins:\n", " print(f\"Cool! You have won! The word was: {word}\")\n", diff --git a/your-project/The_hangfolk_game_vlau.ipynb b/your-project/The_hangfolk_game_vlau.ipynb index a04adfe..733ee59 100644 --- a/your-project/The_hangfolk_game_vlau.ipynb +++ b/your-project/The_hangfolk_game_vlau.ipynb @@ -200,14 +200,16 @@ "metadata": {}, "outputs": [], "source": [ - "def print_current_game(list_letters,hidden_word):\n", + "def print_current_game(list_letters,hidden_word,fails_left):\n", " '''\n", " This function prints the list of used letters and the encrypted word.\n", " It will be print every turn, so it will show the advances on the game.\n", - " The inputs are a list of letter(the used letters) and a string (encrypted word)\n", + " The inputs are a list of letter(the used letters), string (encrypted word) and\n", + " an integer(number of lives left)\n", " '''\n", " print(\"Those are the letters you have used:\", list_letters)\n", - " print(\"This is the word:\", hidden_word)" + " print(\"This is the word:\", hidden_word)\n", + " print(f\"You have {fails_left} lives left\")" ] }, { @@ -266,7 +268,7 @@ " ongoing= False\n", " player_wins= True\n", "\n", - " print_current_game(used_letters, word_display)\n", + " print_current_game(used_letters, word_display,lives)\n", "\n", " if player_wins:\n", " print(f\"Cool! You have won! The word was: {word}\")\n", diff --git a/your-project/hangfolk.py b/your-project/hangfolk.py index 733ccc3..45ffca8 100644 --- a/your-project/hangfolk.py +++ b/your-project/hangfolk.py @@ -114,14 +114,17 @@ def generate_word_display(hidden_word, list_letters): result = result + "*" return result -def print_current_game(list_letters,hidden_word): +def print_current_game(list_letters,hidden_word,fails_left): ''' This function prints the list of used letters and the encrypted word. It will be print every turn, so it will show the advances on the game. - The inputs are a list of letter(the used letters) and a string (encrypted word) + The inputs are a list of letter(the used letters), string (encrypted word) and + an integer(number of lives left) ''' print("Those are the letters you have used:", list_letters) print("This is the word:", hidden_word) + print(f"You have {fails_left} lives left") + @@ -166,7 +169,7 @@ def main(): ongoing= False player_wins= True - print_current_game(used_letters, word_display) + print_current_game(used_letters, word_display,lives) if player_wins: print(f"Cool! You have won! The word was: {word}") From b2aa4e4175ffedfe93038e9640850b029882e198 Mon Sep 17 00:00:00 2001 From: lauratll Date: Fri, 4 Jun 2021 00:06:01 +0200 Subject: [PATCH 16/16] actualized link to presentation in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b1ba89..1ca95e7 100644 --- a/README.md +++ b/README.md @@ -56,5 +56,5 @@ The repository includes this Readme file and a gitignote. Inside of the folder y Links to the repository, slides and kanban board of this project. [Repository](https://github.com/lauratll/Project-Week-1-Build-Your-Own-Game) -[Slides](https://drive.google.com/file/d/1m77y7zY-pr_Tz0wQ3pKA55tHAnHH0Lcy/view?usp=sharing) +[Slides](https://drive.google.com/file/d/1A2sbVdCMirgQOVL3RaTMTmUf_eGgOOpf/view?usp=sharing) [Trello](https://trello.com/b/wEj7kAZd/project-1-built-your-own-game)