diff --git a/your-code/.ipynb_checkpoints/check1_2-checkpoint.ipynb b/your-code/.ipynb_checkpoints/check1_2-checkpoint.ipynb new file mode 100644 index 00000000..8b87ebb7 --- /dev/null +++ b/your-code/.ipynb_checkpoints/check1_2-checkpoint.ipynb @@ -0,0 +1,426 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "door_d = {\n", + " \"name\": \"door d\",\n", + " \"type\": \"door\",\n", + "}\n", + "couch = {\n", + " \"name\": \"couch\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "door_a = {\n", + " \"name\": \"door a\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_a = {\n", + " \"name\": \"key for door a\",\n", + " \"type\": \"key\",\n", + " \"target\": door_a,\n", + "}\n", + "\n", + "piano = {\n", + " \"name\": \"piano\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "game_room = {\n", + " \"name\": \"game room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "#DEFINE BEDROOM1\n", + "\n", + "bedroom_1 = {\n", + " \"name\": \"bedroom 1\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "door_b = {\n", + " \"name\": \"door b\",\n", + " \"type\": \"door\",\n", + "}\n", + "door_c = {\n", + " \"name\": \"door c\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "queen_bed = {\n", + " \"name\": \"queen bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "key_b={\n", + " \"name\": \"key for door b\",\n", + " \"type\": \"key\",\n", + " \"target\": door_b\n", + "}\n", + "\n", + "\n", + "\n", + "#DEFINE BEDROOM2\n", + "\n", + "key_c = {\n", + " \"name\": \"key for door c\",\n", + " \"type\": \"key\",\n", + " \"target\": door_c,\n", + "}\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d\n", + "}\n", + "double_bed = {\n", + " \"name\": \"double bed\",\n", + " \"type\": \"furniture\"\n", + "}\n", + "dresser = {\n", + " \"name\": \"dresser\",\n", + " \"type\": \"furniture\"\n", + "}\n", + "bedroom_2 = {\n", + " \"name\": \"bedroom 2\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "\n", + "\n", + "# define LIVINGROOM\n", + "\n", + "\n", + "dining_table = {\n", + " \"name\": \"dining table\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "\n", + "\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d\n", + "}\n", + "\n", + "\n", + "living_room = {\n", + " \"name\": \"living room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "all_rooms = [game_room, bedroom_1, bedroom_2, living_room, outside]\n", + "\n", + "all_doors = [door_a, door_b, door_c, door_c]\n", + "\n", + "# define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"game room\": [couch, piano, door_a],\n", + " \"piano\": [key_a],\n", + " \"outside\": [door_a],\n", + " \"door a\": [game_room, bedroom_1],\n", + " \"queen bed\":[key_b],\n", + " \"door b\":[bedroom_1, bedroom_2],\n", + " \"door c\":[bedroom_1, living_room],\n", + " \"double bed\":[key_c],\n", + " \"dresser\": [key_d],\n", + " \"dinning table\":[living_room],\n", + " \"door d\":[living_room, outside],\n", + " \"bedroom 1\":[queen_bed,door_a,door_b,door_c],\n", + " \"bedroom 2\":[double_bed,door_c,door_d,dresser,door_b],\n", + " \"living room\":[dining_table, door_c, door_d]\n", + " \n", + "}\n", + " \n", + "\n", + "\n", + "\n", + "# define game state. Do not directly change this dict. \n", + "# Instead, when a new game starts, make a copy of this\n", + "# dict and use the copy to store gameplay state. This \n", + "# way you can replay the game multiple times.\n", + "\n", + "INIT_GAME_STATE = {\n", + " \"current_room\": game_room,\n", + " \"keys_collected\": [],\n", + " \"target_room\": outside\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "def linebreak():\n", + " \"\"\"\n", + " Print a line break\n", + " \"\"\"\n", + " print(\"\\n\\n\")\n", + "\n", + "def start_game():\n", + " \"\"\"\n", + " Start the game\n", + " \"\"\"\n", + " print(\"You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!\")\n", + " play_room(game_state[\"current_room\"])\n", + "\n", + "def play_room(room):\n", + " \"\"\"\n", + " Play a room. First check if the room being played is the target room.\n", + " If it is, the game will end with success. Otherwise, let player either \n", + " explore (list all items in this room) or examine an item found here.\n", + " \"\"\"\n", + " game_state[\"current_room\"] = room\n", + " if(game_state[\"current_room\"] == game_state[\"target_room\"]):\n", + " print(\"Congrats! You escaped the room!\")\n", + " else:\n", + " print(\"You are now in \" + room[\"name\"])\n", + " intended_action = input(\"What would you like to do? Type 'explore' or 'examine'?\").strip()\n", + " if intended_action == \"explore\":\n", + " explore_room(room)\n", + " play_room(room)\n", + " elif intended_action == \"examine\":\n", + " examine_item(input(\"What would you like to examine?\").strip())\n", + " else:\n", + " print(\"Not sure what you mean. Type 'explore' or 'examine'.\")\n", + " play_room(room)\n", + " linebreak()\n", + "\n", + "def explore_room(room):\n", + " \"\"\"\n", + " Explore a room. List all items belonging to this room.\n", + " \"\"\"\n", + " items = [i[\"name\"] for i in object_relations[room[\"name\"]]]\n", + " print(\"You explore the room. This is \" + room[\"name\"] + \". You find \" + \", \".join(items))\n", + "\n", + "def get_next_room_of_door(door, current_room):\n", + " \"\"\"\n", + " From object_relations, find the two rooms connected to the given door.\n", + " Return the room that is not the current_room.\n", + " \"\"\"\n", + " connected_rooms = object_relations[door[\"name\"]]\n", + " for room in connected_rooms:\n", + " if(not current_room == room):\n", + " return room\n", + "\n", + "def examine_item(item_name):\n", + " \"\"\"\n", + " Examine an item which can be a door or furniture.\n", + " First make sure the intended item belongs to the current room.\n", + " Then check if the item is a door. Tell player if key hasn't been \n", + " collected yet. Otherwise ask player if they want to go to the next\n", + " room. If the item is not a door, then check if it contains keys.\n", + " Collect the key if found and update the game state. At the end,\n", + " play either the current or the next room depending on the game state\n", + " to keep playing.\n", + " \"\"\"\n", + " current_room = game_state[\"current_room\"]\n", + " next_room = \"\"\n", + " output = None\n", + " \n", + " for item in object_relations[current_room[\"name\"]]:\n", + " if(item[\"name\"] == item_name):\n", + " output = \"You examine \" + item_name + \". \"\n", + " if(item[\"type\"] == \"door\"):\n", + " have_key = False\n", + " for key in game_state[\"keys_collected\"]:\n", + " if(key[\"target\"] == item):\n", + " have_key = True\n", + " if(have_key):\n", + " output += \"You unlock it with a key you have.\"\n", + " next_room = get_next_room_of_door(item, current_room)\n", + " else:\n", + " output += \"It is locked but you don't have the key.\"\n", + " else:\n", + " if(item[\"name\"] in object_relations and len(object_relations[item[\"name\"]])>0):\n", + " item_found = object_relations[item[\"name\"]].pop()\n", + " game_state[\"keys_collected\"].append(item_found)\n", + " output += \"You find \" + item_found[\"name\"] + \".\"\n", + " else:\n", + " output += \"There isn't anything interesting about it.\"\n", + " print(output)\n", + " break\n", + "\n", + " if(output is None):\n", + " print(\"The item you requested is not found in the current room.\")\n", + " \n", + " if(next_room and input(\"Do you want to go to the next room? Ener 'yes' or 'no'\").strip() == 'yes'):\n", + " play_room(next_room)\n", + " else:\n", + " play_room(current_room)\n", + " \n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!\n", + "You are now in game room\n", + "What would you like to do? Type 'explore' or 'examine'?examine\n", + "What would you like to examine?piano\n", + "You examine piano. You find key for door a.\n", + "You are now in game room\n", + "What would you like to do? Type 'explore' or 'examine'?examine\n", + "What would you like to examine?door a\n", + "You examine door a. You unlock it with a key you have.\n", + "Do you want to go to the next room? Ener 'yes' or 'no'yes\n", + "You are now in bedroom 1\n", + "What would you like to do? Type 'explore' or 'examine'?examine\n", + "What would you like to examine?queen bed\n", + "You examine queen bed. You find key for door b.\n", + "You are now in bedroom 1\n", + "What would you like to do? Type 'explore' or 'examine'?examine\n", + "What would you like to examine?door b\n", + "You examine door b. You unlock it with a key you have.\n", + "Do you want to go to the next room? Ener 'yes' or 'no'yes\n", + "You are now in bedroom 2\n", + "What would you like to do? Type 'explore' or 'examine'?explore\n", + "You explore the room. This is bedroom 2. You find double bed, door c, door d, dresser, door b\n", + "You are now in bedroom 2\n", + "What would you like to do? Type 'explore' or 'examine'?examine\n", + "What would you like to examine?double bed\n", + "You examine double bed. You find key for door c.\n", + "You are now in bedroom 2\n", + "What would you like to do? Type 'explore' or 'examine'?examine\n", + "What would you like to examine?door c\n", + "You examine door c. You unlock it with a key you have.\n", + "Do you want to go to the next room? Ener 'yes' or 'no'no\n", + "You are now in bedroom 2\n", + "What would you like to do? Type 'explore' or 'examine'?examine\n", + "What would you like to examine?dresser\n", + "You examine dresser. You find key for door d.\n", + "You are now in bedroom 2\n", + "What would you like to do? Type 'explore' or 'examine'?examine\n", + "What would you like to examine?door c\n", + "You examine door c. You unlock it with a key you have.\n", + "Do you want to go to the next room? Ener 'yes' or 'no'yes\n", + "You are now in bedroom 1\n", + "What would you like to do? Type 'explore' or 'examine'?examine\n", + "What would you like to examine?door d\n", + "The item you requested is not found in the current room.\n", + "You are now in bedroom 1\n", + "What would you like to do? Type 'explore' or 'examine'?explore\n", + "You explore the room. This is bedroom 1. You find queen bed, door a, door b, door c\n", + "You are now in bedroom 1\n", + "What would you like to do? Type 'explore' or 'examine'?examine\n", + "What would you like to examine?door c\n", + "You examine door c. You unlock it with a key you have.\n", + "Do you want to go to the next room? Ener 'yes' or 'no'yes\n", + "You are now in living room\n", + "What would you like to do? Type 'explore' or 'examine'?explore\n", + "You explore the room. This is living room. You find dining table, door c, door d\n", + "You are now in living room\n", + "What would you like to do? Type 'explore' or 'examine'?examine\n", + "What would you like to examine?door d\n", + "You examine door d. You unlock it with a key you have.\n", + "Do you want to go to the next room? Ener 'yes' or 'no'yes\n", + "Congrats! You escaped the room!\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + } + ], + "source": [ + "game_state = INIT_GAME_STATE.copy()\n", + "\n", + "start_game()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "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.8" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/your-code/.ipynb_checkpoints/day4 morning-checkpoint.ipynb b/your-code/.ipynb_checkpoints/day4 morning-checkpoint.ipynb new file mode 100644 index 00000000..279d6fd9 --- /dev/null +++ b/your-code/.ipynb_checkpoints/day4 morning-checkpoint.ipynb @@ -0,0 +1,146 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 34, + "id": "c2179e4a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['quick', 'brown', 'jumps', 'over', 'lazy']\n" + ] + } + ], + "source": [ + "#my solution\n", + "\n", + "strin_ph= ['the quick brown fox jumps over the lazy dog']\n", + "new_str=[]\n", + "\n", + "split_str= strin_ph[0].split()\n", + "\n", + "#new=[split_str for split_str if len(word) >=4 new_str.append(word) ]\n", + "\n", + "\n", + "for word in split_str :\n", + " if len(word) >= 4:\n", + " new_str.append(word)\n", + " else:\n", + " continue\n", + " \n", + "print(new_str) \n", + "\n", + "\n", + "\n", + "lst=[5, 5, 3, 5, 4, 4, 3]\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "383aef1c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[5, 5, 3, 5, 4, 4, 3]\n" + ] + } + ], + "source": [ + "#part 1 teacher solution\n", + "teste_st= ['the quick brown fox jumps over the lazy dog']\n", + "size=[]\n", + "split_to_list= teste_st[0].split(' ')\n", + "\n", + "for word in split_to_list:\n", + " if word.lower() != 'the':\n", + " lenght=len(word)\n", + " size.append(lenght)\n", + "print(size)" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "id": "6b0e728e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[5, 5, 3, 5, 4, 4, 3]\n" + ] + } + ], + "source": [ + "#list comprehension\n", + "teste_st= ['the quick brown fox jumps over the lazy dog']\n", + "\n", + "test_list= teste_st[0].split(' ')\n", + "\n", + "size=[len(word) for word in test_list if word.lower() != 'the']\n", + "\n", + "print(size)" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "id": "4d835242", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "quick brown jumps over lazy\n" + ] + } + ], + "source": [ + "#part 2\n", + "\n", + "lst=' '.join([word for word in test_list if len(word) >=4])\n", + "\n", + "print(lst)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "53feac77", + "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.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/your-code/.ipynb_checkpoints/menu testing-checkpoint.ipynb b/your-code/.ipynb_checkpoints/menu testing-checkpoint.ipynb new file mode 100644 index 00000000..60478058 --- /dev/null +++ b/your-code/.ipynb_checkpoints/menu testing-checkpoint.ipynb @@ -0,0 +1,425 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "001a0c8c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " ************Welcome to Hogwards Escape Room*************\n", + " \n", + " Welcome to our new Hogwarts Escape Room! Before we begin our journey, we would like to say a few words...\n", + " \n", + " Choose wisely your paths and remember your spells... \n", + " \n", + "\n", + " Let's proceed! You are now in: game room\n", + "Choose one of these options:\n", + " \n", + " A: Explore what's in the room\n", + " B: Examine what you want to\n", + " \n", + "\n", + " Please enter your choice: a\n", + "\n", + " You explore the room. This is game room. You find these objects: \n", + "- couch\n", + "- piano\n", + "- door a\n", + "\n", + " Let's proceed! You are now in: game room\n", + "Choose one of these options:\n", + " \n", + " A: Explore what's in the room\n", + " B: Examine what you want to\n", + " \n", + "\n", + " Please enter your choice: couch\n", + "\n", + " That is a muggle error! You must only type either A or B.\n", + "\n", + " Let's proceed! You are now in: game room\n", + "Choose one of these options:\n", + " \n", + " A: Explore what's in the room\n", + " B: Examine what you want to\n", + " \n", + "\n", + " Please enter your choice: b\n", + " \n", + " What would you like to examine? \n", + "piano\n", + "\n", + " You examine piano. You find key for door a.\n" + ] + } + ], + "source": [ + "\n", + "import csv\n", + "import sys\n", + "\n", + "# def main():\n", + "# menu()\n", + "\n", + "\n", + "# def menu():\n", + " \n", + " \n", + "# # global choice\n", + "# choice = input(\"\"\" ************Welcome to Hogwards Escape Room*************\n", + " \n", + "# To start choose one of these options:\n", + " \n", + "# A: Explore what's in the room\n", + "# B: Examine what you want to\n", + " \n", + "\n", + "# Please enter your choice: \"\"\")\n", + "\n", + "# if choice.upper() == \"A\" :\n", + " \n", + " \n", + "# elif choice.upper() == \"B\" :\n", + "# print('you are now in chamber B ')\n", + " \n", + "# else:\n", + "# print(\"\\n You must only select either A or B\")\n", + "# print(\"\\n That is a muggle error, read carefully again! \\n\")\n", + "# menu()\n", + " \n", + "# main() \n", + " \n", + "#the program is initiated, so to speak, here\n", + "#main()\n", + "\n", + "door_d = {\n", + " \"name\": \"door d\",\n", + " \"type\": \"door\",\n", + "}\n", + "couch = {\n", + " \"name\": \"couch\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "door_a = {\n", + " \"name\": \"door a\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_a = {\n", + " \"name\": \"key for door a\",\n", + " \"type\": \"key\",\n", + " \"target\": door_a,\n", + "}\n", + "\n", + "piano = {\n", + " \"name\": \"piano\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "game_room = {\n", + " \"name\": \"game room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "#DEFINE BEDROOM1\n", + "\n", + "bedroom_1 = {\n", + " \"name\": \"bedroom 1\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "door_b = {\n", + " \"name\": \"door b\",\n", + " \"type\": \"door\",\n", + "}\n", + "door_c = {\n", + " \"name\": \"door c\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "queen_bed = {\n", + " \"name\": \"queen bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "key_b={\n", + " \"name\": \"key for door b\",\n", + " \"type\": \"key\",\n", + " \"target\": door_b\n", + "}\n", + "\n", + "\n", + "\n", + "#DEFINE BEDROOM2\n", + "\n", + "key_c = {\n", + " \"name\": \"key for door c\",\n", + " \"type\": \"key\",\n", + " \"target\": door_c,\n", + "}\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d\n", + "}\n", + "double_bed = {\n", + " \"name\": \"double bed\",\n", + " \"type\": \"furniture\"\n", + "}\n", + "dresser = {\n", + " \"name\": \"dresser\",\n", + " \"type\": \"furniture\"\n", + "}\n", + "bedroom_2 = {\n", + " \"name\": \"bedroom 2\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "\n", + "\n", + "# Define LIVINGROOM\n", + "\n", + "\n", + "dining_table = {\n", + " \"name\": \"dining table\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "\n", + "\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d\n", + "}\n", + "\n", + "\n", + "living_room = {\n", + " \"name\": \"living room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "all_rooms = [game_room, bedroom_1, bedroom_2, living_room, outside]\n", + "\n", + "all_doors = [door_a, door_b, door_c, door_c]\n", + "\n", + "# Define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"game room\": [couch, piano, door_a],\n", + " \"piano\": [key_a],\n", + " \"outside\": [door_a],\n", + " \"door a\": [game_room, bedroom_1],\n", + " \"queen bed\":[key_b],\n", + " \"door b\":[bedroom_1, bedroom_2],\n", + " \"door c\":[bedroom_1, living_room],\n", + " \"double bed\":[key_c],\n", + " \"dresser\": [key_d],\n", + " \"dinning table\":[living_room],\n", + " \"door d\":[living_room, outside],\n", + " \"bedroom 1\":[queen_bed,door_a,door_b,door_c],\n", + " \"bedroom 2\":[double_bed,door_c,door_d,dresser,door_b],\n", + " \"living room\":[dining_table, door_c, door_d]\n", + " \n", + "}\n", + " \n", + "\n", + "\n", + "\n", + "# define game state. Do not directly change this dict. \n", + "# Instead, when a new game starts, make a copy of this\n", + "# dict and use the copy to store gameplay state. This \n", + "# way you can replay the game multiple times.\n", + "\n", + "INIT_GAME_STATE = {\n", + " \"current_room\": game_room,\n", + " \"keys_collected\": [],\n", + " \"target_room\": outside\n", + "}\n", + "\n", + "def linebreak():\n", + " \"\"\"\n", + " Print a line break\n", + " \"\"\"\n", + " print(\"\\n\\n\")\n", + "\n", + "def start_game():\n", + " \"\"\"\n", + " Start the game\n", + " \"\"\"\n", + " print(\"\"\" ************Welcome to Hogwards Escape Room*************\n", + " \n", + " Welcome to our new Hogwarts Escape Room! Before we begin our journey, we would like to say a few words...\n", + " \n", + " Choose wisely your paths and remember your spells... \n", + " \"\"\")\n", + " play_room(game_state[\"current_room\"])\n", + "\n", + "def play_room(room):\n", + " \"\"\"\n", + " Play a room. First check if the room being played is the target room.\n", + " If it is, the game will end with success. Otherwise, let player either \n", + " explore (list all items in this room) or examine an item found here.\n", + " \"\"\"\n", + " game_state[\"current_room\"] = room\n", + " if(game_state[\"current_room\"] == game_state[\"target_room\"]):\n", + " print(\"Congrats! You escaped the room!\")\n", + " else:\n", + "# if room[\"name\"] == game_state[\"current_room\"]: \n", + "# print(\"\\n You are still in: \" + room[\"name\"])\n", + "# else:\n", + " print(\"\\n Let's proceed! You are now in: \" + room[\"name\"])\n", + " #intended_action = input(\"What would you like to do? Type 'explore' or 'examine'?\").strip()\n", + " choice = input(\"\"\"Choose one of these options:\n", + " \n", + " A: Explore what's in the room\n", + " B: Examine what you want to\n", + " \n", + "\n", + " Please enter your choice: \"\"\")\n", + " if choice.upper() == \"A\":\n", + " explore_room(room)\n", + " play_room(room)\n", + " elif choice.upper() == \"B\":\n", + " examine_item(input(\" \\n What would you like to examine? \\n\").strip())\n", + " else:\n", + " print(\"\\n That is a muggle error! You must only type either A or B.\")\n", + " play_room(room)\n", + " linebreak()\n", + "\n", + "def explore_room(room):\n", + " \"\"\"\n", + " Explore a room. List all items belonging to this room.\n", + " \"\"\"\n", + " items = [i[\"name\"] for i in object_relations[room[\"name\"]]]\n", + " print(\"\\n You explore the room. This is \" + room[\"name\"] + \". You find these objects: \\n- \" + \"\\n- \".join(items))\n", + "\n", + "def get_next_room_of_door(door, current_room):\n", + " \"\"\"\n", + " From object_relations, find the two rooms connected to the given door.\n", + " Return the room that is not the current_room.\n", + " \"\"\"\n", + " connected_rooms = object_relations[door[\"name\"]]\n", + " for room in connected_rooms:\n", + " if(not current_room == room):\n", + " return room\n", + "\n", + "def examine_item(item_name):\n", + " \"\"\"\n", + " Examine an item which can be a door or furniture.\n", + " First make sure the intended item belongs to the current room.\n", + " Then check if the item is a door. Tell player if key hasn't been \n", + " collected yet. Otherwise ask player if they want to go to the next\n", + " room. If the item is not a door, then check if it contains keys.\n", + " Collect the key if found and update the game state. At the end,\n", + " play either the current or the next room depending on the game state\n", + " to keep playing.\n", + " \"\"\"\n", + " current_room = game_state[\"current_room\"]\n", + " next_room = \"\"\n", + " output = None\n", + " \n", + " for item in object_relations[current_room[\"name\"]]:\n", + " if(item[\"name\"] == item_name):\n", + " output = \"\\n You examine \" + item_name + \". \"\n", + " if(item[\"type\"] == \"door\"):\n", + " have_key = False\n", + " for key in game_state[\"keys_collected\"]:\n", + " if(key[\"target\"] == item):\n", + " have_key = True\n", + " if(have_key):\n", + " output += \"You unlock it with a key you have.\"\n", + " next_room = get_next_room_of_door(item, current_room)\n", + " else:\n", + " output += \"It is locked but you don't have the key.\"\n", + " else:\n", + " if(item[\"name\"] in object_relations and len(object_relations[item[\"name\"]])>0):\n", + " item_found = object_relations[item[\"name\"]].pop()\n", + " game_state[\"keys_collected\"].append(item_found)\n", + " output += \"You find \" + item_found[\"name\"] + \".\"\n", + " else:\n", + " output += \"There isn't anything interesting about it.\"\n", + " \n", + "\n", + " print(output)\n", + " see_again= input((\"\"\"Do you wish to examine more things?\n", + " \n", + " Y: To examine more things\n", + " N: Stop examine\n", + " \n", + "\n", + " Please enter your choice: \"\"\"))\n", + " if see_again.upper() == 'Y':\n", + " examine_item(input(\" \\n What would you like to examine? \\n\").strip()) \n", + " elif see_again.upper() == 'N':\n", + " continue\n", + " else:\n", + " see_again\n", + " break\n", + "\n", + " if(output is None):\n", + " print(\"You must have eaten some Bertie Botts Beansb and are seeing things twisted. That item isn't in the current room.\")\n", + " \n", + " if(next_room and input(\"Do you wish to go to another Hogwards room? Write 'yes' to enter or write anything else to go to main menu.\").strip().lower() == 'yes'):\n", + " play_room(next_room)\n", + " else:\n", + " play_room(current_room)\n", + " \n", + "\n", + "game_state = INIT_GAME_STATE.copy()\n", + "\n", + "start_game()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f8f3672e", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3aa2594a", + "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.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/your-code/.ipynb_checkpoints/sample-code-checkpoint.ipynb b/your-code/.ipynb_checkpoints/sample-code-checkpoint.ipynb new file mode 100644 index 00000000..3dc4ab77 --- /dev/null +++ b/your-code/.ipynb_checkpoints/sample-code-checkpoint.ipynb @@ -0,0 +1,389 @@ +<<<<<<< HEAD +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "pygame 2.0.2 (SDL 2.0.16, Python 3.8.8)\n", + "Hello from the pygame community. https://www.pygame.org/contribute.html\n" + ] + } + ], + "source": [ + "#from pygame import mixer\n", + "from pygame import mixer\n", + "\n", + "\n", + "def linebreak():\n", + " \"\"\"\n", + " Print a line break\n", + " \"\"\"\n", + " print(\"\\n\\n\")\n", + "\n", + "def start_game():\n", + " \"\"\"\n", + " Start the game\n", + " \"\"\"\n", + " # Starting the mixer\n", + " mixer.init()\n", + "\n", + " # Loading the song\n", + " mixer.music.load(\"C:\\\\Users\\\\User\\Desktop\\\\IronHack\\\\python-project\\\\your-code\\\\harry.mp3\")\n", + "\n", + " # Setting the volume\n", + " mixer.music.set_volume(0.7)\n", + "\n", + " # Start playing the song\n", + " mixer.music.play()\n", + " \n", + " print(\"You wake up in Hogwards. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!\")\n", + " play_room(game_state[\"current_room\"])\n", + "\n", + "def play_room(room):\n", + " \"\"\"\n", + " Play a room. First check if the room being played is the target room.\n", + " If it is, the game will end with success. Otherwise, let player either \n", + " explore (list all items in this room) or examine an item found here.\n", + " \"\"\" \n", + " game_state[\"current_room\"] = room\n", + " if(game_state[\"current_room\"] == game_state[\"target_room\"]):\n", + " #stop the music when ends the game\n", + " mixer.music.pause()\n", + " print(\"Congrats! You are free from the spells\",)\n", + " else:\n", + " print(\"You are now in \" + room[\"name\"])\n", + " intended_action = input(\"What would you like to do? Type 'explore' or 'examine'?\").strip()\n", + " if intended_action == \"explore\":\n", + " explore_room(room)\n", + " play_room(room)\n", + " elif intended_action == \"examine\":\n", + " examine_item(input(\"What would you like to examine?\").strip())\n", + " else:\n", + " print(\"Not sure what you mean. Type 'explore' or 'examine'.\")\n", + " play_room(room)\n", + " linebreak()\n", + "\n", + "def explore_room(room):\n", + " \"\"\"\n", + " Explore a room. List all items belonging to this room.\n", + " \"\"\"\n", + " items = [i[\"name\"] for i in object_relations[room[\"name\"]]]\n", + " print(\"You explore the room. This is \" + room[\"name\"] + \". You find \" + \", \".join(items))\n", + "\n", + "def get_next_room_of_door(door, current_room):\n", + " \"\"\"\n", + " From object_relations, find the two rooms connected to the given door.\n", + " Return the room that is not the current_room.\n", + " \"\"\"\n", + " connected_rooms = object_relations[door[\"name\"]]\n", + " for room in connected_rooms:\n", + " if(not current_room == room):\n", + " return room\n", + "\n", + "def examine_item(item_name):\n", + " \"\"\"\n", + " Examine an item which can be a door or furniture.\n", + " First make sure the intended item belongs to the current room.\n", + " Then check if the item is a door. Tell player if key hasn't been \n", + " collected yet. Otherwise ask player if they want to go to the next\n", + " room. If the item is not a door, then check if it contains keys.\n", + " Collect the key if found and update the game state. At the end,\n", + " play either the current or the next room depending on the game state\n", + " to keep playing.\n", + " \"\"\"\n", + " current_room = game_state[\"current_room\"]\n", + " next_room = \"\"\n", + " output = None\n", + " \n", + " for item in object_relations[current_room[\"name\"]]:\n", + " if(item[\"name\"] == item_name):\n", + " output = \"You examine \" + item_name + \". \"\n", + " if(item[\"type\"] == \"door\"):\n", + " have_key = False\n", + " for key in game_state[\"keys_collected\"]:\n", + " if(key[\"target\"] == item):\n", + " have_key = True\n", + " if(have_key):\n", + " output += \"You unlock it with a key you have.\"\n", + " next_room = get_next_room_of_door(item, current_room)\n", + " else:\n", + " output += \"It is locked but you don't have the key.\"\n", + " else:\n", + " if(item[\"name\"] in object_relations and len(object_relations[item[\"name\"]])>0):\n", + " item_found = object_relations[item[\"name\"]].pop()\n", + " game_state[\"keys_collected\"].append(item_found)\n", + " output += \"You find \" + item_found[\"name\"] + \".\"\n", + " else:\n", + " output += \"There isn't anything interesting about it.\"\n", + " print(output)\n", + " break\n", + "\n", + " if(output is None):\n", + " print(\"The item you requested is not found in the current room.\")\n", + " \n", + " if(next_room and input(\"Do you want to go to the next room? Ener 'yes' or 'no'\").strip() == 'yes'):\n", + " play_room(next_room)\n", + " else:\n", + " play_room(current_room)\n", + " \n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "nundu_door = {\n", + " \"name\": \"nundu door\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "\n", + "fenix_door = {\n", + " \"name\": \"fenix door\",\n", + " \"type\": \"door\",\n", + "}\n", + "wand = {\n", + " \"name\": \"wand\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dumbledore = {\n", + " \"name\": \"dumbledore\",\n", + " \"type\": \"furniture\",\n", + "} \n", + " \n", + "\n", + "\n", + "snake_door = {\n", + " \"name\": \"snake door\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_snake= {\n", + " \"name\": \"key for snake door\",\n", + " \"type\": \"key\",\n", + " \"target\": snake_door,\n", + "}\n", + "\n", + "pensieve = {\n", + " \"name\": \"pensieve\",\n", + " \"type\": \"furniture\"\n", + "}\n", + "spell={\n", + " \"name\":\"\\n \\n Expectro patrono \\n \\n\",\n", + " \"type\": \"key\",\n", + " \"target\":pensieve\n", + " \n", + "}\n", + "\n", + "mirror_enrised = {\n", + " \"name\": \"mirror enrised\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "hogwarts = {\n", + " \"name\": \"hogwarts\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "#DEFINE BEDROOM1\n", + "\n", + "azkaban = {\n", + " \"name\": \"azkaban\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "dwarves_door = {\n", + " \"name\": \"dwarves door\",\n", + " \"type\": \"door\",\n", + "}\n", + "elfes_door = {\n", + " \"name\": \"elfes door\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "weasley_clock = {\n", + " \"name\": \"weasley clock\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "key_dwarves={\n", + " \"name\": \"key for dwarves door\",\n", + " \"type\": \"key\",\n", + " \"target\": dwarves_door\n", + "}\n", + "\n", + "\n", + "\n", + "#DEFINE BEDROOM2\n", + "\n", + "invisibility_cloak = {\n", + " \"name\": \"invisibility cloak\",\n", + " \"type\": \"furniture\"\n", + "}\n", + "\n", + "key_elfes = {\n", + " \"name\": \"key for elfes door\",\n", + " \"type\": \"key\",\n", + " \"target\": elfes_door,\n", + "}\n", + "\n", + "key_fenix = {\n", + " \"name\": \"key for fenix door\",\n", + " \"type\": \"key\",\n", + " \"target\": fenix_door\n", + "}\n", + "portkey = {\n", + " \"name\": \"portkey\",\n", + " \"type\": \"furniture\"\n", + "}\n", + "\n", + "diagon_alley = {\n", + " \"name\": \"diagon alley\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "key_nundu = {\n", + " \"name\": \"key for nundu door\",\n", + " \"type\": \"key\",\n", + " \"target\": nundu_door,\n", + "}\n", + "\n", + "# define LIVINGROOM\n", + "\n", + "\n", + "broonstick = {\n", + " \"name\": \"broonstick\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "\n", + "dumbledore_chamber = {\n", + " \"name\": \"dumbledore chamber\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "all_rooms = [hogwarts, azkaban, diagon_alley, dumbledore_chamber, outside]\n", + "\n", + "all_doors = [snake_door, dwarves_door, elfes_door, nundu_door, fenix_door]\n", + "\n", + "# define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"hogwarts\": [dumbledore,wand, mirror_enrised, snake_door],\n", + " \"mirror enrised\": [key_snake],\n", + " \"outside\": [snake_door],\n", + " \"snake door\": [hogwarts, azkaban],\n", + " #\"snake door\":[outside],\n", + " \"weasley clock\":[key_dwarves],\n", + " \"dwarves door\":[azkaban, diagon_alley],\n", + " \"elfes door\":[azkaban, dumbledore_chamber],\n", + " \"portkey\":[key_elfes],\n", + " \"pensieve\": [key_fenix, spell],\n", + " \"dinning table\":[dumbledore_chamber],\n", + " \"fenix door\":[dumbledore_chamber, outside],\n", + " \"azkaban\":[weasley_clock,snake_door, dwarves_door, elfes_door],\n", + " \"diagon alley\":[portkey, dwarves_door, nundu_door, invisibility_cloak],\n", + " \"dumbledore chamber\":[broonstick, elfes_door, fenix_door, pensieve],\n", + " \"invisibility cloak\":[key_nundu],\n", + " \"nundu door\":[diagon_alley, hogwarts],\n", + " \"dumbledore\":[spell,]\n", + "}\n", + " \n", + "\n", + "\n", + "\n", + "# define game state. Do not directly change this dict. \n", + "# Instead, when a new game starts, make a copy of this\n", + "# dict and use the copy to store gameplay state. This \n", + "# way you can replay the game multiple times.\n", + "\n", + "INIT_GAME_STATE = {\n", + " \"current_room\": hogwarts,\n", + " \"keys_collected\": [],\n", + " \"target_room\": outside,\n", + "\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You wake up in Hogwards. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!\n", + "You are now in hogwarts\n" + ] + } + ], + "source": [ + "game_state = INIT_GAME_STATE.copy()\n", + "\n", + "start_game()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "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.8" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} +======= +>>>>>>> master diff --git a/your-code/.ipynb_checkpoints/sample-code1.1-checkpoint.ipynb b/your-code/.ipynb_checkpoints/sample-code1.1-checkpoint.ipynb new file mode 100644 index 00000000..08f05da8 --- /dev/null +++ b/your-code/.ipynb_checkpoints/sample-code1.1-checkpoint.ipynb @@ -0,0 +1,227 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "# define rooms and items\n", + "\n", + "couch = {\n", + " \"name\": \"couch\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "door_a = {\n", + " \"name\": \"door a\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_a = {\n", + " \"name\": \"key for door a\",\n", + " \"type\": \"key\",\n", + " \"target\": door_a,\n", + "}\n", + "\n", + "piano = {\n", + " \"name\": \"piano\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "game_room = {\n", + " \"name\": \"game room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "all_rooms = [game_room, outside]\n", + "\n", + "all_doors = [door_a]\n", + "\n", + "# define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"game room\": [couch, piano, door_a],\n", + " \"piano\": [key_a],\n", + " \"outside\": [door_a],\n", + " \"door a\": [game_room, outside]\n", + "}\n", + "\n", + "# define game state. Do not directly change this dict. \n", + "# Instead, when a new game starts, make a copy of this\n", + "# dict and use the copy to store gameplay state. This \n", + "# way you can replay the game multiple times.\n", + "\n", + "INIT_GAME_STATE = {\n", + " \"current_room\": game_room,\n", + " \"keys_collected\": [],\n", + " \"target_room\": outside\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "def linebreak():\n", + " \"\"\"\n", + " Print a line break\n", + " \"\"\"\n", + " print(\"\\n\\n\")\n", + "\n", + "def start_game():\n", + " \"\"\"\n", + " Start the game\n", + " \"\"\"\n", + " print(\"You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!\")\n", + " play_room(game_state[\"current_room\"])\n", + "\n", + "def play_room(room):\n", + " \"\"\"\n", + " Play a room. First check if the room being played is the target room.\n", + " If it is, the game will end with success. Otherwise, let player either \n", + " explore (list all items in this room) or examine an item found here.\n", + " \"\"\"\n", + " game_state[\"current_room\"] = room\n", + " if(game_state[\"current_room\"] == game_state[\"target_room\"]):\n", + " print(\"Congrats! You escaped the room!\")\n", + " else:\n", + " print(\"You are now in \" + room[\"name\"])\n", + " intended_action = input(\"What would you like to do? Type 'explore' or 'examine'?\").strip()\n", + " if intended_action == \"explore\":\n", + " explore_room(room)\n", + " play_room(room)\n", + " elif intended_action == \"examine\":\n", + " examine_item(input(\"What would you like to examine?\").strip())\n", + " else:\n", + " print(\"Not sure what you mean. Type 'explore' or 'examine'.\")\n", + " play_room(room)\n", + " linebreak()\n", + "\n", + "def explore_room(room):\n", + " \"\"\"\n", + " Explore a room. List all items belonging to this room.\n", + " \"\"\"\n", + " items = [i[\"name\"] for i in object_relations[room[\"name\"]]]\n", + " print(\"You explore the room. This is \" + room[\"name\"] + \". You find \" + \", \".join(items))\n", + "\n", + "def get_next_room_of_door(door, current_room):\n", + " \"\"\"\n", + " From object_relations, find the two rooms connected to the given door.\n", + " Return the room that is not the current_room.\n", + " \"\"\"\n", + " connected_rooms = object_relations[door[\"name\"]]\n", + " for room in connected_rooms:\n", + " if(not current_room == room):\n", + " return room\n", + "\n", + "def examine_item(item_name):\n", + " \"\"\"\n", + " Examine an item which can be a door or furniture.\n", + " First make sure the intended item belongs to the current room.\n", + " Then check if the item is a door. Tell player if key hasn't been \n", + " collected yet. Otherwise ask player if they want to go to the next\n", + " room. If the item is not a door, then check if it contains keys.\n", + " Collect the key if found and update the game state. At the end,\n", + " play either the current or the next room depending on the game state\n", + " to keep playing.\n", + " \"\"\"\n", + " current_room = game_state[\"current_room\"]\n", + " next_room = \"\"\n", + " output = None\n", + " \n", + " for item in object_relations[current_room[\"name\"]]:\n", + " if(item[\"name\"] == item_name):\n", + " output = \"You examine \" + item_name + \". \"\n", + " if(item[\"type\"] == \"door\"):\n", + " have_key = False\n", + " for key in game_state[\"keys_collected\"]:\n", + " if(key[\"target\"] == item):\n", + " have_key = True\n", + " if(have_key):\n", + " output += \"You unlock it with a key you have.\"\n", + " next_room = get_next_room_of_door(item, current_room)\n", + " else:\n", + " output += \"It is locked but you don't have the key.\"\n", + " else:\n", + " if(item[\"name\"] in object_relations and len(object_relations[item[\"name\"]])>0):\n", + " item_found = object_relations[item[\"name\"]].pop()\n", + " game_state[\"keys_collected\"].append(item_found)\n", + " output += \"You find \" + item_found[\"name\"] + \".\"\n", + " else:\n", + " output += \"There isn't anything interesting about it.\"\n", + " print(output)\n", + " break\n", + "\n", + " if(output is None):\n", + " print(\"The item you requested is not found in the current room.\")\n", + " \n", + " if(next_room and input(\"Do you want to go to the next room? Ener 'yes' or 'no'\").strip() == 'yes'):\n", + " play_room(next_room)\n", + " else:\n", + " play_room(current_room)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!\n", + "You are now in game room\n", + "What would you like to do? Type 'explore' or 'examine'?explore\n", + "You explore the room. This is game room. You find couch, piano, door a\n", + "You are now in game room\n", + "What would you like to do? Type 'explore' or 'examine'?explore\n", + "You explore the room. This is game room. You find couch, piano, door a\n", + "You are now in game room\n", + "What would you like to do? Type 'explore' or 'examine'?examine\n" + ] + } + ], + "source": [ + "game_state = INIT_GAME_STATE.copy()\n", + "\n", + "start_game()" + ] + }, + { + "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.8" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/your-code/harry.mp3 b/your-code/harry.mp3 new file mode 100644 index 00000000..eede7408 Binary files /dev/null and b/your-code/harry.mp3 differ diff --git a/your-code/menu testing.ipynb b/your-code/menu testing.ipynb new file mode 100644 index 00000000..2a24247b --- /dev/null +++ b/your-code/menu testing.ipynb @@ -0,0 +1,443 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "001a0c8c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " ************Welcome to Hogwards Escape Room*************\n", + " \n", + " Welcome to our new Hogwarts Escape Room! Before we begin our journey, we would like to say a few words...\n", + " \n", + " Choose wisely your paths and remember your spells... \n", + " \n", + "\n", + " Let's proceed! You are now in: game room\n", + "Choose one of these options:\n", + " \n", + " A: Explore what's in the room\n", + " B: Examine what you want to\n", + " \n", + "\n", + " Please enter your choice: a\n", + "\n", + " You explore the room. This is game room. You find these objects: \n", + "- couch\n", + "- piano\n", + "- door a\n", + "\n", + " Let's proceed! You are now in: game room\n", + "Choose one of these options:\n", + " \n", + " A: Explore what's in the room\n", + " B: Examine what you want to\n", + " \n", + "\n", + " Please enter your choice: couch\n", + "\n", + " That is a muggle error! You must only type either A or B.\n", + "\n", + " Let's proceed! You are now in: game room\n", + "Choose one of these options:\n", + " \n", + " A: Explore what's in the room\n", + " B: Examine what you want to\n", + " \n", + "\n", + " Please enter your choice: b\n", + " \n", + " What would you like to examine? \n", + "piano\n", + "\n", + " You examine piano. You find key for door a.\n" + ] + }, + { + "ename": "KeyboardInterrupt", + "evalue": "Interrupted by user", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 320\u001b[0m \u001b[0mgame_state\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mINIT_GAME_STATE\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcopy\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 321\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 322\u001b[1;33m \u001b[0mstart_game\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;32m\u001b[0m in \u001b[0;36mstart_game\u001b[1;34m()\u001b[0m\n\u001b[0;32m 205\u001b[0m \u001b[0mChoose\u001b[0m \u001b[0mwisely\u001b[0m \u001b[0myour\u001b[0m \u001b[0mpaths\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mremember\u001b[0m \u001b[0myour\u001b[0m \u001b[0mspells\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 206\u001b[0m \"\"\")\n\u001b[1;32m--> 207\u001b[1;33m \u001b[0mplay_room\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mgame_state\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"current_room\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 208\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 209\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mplay_room\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mroom\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m\u001b[0m in \u001b[0;36mplay_room\u001b[1;34m(room)\u001b[0m\n\u001b[0;32m 231\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mchoice\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mupper\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m\"A\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 232\u001b[0m \u001b[0mexplore_room\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mroom\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 233\u001b[1;33m \u001b[0mplay_room\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mroom\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 234\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mchoice\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mupper\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m\"B\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 235\u001b[0m \u001b[0mexamine_item\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\" \\n What would you like to examine? \\n\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstrip\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m\u001b[0m in \u001b[0;36mplay_room\u001b[1;34m(room)\u001b[0m\n\u001b[0;32m 236\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 237\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"\\n That is a muggle error! You must only type either A or B.\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 238\u001b[1;33m \u001b[0mplay_room\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mroom\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 239\u001b[0m \u001b[0mlinebreak\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 240\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m\u001b[0m in \u001b[0;36mplay_room\u001b[1;34m(room)\u001b[0m\n\u001b[0;32m 233\u001b[0m \u001b[0mplay_room\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mroom\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 234\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mchoice\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mupper\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m\"B\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 235\u001b[1;33m \u001b[0mexamine_item\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\" \\n What would you like to examine? \\n\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstrip\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 236\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 237\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"\\n That is a muggle error! You must only type either A or B.\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m\u001b[0m in \u001b[0;36mexamine_item\u001b[1;34m(item_name)\u001b[0m\n\u001b[0;32m 294\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 295\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0moutput\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 296\u001b[1;33m see_again= input((\"\"\"Do you wish to examine more things?\n\u001b[0m\u001b[0;32m 297\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 298\u001b[0m \u001b[0mY\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mTo\u001b[0m \u001b[0mexamine\u001b[0m \u001b[0mmore\u001b[0m \u001b[0mthings\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\ipykernel\\kernelbase.py\u001b[0m in \u001b[0;36mraw_input\u001b[1;34m(self, prompt)\u001b[0m\n\u001b[0;32m 858\u001b[0m \u001b[1;34m\"raw_input was called, but this frontend does not support input requests.\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 859\u001b[0m )\n\u001b[1;32m--> 860\u001b[1;33m return self._input_request(str(prompt),\n\u001b[0m\u001b[0;32m 861\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent_ident\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 862\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent_header\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\ipykernel\\kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[1;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[0;32m 902\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 903\u001b[0m \u001b[1;31m# re-raise KeyboardInterrupt, to truncate traceback\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 904\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Interrupted by user\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 905\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 906\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwarning\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Invalid Message:\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mexc_info\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mKeyboardInterrupt\u001b[0m: Interrupted by user" + ] + } + ], + "source": [ + "\n", + "import csv\n", + "import sys\n", + "\n", + "# def main():\n", + "# menu()\n", + "\n", + "\n", + "# def menu():\n", + " \n", + " \n", + "# # global choice\n", + "# choice = input(\"\"\" ************Welcome to Hogwards Escape Room*************\n", + " \n", + "# To start choose one of these options:\n", + " \n", + "# A: Explore what's in the room\n", + "# B: Examine what you want to\n", + " \n", + "\n", + "# Please enter your choice: \"\"\")\n", + "\n", + "# if choice.upper() == \"A\" :\n", + " \n", + " \n", + "# elif choice.upper() == \"B\" :\n", + "# print('you are now in chamber B ')\n", + " \n", + "# else:\n", + "# print(\"\\n You must only select either A or B\")\n", + "# print(\"\\n That is a muggle error, read carefully again! \\n\")\n", + "# menu()\n", + " \n", + "# main() \n", + " \n", + "#the program is initiated, so to speak, here\n", + "#main()\n", + "\n", + "door_d = {\n", + " \"name\": \"door d\",\n", + " \"type\": \"door\",\n", + "}\n", + "couch = {\n", + " \"name\": \"couch\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "door_a = {\n", + " \"name\": \"door a\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_a = {\n", + " \"name\": \"key for door a\",\n", + " \"type\": \"key\",\n", + " \"target\": door_a,\n", + "}\n", + "\n", + "piano = {\n", + " \"name\": \"piano\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "game_room = {\n", + " \"name\": \"game room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "#DEFINE BEDROOM1\n", + "\n", + "bedroom_1 = {\n", + " \"name\": \"bedroom 1\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "door_b = {\n", + " \"name\": \"door b\",\n", + " \"type\": \"door\",\n", + "}\n", + "door_c = {\n", + " \"name\": \"door c\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "queen_bed = {\n", + " \"name\": \"queen bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "key_b={\n", + " \"name\": \"key for door b\",\n", + " \"type\": \"key\",\n", + " \"target\": door_b\n", + "}\n", + "\n", + "\n", + "\n", + "#DEFINE BEDROOM2\n", + "\n", + "key_c = {\n", + " \"name\": \"key for door c\",\n", + " \"type\": \"key\",\n", + " \"target\": door_c,\n", + "}\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d\n", + "}\n", + "double_bed = {\n", + " \"name\": \"double bed\",\n", + " \"type\": \"furniture\"\n", + "}\n", + "dresser = {\n", + " \"name\": \"dresser\",\n", + " \"type\": \"furniture\"\n", + "}\n", + "bedroom_2 = {\n", + " \"name\": \"bedroom 2\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "\n", + "\n", + "# Define LIVINGROOM\n", + "\n", + "\n", + "dining_table = {\n", + " \"name\": \"dining table\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "\n", + "\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d\n", + "}\n", + "\n", + "\n", + "living_room = {\n", + " \"name\": \"living room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "all_rooms = [game_room, bedroom_1, bedroom_2, living_room, outside]\n", + "\n", + "all_doors = [door_a, door_b, door_c, door_c]\n", + "\n", + "# Define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"game room\": [couch, piano, door_a],\n", + " \"piano\": [key_a],\n", + " \"outside\": [door_a],\n", + " \"door a\": [game_room, bedroom_1],\n", + " \"queen bed\":[key_b],\n", + " \"door b\":[bedroom_1, bedroom_2],\n", + " \"door c\":[bedroom_1, living_room],\n", + " \"double bed\":[key_c],\n", + " \"dresser\": [key_d],\n", + " \"dinning table\":[living_room],\n", + " \"door d\":[living_room, outside],\n", + " \"bedroom 1\":[queen_bed,door_a,door_b,door_c],\n", + " \"bedroom 2\":[double_bed,door_c,door_d,dresser,door_b],\n", + " \"living room\":[dining_table, door_c, door_d]\n", + " \n", + "}\n", + " \n", + "\n", + "\n", + "\n", + "# define game state. Do not directly change this dict. \n", + "# Instead, when a new game starts, make a copy of this\n", + "# dict and use the copy to store gameplay state. This \n", + "# way you can replay the game multiple times.\n", + "\n", + "INIT_GAME_STATE = {\n", + " \"current_room\": game_room,\n", + " \"keys_collected\": [],\n", + " \"target_room\": outside\n", + "}\n", + "\n", + "def linebreak():\n", + " \"\"\"\n", + " Print a line break\n", + " \"\"\"\n", + " print(\"\\n\\n\")\n", + "\n", + "def start_game():\n", + " \"\"\"\n", + " Start the game\n", + " \"\"\"\n", + " print(\"\"\" ************Welcome to Hogwards Escape Room*************\n", + " \n", + " Welcome to our new Hogwarts Escape Room! Before we begin our journey, we would like to say a few words...\n", + " \n", + " Choose wisely your paths and remember your spells... \n", + " \"\"\")\n", + " play_room(game_state[\"current_room\"])\n", + "\n", + "def play_room(room):\n", + " \"\"\"\n", + " Play a room. First check if the room being played is the target room.\n", + " If it is, the game will end with success. Otherwise, let player either \n", + " explore (list all items in this room) or examine an item found here.\n", + " \"\"\"\n", + " game_state[\"current_room\"] = room\n", + " if(game_state[\"current_room\"] == game_state[\"target_room\"]):\n", + " print(\"Congrats! You escaped the room!\")\n", + " else:\n", + "# if room[\"name\"] == game_state[\"current_room\"]: \n", + "# print(\"\\n You are still in: \" + room[\"name\"])\n", + "# else:\n", + " print(\"\\n Let's proceed! You are now in: \" + room[\"name\"])\n", + " #intended_action = input(\"What would you like to do? Type 'explore' or 'examine'?\").strip()\n", + " choice = input(\"\"\"Choose one of these options:\n", + " \n", + " A: Explore what's in the room\n", + " B: Examine what you want to\n", + " \n", + "\n", + " Please enter your choice: \"\"\")\n", + " if choice.upper() == \"A\":\n", + " explore_room(room)\n", + " play_room(room)\n", + " elif choice.upper() == \"B\":\n", + " examine_item(input(\" \\n What would you like to examine? \\n\").strip())\n", + " else:\n", + " print(\"\\n That is a muggle error! You must only type either A or B.\")\n", + " play_room(room)\n", + " linebreak()\n", + "\n", + "def explore_room(room):\n", + " \"\"\"\n", + " Explore a room. List all items belonging to this room.\n", + " \"\"\"\n", + " items = [i[\"name\"] for i in object_relations[room[\"name\"]]]\n", + " print(\"\\n You explore the room. This is \" + room[\"name\"] + \". You find these objects: \\n- \" + \"\\n- \".join(items))\n", + "\n", + "def get_next_room_of_door(door, current_room):\n", + " \"\"\"\n", + " From object_relations, find the two rooms connected to the given door.\n", + " Return the room that is not the current_room.\n", + " \"\"\"\n", + " connected_rooms = object_relations[door[\"name\"]]\n", + " for room in connected_rooms:\n", + " if(not current_room == room):\n", + " return room\n", + "\n", + "def examine_item(item_name):\n", + " \"\"\"\n", + " Examine an item which can be a door or furniture.\n", + " First make sure the intended item belongs to the current room.\n", + " Then check if the item is a door. Tell player if key hasn't been \n", + " collected yet. Otherwise ask player if they want to go to the next\n", + " room. If the item is not a door, then check if it contains keys.\n", + " Collect the key if found and update the game state. At the end,\n", + " play either the current or the next room depending on the game state\n", + " to keep playing.\n", + " \"\"\"\n", + " current_room = game_state[\"current_room\"]\n", + " next_room = \"\"\n", + " output = None\n", + " \n", + " for item in object_relations[current_room[\"name\"]]:\n", + " if(item[\"name\"] == item_name):\n", + " output = \"\\n You examine \" + item_name + \". \"\n", + " if(item[\"type\"] == \"door\"):\n", + " have_key = False\n", + " for key in game_state[\"keys_collected\"]:\n", + " if(key[\"target\"] == item):\n", + " have_key = True\n", + " if(have_key):\n", + " output += \"You unlock it with a key you have.\"\n", + " next_room = get_next_room_of_door(item, current_room)\n", + " else:\n", + " output += \"It is locked but you don't have the key.\"\n", + " else:\n", + " if(item[\"name\"] in object_relations and len(object_relations[item[\"name\"]])>0):\n", + " item_found = object_relations[item[\"name\"]].pop()\n", + " game_state[\"keys_collected\"].append(item_found)\n", + " output += \"You find \" + item_found[\"name\"] + \".\"\n", + " else:\n", + " output += \"There isn't anything interesting about it.\"\n", + " \n", + "\n", + " print(output)\n", + " see_again= input((\"\"\"Do you wish to examine more things?\n", + " \n", + " Y: To examine more things\n", + " N: Stop examine\n", + " \n", + "\n", + " Please enter your choice: \"\"\"))\n", + " if see_again.upper() == 'Y':\n", + " examine_item(input(\" \\n What would you like to examine? \\n\").strip()) \n", + " elif see_again.upper() == 'N':\n", + " continue\n", + " else:\n", + " see_again\n", + " break\n", + "\n", + " if(output is None):\n", + " print(\"You must have eaten some Bertie Botts Beansb and are seeing things twisted. That item isn't in the current room.\")\n", + " \n", + " if(next_room and input(\"Do you wish to go to another Hogwards room? Write 'yes' to enter or write anything else to go to main menu.\").strip().lower() == 'yes'):\n", + " play_room(next_room)\n", + " else:\n", + " play_room(current_room)\n", + " \n", + "\n", + "game_state = INIT_GAME_STATE.copy()\n", + "\n", + "start_game()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f8f3672e", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3aa2594a", + "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.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/your-code/sample-code.ipynb b/your-code/sample-code.ipynb index a6f8a94d..3dc4ab77 100644 --- a/your-code/sample-code.ipynb +++ b/your-code/sample-code.ipynb @@ -1,74 +1,25 @@ +<<<<<<< HEAD { "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "pygame 2.0.2 (SDL 2.0.16, Python 3.8.8)\n", + "Hello from the pygame community. https://www.pygame.org/contribute.html\n" + ] + } + ], "source": [ - "# define rooms and items\n", - "\n", - "couch = {\n", - " \"name\": \"couch\",\n", - " \"type\": \"furniture\",\n", - "}\n", - "\n", - "door_a = {\n", - " \"name\": \"door a\",\n", - " \"type\": \"door\",\n", - "}\n", - "\n", - "key_a = {\n", - " \"name\": \"key for door a\",\n", - " \"type\": \"key\",\n", - " \"target\": door_a,\n", - "}\n", - "\n", - "piano = {\n", - " \"name\": \"piano\",\n", - " \"type\": \"furniture\",\n", - "}\n", - "\n", - "game_room = {\n", - " \"name\": \"game room\",\n", - " \"type\": \"room\",\n", - "}\n", - "\n", - "outside = {\n", - " \"name\": \"outside\"\n", - "}\n", - "\n", - "all_rooms = [game_room, outside]\n", - "\n", - "all_doors = [door_a]\n", - "\n", - "# define which items/rooms are related\n", - "\n", - "object_relations = {\n", - " \"game room\": [couch, piano, door_a],\n", - " \"piano\": [key_a],\n", - " \"outside\": [door_a],\n", - " \"door a\": [game_room, outside]\n", - "}\n", + "#from pygame import mixer\n", + "from pygame import mixer\n", "\n", - "# define game state. Do not directly change this dict. \n", - "# Instead, when a new game starts, make a copy of this\n", - "# dict and use the copy to store gameplay state. This \n", - "# way you can replay the game multiple times.\n", "\n", - "INIT_GAME_STATE = {\n", - " \"current_room\": game_room,\n", - " \"keys_collected\": [],\n", - " \"target_room\": outside\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ "def linebreak():\n", " \"\"\"\n", " Print a line break\n", @@ -79,7 +30,19 @@ " \"\"\"\n", " Start the game\n", " \"\"\"\n", - " print(\"You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!\")\n", + " # Starting the mixer\n", + " mixer.init()\n", + "\n", + " # Loading the song\n", + " mixer.music.load(\"C:\\\\Users\\\\User\\Desktop\\\\IronHack\\\\python-project\\\\your-code\\\\harry.mp3\")\n", + "\n", + " # Setting the volume\n", + " mixer.music.set_volume(0.7)\n", + "\n", + " # Start playing the song\n", + " mixer.music.play()\n", + " \n", + " print(\"You wake up in Hogwards. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!\")\n", " play_room(game_state[\"current_room\"])\n", "\n", "def play_room(room):\n", @@ -87,10 +50,12 @@ " Play a room. First check if the room being played is the target room.\n", " If it is, the game will end with success. Otherwise, let player either \n", " explore (list all items in this room) or examine an item found here.\n", - " \"\"\"\n", + " \"\"\" \n", " game_state[\"current_room\"] = room\n", " if(game_state[\"current_room\"] == game_state[\"target_room\"]):\n", - " print(\"Congrats! You escaped the room!\")\n", + " #stop the music when ends the game\n", + " mixer.music.pause()\n", + " print(\"Congrats! You are free from the spells\",)\n", " else:\n", " print(\"You are now in \" + room[\"name\"])\n", " intended_action = input(\"What would you like to do? Type 'explore' or 'examine'?\").strip()\n", @@ -165,48 +130,208 @@ " if(next_room and input(\"Do you want to go to the next room? Ener 'yes' or 'no'\").strip() == 'yes'):\n", " play_room(next_room)\n", " else:\n", - " play_room(current_room)" + " play_room(current_room)\n", + " \n" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "nundu_door = {\n", + " \"name\": \"nundu door\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "\n", + "fenix_door = {\n", + " \"name\": \"fenix door\",\n", + " \"type\": \"door\",\n", + "}\n", + "wand = {\n", + " \"name\": \"wand\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dumbledore = {\n", + " \"name\": \"dumbledore\",\n", + " \"type\": \"furniture\",\n", + "} \n", + " \n", + "\n", + "\n", + "snake_door = {\n", + " \"name\": \"snake door\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "key_snake= {\n", + " \"name\": \"key for snake door\",\n", + " \"type\": \"key\",\n", + " \"target\": snake_door,\n", + "}\n", + "\n", + "pensieve = {\n", + " \"name\": \"pensieve\",\n", + " \"type\": \"furniture\"\n", + "}\n", + "spell={\n", + " \"name\":\"\\n \\n Expectro patrono \\n \\n\",\n", + " \"type\": \"key\",\n", + " \"target\":pensieve\n", + " \n", + "}\n", + "\n", + "mirror_enrised = {\n", + " \"name\": \"mirror enrised\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "hogwarts = {\n", + " \"name\": \"hogwarts\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "#DEFINE BEDROOM1\n", + "\n", + "azkaban = {\n", + " \"name\": \"azkaban\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "dwarves_door = {\n", + " \"name\": \"dwarves door\",\n", + " \"type\": \"door\",\n", + "}\n", + "elfes_door = {\n", + " \"name\": \"elfes door\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "weasley_clock = {\n", + " \"name\": \"weasley clock\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "key_dwarves={\n", + " \"name\": \"key for dwarves door\",\n", + " \"type\": \"key\",\n", + " \"target\": dwarves_door\n", + "}\n", + "\n", + "\n", + "\n", + "#DEFINE BEDROOM2\n", + "\n", + "invisibility_cloak = {\n", + " \"name\": \"invisibility cloak\",\n", + " \"type\": \"furniture\"\n", + "}\n", + "\n", + "key_elfes = {\n", + " \"name\": \"key for elfes door\",\n", + " \"type\": \"key\",\n", + " \"target\": elfes_door,\n", + "}\n", + "\n", + "key_fenix = {\n", + " \"name\": \"key for fenix door\",\n", + " \"type\": \"key\",\n", + " \"target\": fenix_door\n", + "}\n", + "portkey = {\n", + " \"name\": \"portkey\",\n", + " \"type\": \"furniture\"\n", + "}\n", + "\n", + "diagon_alley = {\n", + " \"name\": \"diagon alley\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "key_nundu = {\n", + " \"name\": \"key for nundu door\",\n", + " \"type\": \"key\",\n", + " \"target\": nundu_door,\n", + "}\n", + "\n", + "# define LIVINGROOM\n", + "\n", + "\n", + "broonstick = {\n", + " \"name\": \"broonstick\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "\n", + "dumbledore_chamber = {\n", + " \"name\": \"dumbledore chamber\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "outside = {\n", + " \"name\": \"outside\"\n", + "}\n", + "\n", + "all_rooms = [hogwarts, azkaban, diagon_alley, dumbledore_chamber, outside]\n", + "\n", + "all_doors = [snake_door, dwarves_door, elfes_door, nundu_door, fenix_door]\n", + "\n", + "# define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"hogwarts\": [dumbledore,wand, mirror_enrised, snake_door],\n", + " \"mirror enrised\": [key_snake],\n", + " \"outside\": [snake_door],\n", + " \"snake door\": [hogwarts, azkaban],\n", + " #\"snake door\":[outside],\n", + " \"weasley clock\":[key_dwarves],\n", + " \"dwarves door\":[azkaban, diagon_alley],\n", + " \"elfes door\":[azkaban, dumbledore_chamber],\n", + " \"portkey\":[key_elfes],\n", + " \"pensieve\": [key_fenix, spell],\n", + " \"dinning table\":[dumbledore_chamber],\n", + " \"fenix door\":[dumbledore_chamber, outside],\n", + " \"azkaban\":[weasley_clock,snake_door, dwarves_door, elfes_door],\n", + " \"diagon alley\":[portkey, dwarves_door, nundu_door, invisibility_cloak],\n", + " \"dumbledore chamber\":[broonstick, elfes_door, fenix_door, pensieve],\n", + " \"invisibility cloak\":[key_nundu],\n", + " \"nundu door\":[diagon_alley, hogwarts],\n", + " \"dumbledore\":[spell,]\n", + "}\n", + " \n", + "\n", + "\n", + "\n", + "# define game state. Do not directly change this dict. \n", + "# Instead, when a new game starts, make a copy of this\n", + "# dict and use the copy to store gameplay state. This \n", + "# way you can replay the game multiple times.\n", + "\n", + "INIT_GAME_STATE = {\n", + " \"current_room\": hogwarts,\n", + " \"keys_collected\": [],\n", + " \"target_room\": outside,\n", + "\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!\n", - "You are now in game room\n", - "What would you like to do? Type 'explore' or 'examine'?explore\n", - "You explore the room. This is game room. You find couch, piano, door a\n", - "You are now in game room\n", - "What would you like to do? Type 'explore' or 'examine'?examine\n", - "What would you like to examine?door a\n", - "You examine door a. It is locked but you don't have the key.\n", - "You are now in game room\n", - "What would you like to do? Type 'explore' or 'examine'?examine\n", - "What would you like to examine?piano\n", - "You examine piano. You find key for door a.\n", - "You are now in game room\n", - "What would you like to do? Type 'explore' or 'examine'?examine\n", - "What would you like to examine?door a\n", - "You examine door a. You unlock it with a key you have.\n", - "Do you want to go to the next room? Ener 'yes' or 'no'yes\n", - "Congrats! You escaped the room!\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n" + "You wake up in Hogwards. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!\n", + "You are now in hogwarts\n" ] } ], @@ -216,6 +341,20 @@ "start_game()" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -240,9 +379,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.8.8" } }, "nbformat": 4, "nbformat_minor": 2 } +======= +>>>>>>> master diff --git a/your-code/sample-code.py b/your-code/sample-code.py new file mode 100644 index 00000000..a4550372 --- /dev/null +++ b/your-code/sample-code.py @@ -0,0 +1,376 @@ + + + +#from pygame import mixer +from pygame import mixer + +nundu_door = { + "name": "nundu door", + "type": "door", +} + + +fenix_door = { + "name": "fenix door", + "type": "door", +} +wand = { + "name": "wand", + "type": "furniture", +} + +dumbledore = { + "name": "dumbledore", + "type": "furniture", +} + + + +snake_door = { + "name": "snake door", + "type": "door", +} + +key_snake= { + "name": "key for snake door", + "type": "key", + "target": snake_door, +} + +pensieve = { + "name": "pensieve", + "type": "furniture" +} +spell={ + "name":"\n \n Expectro patrono \n \n", + "type": "key", + "target":pensieve + +} + +mirror_enrised = { + "name": "mirror enrised", + "type": "furniture", +} + +hogwarts = { + "name": "hogwarts", + "type": "room", +} + +outside = { + "name": "outside" +} + +#DEFINE BEDROOM1 + +azkaban = { + "name": "azkaban", + "type": "room", +} + +dwarves_door = { + "name": "dwarves door", + "type": "door", +} +elfes_door = { + "name": "elfes door", + "type": "door", +} + +weasley_clock = { + "name": "weasley clock", + "type": "furniture", +} +key_dwarves={ + "name": "key for dwarves door", + "type": "key", + "target": dwarves_door +} + + + +#DEFINE BEDROOM2 + +invisibility_cloak = { + "name": "invisibility cloak", + "type": "furniture" +} + +key_elfes = { + "name": "key for elfes door", + "type": "key", + "target": elfes_door, +} + +key_fenix = { + "name": "key for fenix door", + "type": "key", + "target": fenix_door +} +portkey = { + "name": "portkey", + "type": "furniture" +} + +diagon_alley = { + "name": "diagon alley", + "type": "room", +} + +key_nundu = { + "name": "key for nundu door", + "type": "key", + "target": nundu_door, +} + +# define LIVINGROOM + + +broonstick = { + "name": "broonstick", + "type": "furniture", +} + + +dumbledore_chamber = { + "name": "dumbledore chamber", + "type": "room", +} + +outside = { + "name": "outside" +} + +all_rooms = [hogwarts, azkaban, diagon_alley, dumbledore_chamber, outside] + +all_doors = [snake_door, dwarves_door, elfes_door, nundu_door, fenix_door] + +# define which items/rooms are related + +object_relations = { + "hogwarts": [dumbledore,wand, mirror_enrised, snake_door], + "mirror enrised": [key_snake], + "outside": [fenix_door], + # "snake door": [hogwarts, azkaban], + "snake door":[dumbledore_chamber], + "weasley clock":[key_dwarves], + "dwarves door":[azkaban, diagon_alley], + "elfes door":[azkaban, dumbledore_chamber], + "portkey":[key_elfes], + "pensieve": [key_fenix],#, spell], + "dinning table":[dumbledore_chamber], + "fenix door":[dumbledore_chamber, outside], + "azkaban":[weasley_clock,snake_door, dwarves_door, elfes_door], + "diagon alley":[portkey, dwarves_door, nundu_door, invisibility_cloak], + "dumbledore chamber":[broonstick, elfes_door, fenix_door, pensieve], + "invisibility cloak":[key_nundu], + "nundu door":[diagon_alley, hogwarts], + "dumbledore":[spell,] +} + + + + +# define game state. Do not directly change this dict. +# Instead, when a new game starts, make a copy of this +# dict and use the copy to store gameplay state. This +# way you can replay the game multiple times. + +INIT_GAME_STATE = { + "current_room": hogwarts, + "keys_collected": [], + "target_room": outside, + +} + +def linebreak(): + """ + Print a line break + """ + print("\n\n") + +def start_game(): + """ + Start the game + """ + + # Starting the mixer + mixer.init() + + # Loading the song + mixer.music.load("C:\\Users\\User\\Desktop\\IronHack\\python-project\\your-code\\harry.mp3") + + # Setting the volume + mixer.music.set_volume(0.7) + + # Start playing the song + mixer.music.play() + + print(""" ************Welcome to Hogwards Escape Room************* + + Welcome to our new Hogwarts Escape Room! Before we begin our journey, we would like to say a few words... + + Choose wisely your paths and remember your spells... + """) + + play_room(game_state["current_room"]) + +def quiz(): + print('A dementor is coming!!!!!') + spell_question = '' + if spell in game_state["keys_collected"]: + while spell_question.strip().lower() != 'expecto patrono': + spell_question = input('What is the spell to fight a dementor?') + mixer.music.pause() + print('the dementor is gone!!') + input() + play_room(outside) + return outside + else: + print("you don't know how to fight the dementor and you fled") + input() + play_room(hogwarts) + +def play_room(room): + """ + Play a room. First check if the room being played is the target room. + If it is, the game will end with success. Otherwise, let player either + explore (list all items in this room) or examine an item found here.""" + + game_state["current_room"] = room + if(game_state["current_room"] == game_state["target_room"]): + #mixer.music.pause() + print("Congrats! You escaped the room!") + exit() + else: +# if room["name"] == game_state["current_room"]: +# print("\n You are still in: " + room["name"]) +# else: + print("\n Let's proceed! You are now in: " + room["name"]) + #intended_action = input("What would you like to do? Type 'explore' or 'examine'?").strip() + choice = input("""Choose one of these options: + + A: Explore what's in the room + B: Examine what you want to + + + Please enter your choice: """) + if choice.upper() == "A": + explore_room(room) + play_room(room) + elif choice.upper() == "B": + examine_item(input(" \n What would you like to examine? \n").strip()) + else: + print("\n That is a muggle error! You must only type either A or B.") + + play_room(room) + linebreak() + +def explore_room(room): + """ + Explore a room. List all items belonging to this room. + """ + items = [i["name"] for i in object_relations[room["name"]]] + print("\n You explore the room. This is " + room["name"] + ". You find these objects: \n- " + "\n- ".join(items)) + + +def get_next_room_of_door(door, current_room): + """ + From object_relations, find the two rooms connected to the given door. + Return the room that is not the current_room. + """ + if door == fenix_door: + quiz() + connected_rooms = object_relations[door["name"]] + for room in connected_rooms: + if(not current_room == room): + return room + +def examine_item(item_name): + """ + Examine an item which can be a door or furniture. + First make sure the intended item belongs to the current room. + Then check if the item is a door. Tell player if key hasn't been + collected yet. Otherwise ask player if they want to go to the next + room. If the item is not a door, then check if it contains keys. + Collect the key if found and update the game state. At the end, + play either the current or the next room depending on the game state + to keep playing. + """ + current_room = game_state["current_room"] + next_room = "" + output = None + + for item in object_relations[current_room["name"]]: + if(item["name"] == item_name): + + output = "\n You examine " + item_name + ". " + + if(item["type"] == "door"): + have_key = False + for key in game_state["keys_collected"]: + if(key["target"] == item): + have_key = True + if(have_key): + output += "You unlock it with a key you have." + next_room = get_next_room_of_door(item, current_room) + else: + output += "It is locked but you don't have the key." + else: + if(item["name"] in object_relations and len(object_relations[item["name"]])>0): + item_found = object_relations[item["name"]].pop() + game_state["keys_collected"].append(item_found) + output += "You find " + item_found["name"] + "." + else: + output += "There isn't anything interesting about it." + + + print(output) + see_again= input(("""Do you wish to examine more things? + + Y: To examine more things + N: Stop examine + + + Please enter your choice: """)) + if see_again.upper() == 'Y': + examine_item(input(" \n What would you like to examine? \n").strip()) + elif see_again.upper() == 'N': + continue + else: + see_again + break + + if(output is None): + print("You must have eaten some Bertie Botts Beansb and are seeing things twisted. That item isn't in the current room.") + + if(next_room and input("Do you wish to go to another Hogwards room? Write 'yes' to enter or write anything else to go to main menu.").strip().lower() == 'yes'): + + play_room(next_room) + else: + play_room(current_room) + +game_state = INIT_GAME_STATE.copy() + +start_game() + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: