diff --git a/.ipynb_checkpoints/MVP - Elora final features-checkpoint.ipynb b/.ipynb_checkpoints/MVP - Elora final features-checkpoint.ipynb new file mode 100644 index 00000000..543c3921 --- /dev/null +++ b/.ipynb_checkpoints/MVP - Elora final features-checkpoint.ipynb @@ -0,0 +1,386 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "# Defining rooms\n", + "door_a = {\n", + " \"name\": \"door_a\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "\n", + "door_b = {\n", + " \"name\": \"door_b\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_c = {\n", + " \"name\": \"door_c\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_d = {\n", + " \"name\": \"door_d\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "# Defining keys\n", + "\n", + "key_a = {\n", + " \"name\": \"key for door a\",\n", + " \"type\": \"key\",\n", + " \"target\": door_a,\n", + "}\n", + "\n", + "key_b = {\n", + " \"name\": \"key for door b\",\n", + " \"type\": \"key\",\n", + " \"target\": door_b,\n", + "}\n", + "\n", + "key_c = {\n", + " \"name\": \"key for door c\",\n", + " \"type\": \"key\",\n", + " \"target\": door_c,\n", + "}\n", + "\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d,\n", + "}\n", + "\n", + "\n", + "# Defining items\n", + "couch = {\n", + " \"name\": \"couch\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "piano = {\n", + " \"name\": \"piano\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + " \n", + "queen_bed = {\n", + " \"name\": \"queen_bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "double_bed = {\n", + " \"name\": \"double_bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + " \n", + "dresser = {\n", + " \"name\": \"dresser\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dining_table = {\n", + " \"name\": \"dining_table\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "#rooms declaration: \n", + "game_room = {\n", + " \"name\": \"game_room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "bedroom_1 = {\n", + " \"name\": \"bedroom_1\",\n", + " \"type\": \"room\",\n", + "}\n", + "bedroom_2 = {\n", + " \"name\": \"bedroom_2\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "livingroom = {\n", + " \"name\": \"livingroom\",\n", + " \"type\": \"room\",\n", + "}\n", + "outside = {\n", + " \"name\": \"outside\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "\n", + "# define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"game_room\": [couch, piano, door_a],\n", + " \"bedroom_1\": [queen_bed, door_b, door_a, door_c],\n", + " \"bedroom_2\": [double_bed, dresser, door_b],\n", + " \"livingroom\": [dining_table, door_c, door_d],\n", + " \"outside\": [door_d],\n", + " \"door_a\": [game_room, bedroom_1],\n", + " \"door_b\": [bedroom_1, bedroom_2],\n", + " \"door_c\": [bedroom_1, livingroom],\n", + " \"door_d\": [livingroom, outside],\n", + " \"key_a\": [door_a],\n", + " \"key_b\": [door_b],\n", + " \"key_c\": [door_c],\n", + " \"key_d\": [door_d],\n", + " \"piano\": [key_a],\n", + " \"queen_bed\": [key_b],\n", + " \"double_bed\": [key_c],\n", + " \"dresser\": [key_d],\n", + " \"couch\": [],\n", + " \"dining_table\": [],\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": 27, + "metadata": {}, + "outputs": [], + "source": [ + "def linebreak():\n", + " \"\"\"\n", + " Print a line break\n", + " \"\"\"\n", + " print(\"\\n\\n\")\n", + "\n", + "import time\n", + "import sys\n", + "\n", + "def start_countdown():\n", + " \"\"\"\n", + " Countdown before starting the game\n", + " \"\"\"\n", + " for x in range(3, 0, -1):\n", + " print(x)\n", + " time.sleep(1)\n", + " print(\"LET'S PLAY!\")\n", + " \n", + " # Play a beep sound\n", + " if sys.platform.startswith('win'):\n", + " import winsound\n", + " frequency = 1500\n", + " duration = 1500\n", + " winsound.Beep(frequency, duration)\n", + " \n", + "\n", + "def start_game():\n", + " \"\"\"\n", + " Start the game\n", + " \"\"\"\n", + " print(\"Welcome to your Escape Room!\"+\"\\U0001F525\") \n", + " player_name = input(\"Before we get started, what's your name? \")\n", + " print(f'Hello {player_name} !')\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", + " \n", + " # Start the timer\n", + " start_time = time.time()\n", + " \n", + " play_room(game_state[\"current_room\"], start_time)\n", + "\n", + "def play_room(room, start_time): \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", + " \n", + " # Calculate elapsed time\n", + " elapsed_time = int(time.time() - start_time)\n", + " print(f\"\\nElapsed Time: {elapsed_time} seconds\\n\")\n", + " \n", + " if(game_state[\"current_room\"] == game_state[\"target_room\"]):\n", + " print(\"Congrats! You escaped the room!\"+\"\\U0001F389\")\n", + " print(f\"Total Time: {elapsed_time} seconds\")\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", + " \n", + " if intended_action == \"explore\":\n", + " explore_room(room)\n", + " play_room(room, start_time) # Include start_time argument here\n", + " elif intended_action == \"examine\":\n", + " examine_item(input(\"What would you like to examine?\"+\"\\U0001F914\").strip(), start_time) # Pass start_time here\n", + " else:\n", + " print(\"Not sure what you mean. Type 'explore' or 'examine'.\")\n", + " play_room(room, start_time) # Include start_time argument here\n", + " \n", + " linebreak()\n", + "\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, start_time): # Pass start_time here\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\"+\"\\U0001F44F\"\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\"+\"\\U0001F622\"\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\"+\"\\U0001F644\"\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? Enter 'yes' or 'no'\").strip() == 'yes'):\n", + " play_room(next_room, start_time) # Include start_time argument here\n", + " else:\n", + " play_room(current_room, start_time) # Include start_time argument here" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "2\n", + "1\n", + "LET'S PLAY!\n", + "Welcome to your Escape Room!🔥\n" + ] + }, + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Before we get started, what's your name? Elora\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello Elora !\n", + "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", + "\n", + "Elapsed Time: 0 seconds\n", + "\n", + "You are now in game_room\n" + ] + }, + { + "name": "stdin", + "output_type": "stream", + "text": [ + "What would you like to do? Type 'explore' or 'examine'? examine\n" + ] + } + ], + "source": [ + "start_countdown()\n", + "\n", + "game_state = INIT_GAME_STATE.copy()\n", + "\n", + "start_game()\n" + ] + }, + { + "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 (ipykernel)", + "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.11.7" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 00000000..26b94e1d --- /dev/null +++ b/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,632 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 8, + "id": "8d8c1761-1c5e-4a4f-8a33-5ffb590ed136", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "enter the time in seconds: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "2\n", + "1\n", + "TIME'S UP !\n" + ] + } + ], + "source": [ + "import time\n", + "my_time = int(input('enter the time in seconds:'))\n", + "for x in range(my_time, 0, -1):\n", + " print(x)\n", + " time.sleep(1)\n", + "print(\"TIME'S UP !\")\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "3c42a4ca-6d80-4df6-8ead-dd0f208ede13", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "2\n", + "1\n", + "TIME'S UP !\n" + ] + } + ], + "source": [ + "import time\n", + "\n", + "for x in range(3, 0, -1):\n", + " print(x)\n", + " time.sleep(1)\n", + "print(\"TIME'S UP !\")" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "6d0bbed8-8172-47d1-b1dd-22f45b9ff2f4", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "start time\n", + "1713471160.6527634\n" + ] + }, + { + "name": "stdin", + "output_type": "stream", + "text": [ + "press enter to stop \n" + ] + }, + { + "ename": "NameError", + "evalue": "name 'tim' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[10], line 6\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(start_time)\n\u001b[0;32m 5\u001b[0m stopper\u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mpress enter to stop\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m----> 6\u001b[0m end_time \u001b[38;5;241m=\u001b[39m tim\u001b[38;5;241m.\u001b[39mtime()\n", + "\u001b[1;31mNameError\u001b[0m: name 'tim' is not defined" + ] + } + ], + "source": [ + "import time\n", + "print('start time')\n", + "start_time = time.time()\n", + "print(start_time)\n", + "stopper= input('press enter to stop')\n", + "end_time = tim.time()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "ef55cdd7-9b98-4048-b82e-b757e3ea43fa", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5\n" + ] + } + ], + "source": [ + "import time\n", + "time_limit = 5\n", + "start_time = time.time()\n", + "elapsed_time = time.time() - start_time\n", + "print(time_limit - int(elapsed_time))\n", + "if elapsed_time > time_limit :\n", + " print('GAME OVER')\n", + " exit()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "92a17b9f-8128-42bc-9265-e1f3657fe0d8", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "enter the time in seconds: 60\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "00:00\n", + "00:59\n", + "00:58\n", + "00:57\n", + "00:56\n", + "00:55\n", + "00:54\n", + "00:53\n", + "00:52\n", + "00:51\n", + "00:50\n", + "00:49\n", + "00:48\n", + "00:47\n", + "00:46\n", + "00:45\n", + "00:44\n", + "00:43\n", + "00:42\n", + "00:41\n", + "00:40\n", + "00:39\n", + "00:38\n", + "00:37\n", + "00:36\n", + "00:35\n", + "00:34\n", + "00:33\n", + "00:32\n", + "00:31\n", + "00:30\n", + "00:29\n", + "00:28\n", + "00:27\n", + "00:26\n", + "00:25\n", + "00:24\n", + "00:23\n", + "00:22\n", + "00:21\n", + "00:20\n", + "00:19\n", + "00:18\n", + "00:17\n", + "00:16\n", + "00:15\n", + "00:14\n", + "00:13\n", + "00:12\n", + "00:11\n", + "00:10\n", + "00:09\n", + "00:08\n", + "00:07\n", + "00:06\n", + "00:05\n", + "00:04\n", + "00:03\n", + "00:02\n", + "00:01\n", + "TIME'S UP !\n" + ] + } + ], + "source": [ + "import time\n", + "my_time = int(input('enter the time in seconds:'))\n", + "for x in range(my_time, 0, -1):\n", + " seconds = x % 60\n", + " minutes = int(x/60)%60\n", + " hours = int(x/3600)\n", + " print(f'{hours:02}:{seconds:02}')\n", + " time.sleep(1)\n", + "print(\"TIME'S UP !\")" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "738e3c1d-d228-449b-9923-1b0cdbebf191", + "metadata": {}, + "outputs": [], + "source": [ + "import winsound\n", + "frequency = 1500 # Set Frequency To 2500 Hertz\n", + "duration = 1000 # Set Duration To 1000 ms == 1 second\n", + "winsound.Beep(frequency, duration)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "5849d495-0de8-40fc-bc08-0d983b154b27", + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'pydub'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[11], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m# import required module\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mpydub\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m AudioSegment\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mpydub\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mplayback\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m play\n\u001b[0;32m 5\u001b[0m \u001b[38;5;66;03m# for playing mp3 file\u001b[39;00m\n", + "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'pydub'" + ] + } + ], + "source": [ + "\n", + "# import required module\n", + "from pydub import AudioSegment\n", + "from pydub.playback import play\n", + " \n", + "# for playing mp3 file\n", + "song = AudioSegment.from_mp3(\"note.mp3\")\n", + "print('playing sound using pydub')\n", + "play(song)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "dbe849a9-c012-4d23-9f13-f23d543e4b9e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Welcome to the Escape Game!\n", + "You have 5 minutes to escape.\n", + "Time remaining: 300 seconds\n", + "Time remaining: 298 seconds\n", + "Time remaining: 297 seconds\n", + "Time remaining: 296 seconds\n", + "Time remaining: 295 seconds\n", + "Time remaining: 294 seconds\n", + "Time remaining: 293 seconds\n", + "Time remaining: 292 seconds\n", + "Time remaining: 291 seconds\n", + "Time remaining: 290 seconds\n", + "Time remaining: 289 seconds\n", + "Time remaining: 288 seconds\n", + "Time remaining: 287 seconds\n", + "Time remaining: 286 seconds\n", + "Time remaining: 285 seconds\n", + "Time remaining: 284 seconds\n", + "Time remaining: 283 seconds\n", + "Time remaining: 282 seconds\n", + "Time remaining: 281 seconds\n", + "Time remaining: 280 seconds\n", + "Time remaining: 279 seconds\n", + "Time remaining: 278 seconds\n", + "Time remaining: 277 seconds\n", + "Time remaining: 276 seconds\n", + "Time remaining: 275 seconds\n", + "Time remaining: 274 seconds\n", + "Time remaining: 273 seconds\n", + "Time remaining: 272 seconds\n", + "Time remaining: 271 seconds\n", + "Time remaining: 270 seconds\n", + "Time remaining: 269 seconds\n", + "Time remaining: 268 seconds\n", + "Time remaining: 267 seconds\n", + "Time remaining: 266 seconds\n", + "Time remaining: 265 seconds\n", + "Time remaining: 264 seconds\n", + "Time remaining: 263 seconds\n" + ] + }, + { + "ename": "KeyboardInterrupt", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[1], line 25\u001b[0m\n\u001b[0;32m 22\u001b[0m \u001b[38;5;66;03m# Add your game logic here\u001b[39;00m\n\u001b[0;32m 24\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;18m__name__\u001b[39m \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m__main__\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m---> 25\u001b[0m escape_game()\n", + "Cell \u001b[1;32mIn[1], line 20\u001b[0m, in \u001b[0;36mescape_game\u001b[1;34m()\u001b[0m\n\u001b[0;32m 17\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mYou have 5 minutes to escape.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 19\u001b[0m duration \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m5\u001b[39m \u001b[38;5;241m*\u001b[39m \u001b[38;5;241m60\u001b[39m \u001b[38;5;66;03m# 5 minutes in seconds\u001b[39;00m\n\u001b[1;32m---> 20\u001b[0m start_timer(duration)\n", + "Cell \u001b[1;32mIn[1], line 10\u001b[0m, in \u001b[0;36mstart_timer\u001b[1;34m(duration)\u001b[0m\n\u001b[0;32m 8\u001b[0m remaining_time \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mint\u001b[39m(end_time \u001b[38;5;241m-\u001b[39m time\u001b[38;5;241m.\u001b[39mtime())\n\u001b[0;32m 9\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTime remaining: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mremaining_time\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m seconds\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m---> 10\u001b[0m time\u001b[38;5;241m.\u001b[39msleep(\u001b[38;5;241m1\u001b[39m)\n\u001b[0;32m 12\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTime\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124ms up!\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[1;31mKeyboardInterrupt\u001b[0m: " + ] + } + ], + "source": [ + "import time\n", + "\n", + "def start_timer(duration):\n", + " start_time = time.time()\n", + " end_time = start_time + duration\n", + " \n", + " while time.time() < end_time:\n", + " remaining_time = int(end_time - time.time())\n", + " print(f\"Time remaining: {remaining_time} seconds\")\n", + " time.sleep(1)\n", + " \n", + " print(\"Time's up!\")\n", + " # Add code to handle game over when time is up\n", + "\n", + "def escape_game():\n", + " print(\"Welcome to the Escape Game!\")\n", + " print(\"You have 5 minutes to escape.\")\n", + " \n", + " duration = 5 * 60 # 5 minutes in seconds\n", + " start_timer(duration)\n", + " \n", + " # Add your game logic here\n", + "\n", + "if __name__ == \"__main__\":\n", + " escape_game()" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "89149b9f-73be-4d0d-8930-31dc8c6ea18e", + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'pygame'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[2], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpygame\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mtime\u001b[39;00m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;66;03m# Initialize pygame\u001b[39;00m\n", + "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'pygame'" + ] + } + ], + "source": [ + "import pygame\n", + "import time\n", + "\n", + "# Initialize pygame\n", + "pygame.init()\n", + "\n", + "# Initialize the mixer for sound\n", + "pygame.mixer.init()\n", + "\n", + "def play_sound(sound_file):\n", + " pygame.mixer.music.load(sound_file)\n", + " pygame.mixer.music.play()\n", + " while pygame.mixer.music.get_busy():\n", + " pygame.time.Clock().tick(10)\n", + "\n", + "def main():\n", + " try:\n", + " # Play sound effect\n", + " play_sound('path_to_sound_file.wav') # Replace 'path_to_sound_file.wav' with your sound file path\n", + "\n", + " # Keep the program running to let the sound play\n", + " while True:\n", + " time.sleep(1)\n", + " except KeyboardInterrupt:\n", + " pygame.mixer.music.stop()\n", + " pygame.quit()\n", + "\n", + "if __name__ == \"__main__\":\n", + " main()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "304af359-56f6-4568-af6d-9ac174f8083e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from IPython.display import Audio\n", + "\n", + "Audio(\"congratulations-deep-voice-172193.mp3\", autoplay=True)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "666a0565-8d60-40aa-96cb-89e672d9ff36", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from IPython.display import Audio\n", + "Audio(\"congratulations-deep-voice-172193.mp3\", autoplay=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "a0f07218-97d3-4e0c-ae9a-c7e0ae1ed96d", + "metadata": {}, + "outputs": [], + "source": [ + "import winsound\n", + "frequency = 1500 \n", + "duration = 1000 \n", + "winsound.Beep(frequency, duration)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "ba2410d7-6959-4318-8430-65ac9e4eca7a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " __\n", + " / \\\n", + " | |\n", + " \\____/\n", + "\n" + ] + } + ], + "source": [ + "print(\"\"\"\n", + " __\n", + " / \\\\\n", + " | |\n", + " \\\\____/\n", + "\"\"\")" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "ae282eea-20b4-4410-bccf-5c38d9c8e75f", + "metadata": {}, + "outputs": [], + "source": [ + "def make_magic():\n", + " print(\"Abracadabra! Magic happening here!\")" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "b4b5238a-8e7f-4e3e-b5d7-569b8cbb0e78", + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "def random_joke():\n", + " jokes = [\n", + " \"Why did the programmer quit his job? He didn't get arrays.\",\n", + " \"What's a computer's favorite snack? Microchips!\",\n", + " \"Why did the computer cross the road? To get to the other website.\"\n", + " ]\n", + " print(random.choice(jokes))" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "f5376b1d-e547-4269-aa52-ca48ceaf9697", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "2\n", + "1\n", + "LET'S PLAY!\n" + ] + } + ], + "source": [ + "import time\n", + "for x in range(3, 0, -1):\n", + " print(x)\n", + " time.sleep(1)\n", + "print(\"LET'S PLAY!\")" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "2ccf695a-58c8-402b-a1cc-17288ed3f669", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "😀\n" + ] + } + ], + "source": [ + "print(\"\\U0001F600\")" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "6e0f28a7-7193-4098-899c-d5dbd3daac34", + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "(unicode error) 'unicodeescape' codec can't decode bytes in position 0-6: truncated \\UXXXXXXXX escape (1201725009.py, line 1)", + "output_type": "error", + "traceback": [ + "\u001b[1;36m Cell \u001b[1;32mIn[18], line 1\u001b[1;36m\u001b[0m\n\u001b[1;33m print(\"Congrats! You escaped the room!\"+\"\\U1F915\")\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m (unicode error) 'unicodeescape' codec can't decode bytes in position 0-6: truncated \\UXXXXXXXX escape\n" + ] + } + ], + "source": [ + "print(\"Congrats! You escaped the room!\"+\"\\U1F915\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "239bb853-c0c6-481f-9881-0fd94b3e5ebd", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.11.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/.ipynb_checkpoints/escape-room-plan-checkpoint.jpg b/.ipynb_checkpoints/escape-room-plan-checkpoint.jpg new file mode 100644 index 00000000..a3ea42c1 Binary files /dev/null and b/.ipynb_checkpoints/escape-room-plan-checkpoint.jpg differ diff --git a/MVP - Elora final features.ipynb b/MVP - Elora final features.ipynb new file mode 100644 index 00000000..543c3921 --- /dev/null +++ b/MVP - Elora final features.ipynb @@ -0,0 +1,386 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "# Defining rooms\n", + "door_a = {\n", + " \"name\": \"door_a\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "\n", + "door_b = {\n", + " \"name\": \"door_b\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_c = {\n", + " \"name\": \"door_c\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_d = {\n", + " \"name\": \"door_d\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "# Defining keys\n", + "\n", + "key_a = {\n", + " \"name\": \"key for door a\",\n", + " \"type\": \"key\",\n", + " \"target\": door_a,\n", + "}\n", + "\n", + "key_b = {\n", + " \"name\": \"key for door b\",\n", + " \"type\": \"key\",\n", + " \"target\": door_b,\n", + "}\n", + "\n", + "key_c = {\n", + " \"name\": \"key for door c\",\n", + " \"type\": \"key\",\n", + " \"target\": door_c,\n", + "}\n", + "\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d,\n", + "}\n", + "\n", + "\n", + "# Defining items\n", + "couch = {\n", + " \"name\": \"couch\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "piano = {\n", + " \"name\": \"piano\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + " \n", + "queen_bed = {\n", + " \"name\": \"queen_bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "double_bed = {\n", + " \"name\": \"double_bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + " \n", + "dresser = {\n", + " \"name\": \"dresser\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dining_table = {\n", + " \"name\": \"dining_table\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "#rooms declaration: \n", + "game_room = {\n", + " \"name\": \"game_room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "bedroom_1 = {\n", + " \"name\": \"bedroom_1\",\n", + " \"type\": \"room\",\n", + "}\n", + "bedroom_2 = {\n", + " \"name\": \"bedroom_2\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "livingroom = {\n", + " \"name\": \"livingroom\",\n", + " \"type\": \"room\",\n", + "}\n", + "outside = {\n", + " \"name\": \"outside\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "\n", + "# define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"game_room\": [couch, piano, door_a],\n", + " \"bedroom_1\": [queen_bed, door_b, door_a, door_c],\n", + " \"bedroom_2\": [double_bed, dresser, door_b],\n", + " \"livingroom\": [dining_table, door_c, door_d],\n", + " \"outside\": [door_d],\n", + " \"door_a\": [game_room, bedroom_1],\n", + " \"door_b\": [bedroom_1, bedroom_2],\n", + " \"door_c\": [bedroom_1, livingroom],\n", + " \"door_d\": [livingroom, outside],\n", + " \"key_a\": [door_a],\n", + " \"key_b\": [door_b],\n", + " \"key_c\": [door_c],\n", + " \"key_d\": [door_d],\n", + " \"piano\": [key_a],\n", + " \"queen_bed\": [key_b],\n", + " \"double_bed\": [key_c],\n", + " \"dresser\": [key_d],\n", + " \"couch\": [],\n", + " \"dining_table\": [],\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": 27, + "metadata": {}, + "outputs": [], + "source": [ + "def linebreak():\n", + " \"\"\"\n", + " Print a line break\n", + " \"\"\"\n", + " print(\"\\n\\n\")\n", + "\n", + "import time\n", + "import sys\n", + "\n", + "def start_countdown():\n", + " \"\"\"\n", + " Countdown before starting the game\n", + " \"\"\"\n", + " for x in range(3, 0, -1):\n", + " print(x)\n", + " time.sleep(1)\n", + " print(\"LET'S PLAY!\")\n", + " \n", + " # Play a beep sound\n", + " if sys.platform.startswith('win'):\n", + " import winsound\n", + " frequency = 1500\n", + " duration = 1500\n", + " winsound.Beep(frequency, duration)\n", + " \n", + "\n", + "def start_game():\n", + " \"\"\"\n", + " Start the game\n", + " \"\"\"\n", + " print(\"Welcome to your Escape Room!\"+\"\\U0001F525\") \n", + " player_name = input(\"Before we get started, what's your name? \")\n", + " print(f'Hello {player_name} !')\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", + " \n", + " # Start the timer\n", + " start_time = time.time()\n", + " \n", + " play_room(game_state[\"current_room\"], start_time)\n", + "\n", + "def play_room(room, start_time): \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", + " \n", + " # Calculate elapsed time\n", + " elapsed_time = int(time.time() - start_time)\n", + " print(f\"\\nElapsed Time: {elapsed_time} seconds\\n\")\n", + " \n", + " if(game_state[\"current_room\"] == game_state[\"target_room\"]):\n", + " print(\"Congrats! You escaped the room!\"+\"\\U0001F389\")\n", + " print(f\"Total Time: {elapsed_time} seconds\")\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", + " \n", + " if intended_action == \"explore\":\n", + " explore_room(room)\n", + " play_room(room, start_time) # Include start_time argument here\n", + " elif intended_action == \"examine\":\n", + " examine_item(input(\"What would you like to examine?\"+\"\\U0001F914\").strip(), start_time) # Pass start_time here\n", + " else:\n", + " print(\"Not sure what you mean. Type 'explore' or 'examine'.\")\n", + " play_room(room, start_time) # Include start_time argument here\n", + " \n", + " linebreak()\n", + "\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, start_time): # Pass start_time here\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\"+\"\\U0001F44F\"\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\"+\"\\U0001F622\"\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\"+\"\\U0001F644\"\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? Enter 'yes' or 'no'\").strip() == 'yes'):\n", + " play_room(next_room, start_time) # Include start_time argument here\n", + " else:\n", + " play_room(current_room, start_time) # Include start_time argument here" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "2\n", + "1\n", + "LET'S PLAY!\n", + "Welcome to your Escape Room!🔥\n" + ] + }, + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Before we get started, what's your name? Elora\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello Elora !\n", + "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", + "\n", + "Elapsed Time: 0 seconds\n", + "\n", + "You are now in game_room\n" + ] + }, + { + "name": "stdin", + "output_type": "stream", + "text": [ + "What would you like to do? Type 'explore' or 'examine'? examine\n" + ] + } + ], + "source": [ + "start_countdown()\n", + "\n", + "game_state = INIT_GAME_STATE.copy()\n", + "\n", + "start_game()\n" + ] + }, + { + "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 (ipykernel)", + "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.11.7" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/MVP - Elora final features.py b/MVP - Elora final features.py new file mode 100644 index 00000000..e495966b --- /dev/null +++ b/MVP - Elora final features.py @@ -0,0 +1,313 @@ +#!/usr/bin/env python +# coding: utf-8 + +# In[26]: + + +# Defining rooms +door_a = { + "name": "door_a", + "type": "door", +} + + +door_b = { + "name": "door_b", + "type": "door", +} + +door_c = { + "name": "door_c", + "type": "door", +} + +door_d = { + "name": "door_d", + "type": "door", +} + +# Defining keys + +key_a = { + "name": "key for door a", + "type": "key", + "target": door_a, +} + +key_b = { + "name": "key for door b", + "type": "key", + "target": door_b, +} + +key_c = { + "name": "key for door c", + "type": "key", + "target": door_c, +} + +key_d = { + "name": "key for door d", + "type": "key", + "target": door_d, +} + + +# Defining items +couch = { + "name": "couch", + "type": "furniture", +} + +piano = { + "name": "piano", + "type": "furniture", +} + + +queen_bed = { + "name": "queen_bed", + "type": "furniture", +} + +double_bed = { + "name": "double_bed", + "type": "furniture", +} + +dresser = { + "name": "dresser", + "type": "furniture", +} + +dining_table = { + "name": "dining_table", + "type": "furniture", +} + +#rooms declaration: +game_room = { + "name": "game_room", + "type": "room", +} + +bedroom_1 = { + "name": "bedroom_1", + "type": "room", +} +bedroom_2 = { + "name": "bedroom_2", + "type": "room", +} + +livingroom = { + "name": "livingroom", + "type": "room", +} +outside = { + "name": "outside", + "type": "room", +} + + +# define which items/rooms are related + +object_relations = { + "game_room": [couch, piano, door_a], + "bedroom_1": [queen_bed, door_b, door_a, door_c], + "bedroom_2": [double_bed, dresser, door_b], + "livingroom": [dining_table, door_c, door_d], + "outside": [door_d], + "door_a": [game_room, bedroom_1], + "door_b": [bedroom_1, bedroom_2], + "door_c": [bedroom_1, livingroom], + "door_d": [livingroom, outside], + "key_a": [door_a], + "key_b": [door_b], + "key_c": [door_c], + "key_d": [door_d], + "piano": [key_a], + "queen_bed": [key_b], + "double_bed": [key_c], + "dresser": [key_d], + "couch": [], + "dining_table": [], +} + +# 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": game_room, + "keys_collected": [], + "target_room": outside +} + + +# In[27]: + + +def linebreak(): + """ + Print a line break + """ + print("\n\n") + +import time +import sys + +def start_countdown(): + """ + Countdown before starting the game + """ + for x in range(3, 0, -1): + print(x) + time.sleep(1) + print("LET'S PLAY!") + + # Play a beep sound + if sys.platform.startswith('win'): + import winsound + frequency = 1500 + duration = 1500 + winsound.Beep(frequency, duration) + + +def start_game(): + """ + Start the game + """ + print("Welcome to your Escape Room!"+"\U0001F525") + player_name = input("Before we get started, what's your name? ") + print(f'Hello {player_name} !') + 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!") + + # Start the timer + start_time = time.time() + + play_room(game_state["current_room"], start_time) + +def play_room(room, start_time): + """ + 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 + + # Calculate elapsed time + elapsed_time = int(time.time() - start_time) + print(f"\nElapsed Time: {elapsed_time} seconds\n") + + if(game_state["current_room"] == game_state["target_room"]): + print("Congrats! You escaped the room!"+"\U0001F389") + print(f"Total Time: {elapsed_time} seconds") + else: + print("You are now in " + room["name"]) + intended_action = input("What would you like to do? Type 'explore' or 'examine'? ").strip() + + if intended_action == "explore": + explore_room(room) + play_room(room, start_time) # Include start_time argument here + elif intended_action == "examine": + examine_item(input("What would you like to examine?"+"\U0001F914").strip(), start_time) # Pass start_time here + else: + print("Not sure what you mean. Type 'explore' or 'examine'.") + play_room(room, start_time) # Include start_time argument here + + 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("You explore the room. This is " + room["name"] + ". You find " + ", ".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. + """ + connected_rooms = object_relations[door["name"]] + for room in connected_rooms: + if(not current_room == room): + return room + +def examine_item(item_name, start_time): # Pass start_time here + """ + 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 = "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"+"\U0001F44F" + next_room = get_next_room_of_door(item, current_room) + else: + output += "It is locked but you don't have the key"+"\U0001F622" + 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"+"\U0001F644" + print(output) + break + + if(output is None): + print("The item you requested is not found in the current room.") + + if(next_room and input("Do you want to go to the next room? Enter 'yes' or 'no'").strip() == 'yes'): + play_room(next_room, start_time) # Include start_time argument here + else: + play_room(current_room, start_time) # Include start_time argument here + + +# In[ ]: + + +start_countdown() + +game_state = INIT_GAME_STATE.copy() + +start_game() + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/Untitled.ipynb b/Untitled.ipynb new file mode 100644 index 00000000..26b94e1d --- /dev/null +++ b/Untitled.ipynb @@ -0,0 +1,632 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 8, + "id": "8d8c1761-1c5e-4a4f-8a33-5ffb590ed136", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "enter the time in seconds: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "2\n", + "1\n", + "TIME'S UP !\n" + ] + } + ], + "source": [ + "import time\n", + "my_time = int(input('enter the time in seconds:'))\n", + "for x in range(my_time, 0, -1):\n", + " print(x)\n", + " time.sleep(1)\n", + "print(\"TIME'S UP !\")\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "3c42a4ca-6d80-4df6-8ead-dd0f208ede13", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "2\n", + "1\n", + "TIME'S UP !\n" + ] + } + ], + "source": [ + "import time\n", + "\n", + "for x in range(3, 0, -1):\n", + " print(x)\n", + " time.sleep(1)\n", + "print(\"TIME'S UP !\")" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "6d0bbed8-8172-47d1-b1dd-22f45b9ff2f4", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "start time\n", + "1713471160.6527634\n" + ] + }, + { + "name": "stdin", + "output_type": "stream", + "text": [ + "press enter to stop \n" + ] + }, + { + "ename": "NameError", + "evalue": "name 'tim' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[10], line 6\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(start_time)\n\u001b[0;32m 5\u001b[0m stopper\u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mpress enter to stop\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m----> 6\u001b[0m end_time \u001b[38;5;241m=\u001b[39m tim\u001b[38;5;241m.\u001b[39mtime()\n", + "\u001b[1;31mNameError\u001b[0m: name 'tim' is not defined" + ] + } + ], + "source": [ + "import time\n", + "print('start time')\n", + "start_time = time.time()\n", + "print(start_time)\n", + "stopper= input('press enter to stop')\n", + "end_time = tim.time()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "ef55cdd7-9b98-4048-b82e-b757e3ea43fa", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5\n" + ] + } + ], + "source": [ + "import time\n", + "time_limit = 5\n", + "start_time = time.time()\n", + "elapsed_time = time.time() - start_time\n", + "print(time_limit - int(elapsed_time))\n", + "if elapsed_time > time_limit :\n", + " print('GAME OVER')\n", + " exit()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "92a17b9f-8128-42bc-9265-e1f3657fe0d8", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "enter the time in seconds: 60\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "00:00\n", + "00:59\n", + "00:58\n", + "00:57\n", + "00:56\n", + "00:55\n", + "00:54\n", + "00:53\n", + "00:52\n", + "00:51\n", + "00:50\n", + "00:49\n", + "00:48\n", + "00:47\n", + "00:46\n", + "00:45\n", + "00:44\n", + "00:43\n", + "00:42\n", + "00:41\n", + "00:40\n", + "00:39\n", + "00:38\n", + "00:37\n", + "00:36\n", + "00:35\n", + "00:34\n", + "00:33\n", + "00:32\n", + "00:31\n", + "00:30\n", + "00:29\n", + "00:28\n", + "00:27\n", + "00:26\n", + "00:25\n", + "00:24\n", + "00:23\n", + "00:22\n", + "00:21\n", + "00:20\n", + "00:19\n", + "00:18\n", + "00:17\n", + "00:16\n", + "00:15\n", + "00:14\n", + "00:13\n", + "00:12\n", + "00:11\n", + "00:10\n", + "00:09\n", + "00:08\n", + "00:07\n", + "00:06\n", + "00:05\n", + "00:04\n", + "00:03\n", + "00:02\n", + "00:01\n", + "TIME'S UP !\n" + ] + } + ], + "source": [ + "import time\n", + "my_time = int(input('enter the time in seconds:'))\n", + "for x in range(my_time, 0, -1):\n", + " seconds = x % 60\n", + " minutes = int(x/60)%60\n", + " hours = int(x/3600)\n", + " print(f'{hours:02}:{seconds:02}')\n", + " time.sleep(1)\n", + "print(\"TIME'S UP !\")" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "738e3c1d-d228-449b-9923-1b0cdbebf191", + "metadata": {}, + "outputs": [], + "source": [ + "import winsound\n", + "frequency = 1500 # Set Frequency To 2500 Hertz\n", + "duration = 1000 # Set Duration To 1000 ms == 1 second\n", + "winsound.Beep(frequency, duration)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "5849d495-0de8-40fc-bc08-0d983b154b27", + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'pydub'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[11], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m# import required module\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mpydub\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m AudioSegment\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mpydub\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mplayback\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m play\n\u001b[0;32m 5\u001b[0m \u001b[38;5;66;03m# for playing mp3 file\u001b[39;00m\n", + "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'pydub'" + ] + } + ], + "source": [ + "\n", + "# import required module\n", + "from pydub import AudioSegment\n", + "from pydub.playback import play\n", + " \n", + "# for playing mp3 file\n", + "song = AudioSegment.from_mp3(\"note.mp3\")\n", + "print('playing sound using pydub')\n", + "play(song)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "dbe849a9-c012-4d23-9f13-f23d543e4b9e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Welcome to the Escape Game!\n", + "You have 5 minutes to escape.\n", + "Time remaining: 300 seconds\n", + "Time remaining: 298 seconds\n", + "Time remaining: 297 seconds\n", + "Time remaining: 296 seconds\n", + "Time remaining: 295 seconds\n", + "Time remaining: 294 seconds\n", + "Time remaining: 293 seconds\n", + "Time remaining: 292 seconds\n", + "Time remaining: 291 seconds\n", + "Time remaining: 290 seconds\n", + "Time remaining: 289 seconds\n", + "Time remaining: 288 seconds\n", + "Time remaining: 287 seconds\n", + "Time remaining: 286 seconds\n", + "Time remaining: 285 seconds\n", + "Time remaining: 284 seconds\n", + "Time remaining: 283 seconds\n", + "Time remaining: 282 seconds\n", + "Time remaining: 281 seconds\n", + "Time remaining: 280 seconds\n", + "Time remaining: 279 seconds\n", + "Time remaining: 278 seconds\n", + "Time remaining: 277 seconds\n", + "Time remaining: 276 seconds\n", + "Time remaining: 275 seconds\n", + "Time remaining: 274 seconds\n", + "Time remaining: 273 seconds\n", + "Time remaining: 272 seconds\n", + "Time remaining: 271 seconds\n", + "Time remaining: 270 seconds\n", + "Time remaining: 269 seconds\n", + "Time remaining: 268 seconds\n", + "Time remaining: 267 seconds\n", + "Time remaining: 266 seconds\n", + "Time remaining: 265 seconds\n", + "Time remaining: 264 seconds\n", + "Time remaining: 263 seconds\n" + ] + }, + { + "ename": "KeyboardInterrupt", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[1], line 25\u001b[0m\n\u001b[0;32m 22\u001b[0m \u001b[38;5;66;03m# Add your game logic here\u001b[39;00m\n\u001b[0;32m 24\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;18m__name__\u001b[39m \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m__main__\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m---> 25\u001b[0m escape_game()\n", + "Cell \u001b[1;32mIn[1], line 20\u001b[0m, in \u001b[0;36mescape_game\u001b[1;34m()\u001b[0m\n\u001b[0;32m 17\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mYou have 5 minutes to escape.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 19\u001b[0m duration \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m5\u001b[39m \u001b[38;5;241m*\u001b[39m \u001b[38;5;241m60\u001b[39m \u001b[38;5;66;03m# 5 minutes in seconds\u001b[39;00m\n\u001b[1;32m---> 20\u001b[0m start_timer(duration)\n", + "Cell \u001b[1;32mIn[1], line 10\u001b[0m, in \u001b[0;36mstart_timer\u001b[1;34m(duration)\u001b[0m\n\u001b[0;32m 8\u001b[0m remaining_time \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mint\u001b[39m(end_time \u001b[38;5;241m-\u001b[39m time\u001b[38;5;241m.\u001b[39mtime())\n\u001b[0;32m 9\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTime remaining: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mremaining_time\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m seconds\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m---> 10\u001b[0m time\u001b[38;5;241m.\u001b[39msleep(\u001b[38;5;241m1\u001b[39m)\n\u001b[0;32m 12\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTime\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124ms up!\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[1;31mKeyboardInterrupt\u001b[0m: " + ] + } + ], + "source": [ + "import time\n", + "\n", + "def start_timer(duration):\n", + " start_time = time.time()\n", + " end_time = start_time + duration\n", + " \n", + " while time.time() < end_time:\n", + " remaining_time = int(end_time - time.time())\n", + " print(f\"Time remaining: {remaining_time} seconds\")\n", + " time.sleep(1)\n", + " \n", + " print(\"Time's up!\")\n", + " # Add code to handle game over when time is up\n", + "\n", + "def escape_game():\n", + " print(\"Welcome to the Escape Game!\")\n", + " print(\"You have 5 minutes to escape.\")\n", + " \n", + " duration = 5 * 60 # 5 minutes in seconds\n", + " start_timer(duration)\n", + " \n", + " # Add your game logic here\n", + "\n", + "if __name__ == \"__main__\":\n", + " escape_game()" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "89149b9f-73be-4d0d-8930-31dc8c6ea18e", + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'pygame'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[2], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpygame\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mtime\u001b[39;00m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;66;03m# Initialize pygame\u001b[39;00m\n", + "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'pygame'" + ] + } + ], + "source": [ + "import pygame\n", + "import time\n", + "\n", + "# Initialize pygame\n", + "pygame.init()\n", + "\n", + "# Initialize the mixer for sound\n", + "pygame.mixer.init()\n", + "\n", + "def play_sound(sound_file):\n", + " pygame.mixer.music.load(sound_file)\n", + " pygame.mixer.music.play()\n", + " while pygame.mixer.music.get_busy():\n", + " pygame.time.Clock().tick(10)\n", + "\n", + "def main():\n", + " try:\n", + " # Play sound effect\n", + " play_sound('path_to_sound_file.wav') # Replace 'path_to_sound_file.wav' with your sound file path\n", + "\n", + " # Keep the program running to let the sound play\n", + " while True:\n", + " time.sleep(1)\n", + " except KeyboardInterrupt:\n", + " pygame.mixer.music.stop()\n", + " pygame.quit()\n", + "\n", + "if __name__ == \"__main__\":\n", + " main()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "304af359-56f6-4568-af6d-9ac174f8083e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from IPython.display import Audio\n", + "\n", + "Audio(\"congratulations-deep-voice-172193.mp3\", autoplay=True)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "666a0565-8d60-40aa-96cb-89e672d9ff36", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from IPython.display import Audio\n", + "Audio(\"congratulations-deep-voice-172193.mp3\", autoplay=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "a0f07218-97d3-4e0c-ae9a-c7e0ae1ed96d", + "metadata": {}, + "outputs": [], + "source": [ + "import winsound\n", + "frequency = 1500 \n", + "duration = 1000 \n", + "winsound.Beep(frequency, duration)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "ba2410d7-6959-4318-8430-65ac9e4eca7a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " __\n", + " / \\\n", + " | |\n", + " \\____/\n", + "\n" + ] + } + ], + "source": [ + "print(\"\"\"\n", + " __\n", + " / \\\\\n", + " | |\n", + " \\\\____/\n", + "\"\"\")" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "ae282eea-20b4-4410-bccf-5c38d9c8e75f", + "metadata": {}, + "outputs": [], + "source": [ + "def make_magic():\n", + " print(\"Abracadabra! Magic happening here!\")" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "b4b5238a-8e7f-4e3e-b5d7-569b8cbb0e78", + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "def random_joke():\n", + " jokes = [\n", + " \"Why did the programmer quit his job? He didn't get arrays.\",\n", + " \"What's a computer's favorite snack? Microchips!\",\n", + " \"Why did the computer cross the road? To get to the other website.\"\n", + " ]\n", + " print(random.choice(jokes))" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "f5376b1d-e547-4269-aa52-ca48ceaf9697", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "2\n", + "1\n", + "LET'S PLAY!\n" + ] + } + ], + "source": [ + "import time\n", + "for x in range(3, 0, -1):\n", + " print(x)\n", + " time.sleep(1)\n", + "print(\"LET'S PLAY!\")" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "2ccf695a-58c8-402b-a1cc-17288ed3f669", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "😀\n" + ] + } + ], + "source": [ + "print(\"\\U0001F600\")" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "6e0f28a7-7193-4098-899c-d5dbd3daac34", + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "(unicode error) 'unicodeescape' codec can't decode bytes in position 0-6: truncated \\UXXXXXXXX escape (1201725009.py, line 1)", + "output_type": "error", + "traceback": [ + "\u001b[1;36m Cell \u001b[1;32mIn[18], line 1\u001b[1;36m\u001b[0m\n\u001b[1;33m print(\"Congrats! You escaped the room!\"+\"\\U1F915\")\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m (unicode error) 'unicodeescape' codec can't decode bytes in position 0-6: truncated \\UXXXXXXXX escape\n" + ] + } + ], + "source": [ + "print(\"Congrats! You escaped the room!\"+\"\\U1F915\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "239bb853-c0c6-481f-9881-0fd94b3e5ebd", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.11.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/congratulations-deep-voice-172193.mp3 b/congratulations-deep-voice-172193.mp3 new file mode 100644 index 00000000..fbfe71de Binary files /dev/null and b/congratulations-deep-voice-172193.mp3 differ diff --git a/sample-code-Elora final features.py b/sample-code-Elora final features.py new file mode 100644 index 00000000..e495966b --- /dev/null +++ b/sample-code-Elora final features.py @@ -0,0 +1,313 @@ +#!/usr/bin/env python +# coding: utf-8 + +# In[26]: + + +# Defining rooms +door_a = { + "name": "door_a", + "type": "door", +} + + +door_b = { + "name": "door_b", + "type": "door", +} + +door_c = { + "name": "door_c", + "type": "door", +} + +door_d = { + "name": "door_d", + "type": "door", +} + +# Defining keys + +key_a = { + "name": "key for door a", + "type": "key", + "target": door_a, +} + +key_b = { + "name": "key for door b", + "type": "key", + "target": door_b, +} + +key_c = { + "name": "key for door c", + "type": "key", + "target": door_c, +} + +key_d = { + "name": "key for door d", + "type": "key", + "target": door_d, +} + + +# Defining items +couch = { + "name": "couch", + "type": "furniture", +} + +piano = { + "name": "piano", + "type": "furniture", +} + + +queen_bed = { + "name": "queen_bed", + "type": "furniture", +} + +double_bed = { + "name": "double_bed", + "type": "furniture", +} + +dresser = { + "name": "dresser", + "type": "furniture", +} + +dining_table = { + "name": "dining_table", + "type": "furniture", +} + +#rooms declaration: +game_room = { + "name": "game_room", + "type": "room", +} + +bedroom_1 = { + "name": "bedroom_1", + "type": "room", +} +bedroom_2 = { + "name": "bedroom_2", + "type": "room", +} + +livingroom = { + "name": "livingroom", + "type": "room", +} +outside = { + "name": "outside", + "type": "room", +} + + +# define which items/rooms are related + +object_relations = { + "game_room": [couch, piano, door_a], + "bedroom_1": [queen_bed, door_b, door_a, door_c], + "bedroom_2": [double_bed, dresser, door_b], + "livingroom": [dining_table, door_c, door_d], + "outside": [door_d], + "door_a": [game_room, bedroom_1], + "door_b": [bedroom_1, bedroom_2], + "door_c": [bedroom_1, livingroom], + "door_d": [livingroom, outside], + "key_a": [door_a], + "key_b": [door_b], + "key_c": [door_c], + "key_d": [door_d], + "piano": [key_a], + "queen_bed": [key_b], + "double_bed": [key_c], + "dresser": [key_d], + "couch": [], + "dining_table": [], +} + +# 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": game_room, + "keys_collected": [], + "target_room": outside +} + + +# In[27]: + + +def linebreak(): + """ + Print a line break + """ + print("\n\n") + +import time +import sys + +def start_countdown(): + """ + Countdown before starting the game + """ + for x in range(3, 0, -1): + print(x) + time.sleep(1) + print("LET'S PLAY!") + + # Play a beep sound + if sys.platform.startswith('win'): + import winsound + frequency = 1500 + duration = 1500 + winsound.Beep(frequency, duration) + + +def start_game(): + """ + Start the game + """ + print("Welcome to your Escape Room!"+"\U0001F525") + player_name = input("Before we get started, what's your name? ") + print(f'Hello {player_name} !') + 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!") + + # Start the timer + start_time = time.time() + + play_room(game_state["current_room"], start_time) + +def play_room(room, start_time): + """ + 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 + + # Calculate elapsed time + elapsed_time = int(time.time() - start_time) + print(f"\nElapsed Time: {elapsed_time} seconds\n") + + if(game_state["current_room"] == game_state["target_room"]): + print("Congrats! You escaped the room!"+"\U0001F389") + print(f"Total Time: {elapsed_time} seconds") + else: + print("You are now in " + room["name"]) + intended_action = input("What would you like to do? Type 'explore' or 'examine'? ").strip() + + if intended_action == "explore": + explore_room(room) + play_room(room, start_time) # Include start_time argument here + elif intended_action == "examine": + examine_item(input("What would you like to examine?"+"\U0001F914").strip(), start_time) # Pass start_time here + else: + print("Not sure what you mean. Type 'explore' or 'examine'.") + play_room(room, start_time) # Include start_time argument here + + 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("You explore the room. This is " + room["name"] + ". You find " + ", ".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. + """ + connected_rooms = object_relations[door["name"]] + for room in connected_rooms: + if(not current_room == room): + return room + +def examine_item(item_name, start_time): # Pass start_time here + """ + 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 = "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"+"\U0001F44F" + next_room = get_next_room_of_door(item, current_room) + else: + output += "It is locked but you don't have the key"+"\U0001F622" + 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"+"\U0001F644" + print(output) + break + + if(output is None): + print("The item you requested is not found in the current room.") + + if(next_room and input("Do you want to go to the next room? Enter 'yes' or 'no'").strip() == 'yes'): + play_room(next_room, start_time) # Include start_time argument here + else: + play_room(current_room, start_time) # Include start_time argument here + + +# In[ ]: + + +start_countdown() + +game_state = INIT_GAME_STATE.copy() + +start_game() + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/sample-code-eighteen-apr.py b/sample-code-eighteen-apr.py new file mode 100644 index 00000000..e495966b --- /dev/null +++ b/sample-code-eighteen-apr.py @@ -0,0 +1,313 @@ +#!/usr/bin/env python +# coding: utf-8 + +# In[26]: + + +# Defining rooms +door_a = { + "name": "door_a", + "type": "door", +} + + +door_b = { + "name": "door_b", + "type": "door", +} + +door_c = { + "name": "door_c", + "type": "door", +} + +door_d = { + "name": "door_d", + "type": "door", +} + +# Defining keys + +key_a = { + "name": "key for door a", + "type": "key", + "target": door_a, +} + +key_b = { + "name": "key for door b", + "type": "key", + "target": door_b, +} + +key_c = { + "name": "key for door c", + "type": "key", + "target": door_c, +} + +key_d = { + "name": "key for door d", + "type": "key", + "target": door_d, +} + + +# Defining items +couch = { + "name": "couch", + "type": "furniture", +} + +piano = { + "name": "piano", + "type": "furniture", +} + + +queen_bed = { + "name": "queen_bed", + "type": "furniture", +} + +double_bed = { + "name": "double_bed", + "type": "furniture", +} + +dresser = { + "name": "dresser", + "type": "furniture", +} + +dining_table = { + "name": "dining_table", + "type": "furniture", +} + +#rooms declaration: +game_room = { + "name": "game_room", + "type": "room", +} + +bedroom_1 = { + "name": "bedroom_1", + "type": "room", +} +bedroom_2 = { + "name": "bedroom_2", + "type": "room", +} + +livingroom = { + "name": "livingroom", + "type": "room", +} +outside = { + "name": "outside", + "type": "room", +} + + +# define which items/rooms are related + +object_relations = { + "game_room": [couch, piano, door_a], + "bedroom_1": [queen_bed, door_b, door_a, door_c], + "bedroom_2": [double_bed, dresser, door_b], + "livingroom": [dining_table, door_c, door_d], + "outside": [door_d], + "door_a": [game_room, bedroom_1], + "door_b": [bedroom_1, bedroom_2], + "door_c": [bedroom_1, livingroom], + "door_d": [livingroom, outside], + "key_a": [door_a], + "key_b": [door_b], + "key_c": [door_c], + "key_d": [door_d], + "piano": [key_a], + "queen_bed": [key_b], + "double_bed": [key_c], + "dresser": [key_d], + "couch": [], + "dining_table": [], +} + +# 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": game_room, + "keys_collected": [], + "target_room": outside +} + + +# In[27]: + + +def linebreak(): + """ + Print a line break + """ + print("\n\n") + +import time +import sys + +def start_countdown(): + """ + Countdown before starting the game + """ + for x in range(3, 0, -1): + print(x) + time.sleep(1) + print("LET'S PLAY!") + + # Play a beep sound + if sys.platform.startswith('win'): + import winsound + frequency = 1500 + duration = 1500 + winsound.Beep(frequency, duration) + + +def start_game(): + """ + Start the game + """ + print("Welcome to your Escape Room!"+"\U0001F525") + player_name = input("Before we get started, what's your name? ") + print(f'Hello {player_name} !') + 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!") + + # Start the timer + start_time = time.time() + + play_room(game_state["current_room"], start_time) + +def play_room(room, start_time): + """ + 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 + + # Calculate elapsed time + elapsed_time = int(time.time() - start_time) + print(f"\nElapsed Time: {elapsed_time} seconds\n") + + if(game_state["current_room"] == game_state["target_room"]): + print("Congrats! You escaped the room!"+"\U0001F389") + print(f"Total Time: {elapsed_time} seconds") + else: + print("You are now in " + room["name"]) + intended_action = input("What would you like to do? Type 'explore' or 'examine'? ").strip() + + if intended_action == "explore": + explore_room(room) + play_room(room, start_time) # Include start_time argument here + elif intended_action == "examine": + examine_item(input("What would you like to examine?"+"\U0001F914").strip(), start_time) # Pass start_time here + else: + print("Not sure what you mean. Type 'explore' or 'examine'.") + play_room(room, start_time) # Include start_time argument here + + 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("You explore the room. This is " + room["name"] + ". You find " + ", ".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. + """ + connected_rooms = object_relations[door["name"]] + for room in connected_rooms: + if(not current_room == room): + return room + +def examine_item(item_name, start_time): # Pass start_time here + """ + 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 = "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"+"\U0001F44F" + next_room = get_next_room_of_door(item, current_room) + else: + output += "It is locked but you don't have the key"+"\U0001F622" + 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"+"\U0001F644" + print(output) + break + + if(output is None): + print("The item you requested is not found in the current room.") + + if(next_room and input("Do you want to go to the next room? Enter 'yes' or 'no'").strip() == 'yes'): + play_room(next_room, start_time) # Include start_time argument here + else: + play_room(current_room, start_time) # Include start_time argument here + + +# In[ ]: + + +start_countdown() + +game_state = INIT_GAME_STATE.copy() + +start_game() + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + 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..c9341338 --- /dev/null +++ b/your-code/.ipynb_checkpoints/sample-code-checkpoint.ipynb @@ -0,0 +1,401 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "# Defining rooms\n", + "door_a = {\n", + " \"name\": \"door_a\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "\n", + "door_b = {\n", + " \"name\": \"door_b\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_c = {\n", + " \"name\": \"door_c\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_d = {\n", + " \"name\": \"door_d\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "# Defining keys\n", + "\n", + "key_a = {\n", + " \"name\": \"key for door a\",\n", + " \"type\": \"key\",\n", + " \"target\": door_a,\n", + "}\n", + "\n", + "key_b = {\n", + " \"name\": \"key for door b\",\n", + " \"type\": \"key\",\n", + " \"target\": door_b,\n", + "}\n", + "\n", + "key_c = {\n", + " \"name\": \"key for door c\",\n", + " \"type\": \"key\",\n", + " \"target\": door_c,\n", + "}\n", + "\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d,\n", + "}\n", + "\n", + "\n", + "# Defining items\n", + "couch = {\n", + " \"name\": \"couch\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "piano = {\n", + " \"name\": \"piano\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + " \n", + "queen_bed = {\n", + " \"name\": \"queen_bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "double_bed = {\n", + " \"name\": \"double_bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + " \n", + "dresser = {\n", + " \"name\": \"dresser\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dining_table = {\n", + " \"name\": \"dining_table\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "#rooms declaration: \n", + "game_room = {\n", + " \"name\": \"game_room\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "bedroom_1 = {\n", + " \"name\": \"bedroom_1\",\n", + " \"type\": \"room\",\n", + "}\n", + "bedroom_2 = {\n", + " \"name\": \"bedroom_2\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "livingroom = {\n", + " \"name\": \"livingroom\",\n", + " \"type\": \"room\",\n", + "}\n", + "outside = {\n", + " \"name\": \"outside\",\n", + " \"type\": \"room\",\n", + "}\n", + "\n", + "\n", + "# define which items/rooms are related\n", + "\n", + "object_relations = {\n", + " \"game_room\": [couch, piano, door_a],\n", + " \"bedroom_1\": [queen_bed, door_b, door_a, door_c],\n", + " \"bedroom_2\": [double_bed, dresser, door_b],\n", + " \"livingroom\": [dining_table, door_c, door_d],\n", + " \"outside\": [door_d],\n", + " \"door_a\": [game_room, bedroom_1],\n", + " \"door_b\": [bedroom_1, bedroom_2],\n", + " \"door_c\": [bedroom_1, livingroom],\n", + " \"door_d\": [livingroom, outside],\n", + " \"key_a\": [door_a],\n", + " \"key_b\": [door_b],\n", + " \"key_c\": [door_c],\n", + " \"key_d\": [door_d],\n", + " \"piano\": [key_a],\n", + " \"queen_bed\": [key_b],\n", + " \"double_bed\": [key_c],\n", + " \"dresser\": [key_d],\n", + " \"couch\": [],\n", + " \"dining_table\": [],\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", + "import time\n", + "import sys\n", + "\n", + "def start_countdown():\n", + " \"\"\"\n", + " Countdown before starting the game\n", + " \"\"\"\n", + " for x in range(3, 0, -1):\n", + " print(x)\n", + " time.sleep(1)\n", + " print(\"LET'S PLAY!\")\n", + " \n", + " # Play a beep sound\n", + " if sys.platform.startswith('win'):\n", + " import winsound\n", + " frequency = 1500\n", + " duration = 1500\n", + " winsound.Beep(frequency, duration)\n", + " \n", + "\n", + "def start_game():\n", + " \"\"\"\n", + " Start the game\n", + " \"\"\"\n", + " print(\"Welcome to your Escape Room!\"+\"\\U0001F525\") \n", + " player_name = input(\"Before we get started, what's your name? \")\n", + " print(f'Hello {player_name} !')\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", + " \n", + " # Start the timer\n", + " start_time = time.time()\n", + " \n", + " play_room(game_state[\"current_room\"], start_time)\n", + "\n", + "def play_room(room, start_time): \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", + " \n", + " # Calculate elapsed time\n", + " elapsed_time = int(time.time() - start_time)\n", + " print(f\"\\nElapsed Time: {elapsed_time} seconds\\n\")\n", + " \n", + " if(game_state[\"current_room\"] == game_state[\"target_room\"]):\n", + " print(\"Congrats! You escaped the room!\"+\"\\U0001F389\")\n", + " print(f\"Total Time: {elapsed_time} seconds\")\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", + " \n", + " if intended_action == \"explore\":\n", + " explore_room(room)\n", + " play_room(room, start_time) # Include start_time argument here\n", + " elif intended_action == \"examine\":\n", + " examine_item(input(\"What would you like to examine?\"+\"\\U0001F914\").strip(), start_time) # Pass start_time here\n", + " else:\n", + " print(\"Not sure what you mean. Type 'explore' or 'examine'.\")\n", + " play_room(room, start_time) # Include start_time argument here\n", + " \n", + " linebreak()\n", + "\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, start_time): # Pass start_time here\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\"+\"\\U0001F44F\"\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\"+\"\\U0001F622\"\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\"+\"\\U0001F644\"\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? Enter 'yes' or 'no'\").strip() == 'yes'):\n", + " play_room(next_room, start_time) # Include start_time argument here\n", + " else:\n", + " play_room(current_room, start_time) # Include start_time argument here" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "2\n", + "1\n", + "LET'S PLAY!\n", + "Welcome to your Escape Room!🔥\n" + ] + }, + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Before we get started, what's your name? Elora\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello Elora !\n", + "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", + "\n", + "Elapsed Time: 0 seconds\n", + "\n", + "You are now in game_room\n" + ] + }, + { + "name": "stdin", + "output_type": "stream", + "text": [ + "What would you like to do? Type 'explore' or 'examine'? examine\n", + "What would you like to examine?🤔 piano\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You examine piano. You find key for door a.\n", + "\n", + "Elapsed Time: 6 seconds\n", + "\n", + "You are now in game_room\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)", + "Cell \u001b[1;32mIn[3], line 5\u001b[0m\n\u001b[0;32m 1\u001b[0m start_countdown()\n\u001b[0;32m 3\u001b[0m game_state \u001b[38;5;241m=\u001b[39m INIT_GAME_STATE\u001b[38;5;241m.\u001b[39mcopy()\n\u001b[1;32m----> 5\u001b[0m start_game()\n", + "Cell \u001b[1;32mIn[2], line 39\u001b[0m, in \u001b[0;36mstart_game\u001b[1;34m()\u001b[0m\n\u001b[0;32m 36\u001b[0m \u001b[38;5;66;03m# Start the timer\u001b[39;00m\n\u001b[0;32m 37\u001b[0m start_time \u001b[38;5;241m=\u001b[39m time\u001b[38;5;241m.\u001b[39mtime()\n\u001b[1;32m---> 39\u001b[0m play_room(game_state[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcurrent_room\u001b[39m\u001b[38;5;124m\"\u001b[39m], start_time)\n", + "Cell \u001b[1;32mIn[2], line 64\u001b[0m, in \u001b[0;36mplay_room\u001b[1;34m(room, start_time)\u001b[0m\n\u001b[0;32m 62\u001b[0m play_room(room, start_time) \u001b[38;5;66;03m# Include start_time argument here\u001b[39;00m\n\u001b[0;32m 63\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m intended_action \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mexamine\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m---> 64\u001b[0m examine_item(\u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWhat would you like to examine?\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m+\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\U0001F914\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\u001b[38;5;241m.\u001b[39mstrip(), start_time) \u001b[38;5;66;03m# Pass start_time here\u001b[39;00m\n\u001b[0;32m 65\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 66\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNot sure what you mean. Type \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mexplore\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m or \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mexamine\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "Cell \u001b[1;32mIn[2], line 133\u001b[0m, in \u001b[0;36mexamine_item\u001b[1;34m(item_name, start_time)\u001b[0m\n\u001b[0;32m 131\u001b[0m play_room(next_room, start_time) \u001b[38;5;66;03m# Include start_time argument here\u001b[39;00m\n\u001b[0;32m 132\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 133\u001b[0m play_room(current_room, start_time)\n", + "Cell \u001b[1;32mIn[2], line 58\u001b[0m, in \u001b[0;36mplay_room\u001b[1;34m(room, start_time)\u001b[0m\n\u001b[0;32m 56\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 57\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mYou are now in \u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m+\u001b[39m room[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n\u001b[1;32m---> 58\u001b[0m intended_action \u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWhat would you like to do? Type \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mexplore\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m or \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mexamine\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m? \u001b[39m\u001b[38;5;124m\"\u001b[39m)\u001b[38;5;241m.\u001b[39mstrip()\n\u001b[0;32m 60\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m intended_action \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mexplore\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[0;32m 61\u001b[0m explore_room(room)\n", + "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\ipykernel\\kernelbase.py:1262\u001b[0m, in \u001b[0;36mKernel.raw_input\u001b[1;34m(self, prompt)\u001b[0m\n\u001b[0;32m 1260\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mraw_input was called, but this frontend does not support input requests.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 1261\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m StdinNotImplementedError(msg)\n\u001b[1;32m-> 1262\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_input_request(\n\u001b[0;32m 1263\u001b[0m \u001b[38;5;28mstr\u001b[39m(prompt),\n\u001b[0;32m 1264\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_parent_ident[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mshell\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[0;32m 1265\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mget_parent(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mshell\u001b[39m\u001b[38;5;124m\"\u001b[39m),\n\u001b[0;32m 1266\u001b[0m password\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 1267\u001b[0m )\n", + "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\ipykernel\\kernelbase.py:1305\u001b[0m, in \u001b[0;36mKernel._input_request\u001b[1;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[0;32m 1302\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m:\n\u001b[0;32m 1303\u001b[0m \u001b[38;5;66;03m# re-raise KeyboardInterrupt, to truncate traceback\u001b[39;00m\n\u001b[0;32m 1304\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInterrupted by user\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m-> 1305\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m(msg) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 1306\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m:\n\u001b[0;32m 1307\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlog\u001b[38;5;241m.\u001b[39mwarning(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInvalid Message:\u001b[39m\u001b[38;5;124m\"\u001b[39m, exc_info\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n", + "\u001b[1;31mKeyboardInterrupt\u001b[0m: Interrupted by user" + ] + } + ], + "source": [ + "start_countdown()\n", + "\n", + "game_state = INIT_GAME_STATE.copy()\n", + "\n", + "start_game()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.11.7" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/your-code/sample-code.ipynb b/your-code/sample-code.ipynb index a6f8a94d..c9341338 100644 --- a/your-code/sample-code.ipynb +++ b/your-code/sample-code.ipynb @@ -6,49 +6,134 @@ "metadata": {}, "outputs": [], "source": [ - "# define rooms and items\n", + "# Defining rooms\n", + "door_a = {\n", + " \"name\": \"door_a\",\n", + " \"type\": \"door\",\n", + "}\n", "\n", - "couch = {\n", - " \"name\": \"couch\",\n", - " \"type\": \"furniture\",\n", + "\n", + "door_b = {\n", + " \"name\": \"door_b\",\n", + " \"type\": \"door\",\n", "}\n", "\n", - "door_a = {\n", - " \"name\": \"door a\",\n", + "door_c = {\n", + " \"name\": \"door_c\",\n", + " \"type\": \"door\",\n", + "}\n", + "\n", + "door_d = {\n", + " \"name\": \"door_d\",\n", " \"type\": \"door\",\n", "}\n", "\n", + "# Defining keys\n", + "\n", "key_a = {\n", " \"name\": \"key for door a\",\n", " \"type\": \"key\",\n", " \"target\": door_a,\n", "}\n", "\n", + "key_b = {\n", + " \"name\": \"key for door b\",\n", + " \"type\": \"key\",\n", + " \"target\": door_b,\n", + "}\n", + "\n", + "key_c = {\n", + " \"name\": \"key for door c\",\n", + " \"type\": \"key\",\n", + " \"target\": door_c,\n", + "}\n", + "\n", + "key_d = {\n", + " \"name\": \"key for door d\",\n", + " \"type\": \"key\",\n", + " \"target\": door_d,\n", + "}\n", + "\n", + "\n", + "# Defining items\n", + "couch = {\n", + " \"name\": \"couch\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", "piano = {\n", " \"name\": \"piano\",\n", " \"type\": \"furniture\",\n", "}\n", "\n", + " \n", + "queen_bed = {\n", + " \"name\": \"queen_bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "double_bed = {\n", + " \"name\": \"double_bed\",\n", + " \"type\": \"furniture\",\n", + "}\n", + " \n", + "dresser = {\n", + " \"name\": \"dresser\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "dining_table = {\n", + " \"name\": \"dining_table\",\n", + " \"type\": \"furniture\",\n", + "}\n", + "\n", + "#rooms declaration: \n", "game_room = {\n", - " \"name\": \"game room\",\n", + " \"name\": \"game_room\",\n", " \"type\": \"room\",\n", "}\n", "\n", - "outside = {\n", - " \"name\": \"outside\"\n", + "bedroom_1 = {\n", + " \"name\": \"bedroom_1\",\n", + " \"type\": \"room\",\n", + "}\n", + "bedroom_2 = {\n", + " \"name\": \"bedroom_2\",\n", + " \"type\": \"room\",\n", "}\n", "\n", - "all_rooms = [game_room, outside]\n", + "livingroom = {\n", + " \"name\": \"livingroom\",\n", + " \"type\": \"room\",\n", + "}\n", + "outside = {\n", + " \"name\": \"outside\",\n", + " \"type\": \"room\",\n", + "}\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", + " \"game_room\": [couch, piano, door_a],\n", + " \"bedroom_1\": [queen_bed, door_b, door_a, door_c],\n", + " \"bedroom_2\": [double_bed, dresser, door_b],\n", + " \"livingroom\": [dining_table, door_c, door_d],\n", + " \"outside\": [door_d],\n", + " \"door_a\": [game_room, bedroom_1],\n", + " \"door_b\": [bedroom_1, bedroom_2],\n", + " \"door_c\": [bedroom_1, livingroom],\n", + " \"door_d\": [livingroom, outside],\n", + " \"key_a\": [door_a],\n", + " \"key_b\": [door_b],\n", + " \"key_c\": [door_c],\n", + " \"key_d\": [door_d],\n", " \"piano\": [key_a],\n", - " \"outside\": [door_a],\n", - " \"door a\": [game_room, outside]\n", + " \"queen_bed\": [key_b],\n", + " \"double_bed\": [key_c],\n", + " \"dresser\": [key_d],\n", + " \"couch\": [],\n", + " \"dining_table\": [],\n", "}\n", "\n", "# define game state. Do not directly change this dict. \n", @@ -75,35 +160,71 @@ " \"\"\"\n", " print(\"\\n\\n\")\n", "\n", + "import time\n", + "import sys\n", + "\n", + "def start_countdown():\n", + " \"\"\"\n", + " Countdown before starting the game\n", + " \"\"\"\n", + " for x in range(3, 0, -1):\n", + " print(x)\n", + " time.sleep(1)\n", + " print(\"LET'S PLAY!\")\n", + " \n", + " # Play a beep sound\n", + " if sys.platform.startswith('win'):\n", + " import winsound\n", + " frequency = 1500\n", + " duration = 1500\n", + " winsound.Beep(frequency, duration)\n", + " \n", + "\n", "def start_game():\n", " \"\"\"\n", " Start the game\n", " \"\"\"\n", + " print(\"Welcome to your Escape Room!\"+\"\\U0001F525\") \n", + " player_name = input(\"Before we get started, what's your name? \")\n", + " print(f'Hello {player_name} !')\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", + " # Start the timer\n", + " start_time = time.time()\n", + " \n", + " play_room(game_state[\"current_room\"], start_time)\n", "\n", - "def play_room(room):\n", + "def play_room(room, start_time): \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", + " \n", + " # Calculate elapsed time\n", + " elapsed_time = int(time.time() - start_time)\n", + " print(f\"\\nElapsed Time: {elapsed_time} seconds\\n\")\n", + " \n", " if(game_state[\"current_room\"] == game_state[\"target_room\"]):\n", - " print(\"Congrats! You escaped the room!\")\n", + " print(\"Congrats! You escaped the room!\"+\"\\U0001F389\")\n", + " print(f\"Total Time: {elapsed_time} seconds\")\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", + " intended_action = input(\"What would you like to do? Type 'explore' or 'examine'? \").strip()\n", + " \n", " if intended_action == \"explore\":\n", " explore_room(room)\n", - " play_room(room)\n", + " play_room(room, start_time) # Include start_time argument here\n", " elif intended_action == \"examine\":\n", - " examine_item(input(\"What would you like to examine?\").strip())\n", + " examine_item(input(\"What would you like to examine?\"+\"\\U0001F914\").strip(), start_time) # Pass start_time here\n", " else:\n", " print(\"Not sure what you mean. Type 'explore' or 'examine'.\")\n", - " play_room(room)\n", - " linebreak()\n", + " play_room(room, start_time) # Include start_time argument here\n", + " \n", + " linebreak()\n", "\n", + " \n", "def explore_room(room):\n", " \"\"\"\n", " Explore a room. List all items belonging to this room.\n", @@ -121,7 +242,7 @@ " if(not current_room == room):\n", " return room\n", "\n", - "def examine_item(item_name):\n", + "def examine_item(item_name, start_time): # Pass start_time here\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", @@ -145,27 +266,27 @@ " if(key[\"target\"] == item):\n", " have_key = True\n", " if(have_key):\n", - " output += \"You unlock it with a key you have.\"\n", + " output += \"You unlock it with a key you have\"+\"\\U0001F44F\"\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", + " output += \"It is locked but you don't have the key\"+\"\\U0001F622\"\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", + " output += \"There isn't anything interesting about it\"+\"\\U0001F644\"\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", + " if(next_room and input(\"Do you want to go to the next room? Enter 'yes' or 'no'\").strip() == 'yes'):\n", + " play_room(next_room, start_time) # Include start_time argument here\n", " else:\n", - " play_room(current_room)" + " play_room(current_room, start_time) # Include start_time argument here" ] }, { @@ -177,43 +298,75 @@ "name": "stdout", "output_type": "stream", "text": [ + "3\n", + "2\n", + "1\n", + "LET'S PLAY!\n", + "Welcome to your Escape Room!🔥\n" + ] + }, + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Before we get started, what's your name? Elora\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello Elora !\n", "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", + "Elapsed Time: 0 seconds\n", "\n", + "You are now in game_room\n" + ] + }, + { + "name": "stdin", + "output_type": "stream", + "text": [ + "What would you like to do? Type 'explore' or 'examine'? examine\n", + "What would you like to examine?🤔 piano\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You examine piano. You find key for door a.\n", "\n", + "Elapsed Time: 6 seconds\n", "\n", - "\n" + "You are now in game_room\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)", + "Cell \u001b[1;32mIn[3], line 5\u001b[0m\n\u001b[0;32m 1\u001b[0m start_countdown()\n\u001b[0;32m 3\u001b[0m game_state \u001b[38;5;241m=\u001b[39m INIT_GAME_STATE\u001b[38;5;241m.\u001b[39mcopy()\n\u001b[1;32m----> 5\u001b[0m start_game()\n", + "Cell \u001b[1;32mIn[2], line 39\u001b[0m, in \u001b[0;36mstart_game\u001b[1;34m()\u001b[0m\n\u001b[0;32m 36\u001b[0m \u001b[38;5;66;03m# Start the timer\u001b[39;00m\n\u001b[0;32m 37\u001b[0m start_time \u001b[38;5;241m=\u001b[39m time\u001b[38;5;241m.\u001b[39mtime()\n\u001b[1;32m---> 39\u001b[0m play_room(game_state[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcurrent_room\u001b[39m\u001b[38;5;124m\"\u001b[39m], start_time)\n", + "Cell \u001b[1;32mIn[2], line 64\u001b[0m, in \u001b[0;36mplay_room\u001b[1;34m(room, start_time)\u001b[0m\n\u001b[0;32m 62\u001b[0m play_room(room, start_time) \u001b[38;5;66;03m# Include start_time argument here\u001b[39;00m\n\u001b[0;32m 63\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m intended_action \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mexamine\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m---> 64\u001b[0m examine_item(\u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWhat would you like to examine?\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m+\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\U0001F914\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\u001b[38;5;241m.\u001b[39mstrip(), start_time) \u001b[38;5;66;03m# Pass start_time here\u001b[39;00m\n\u001b[0;32m 65\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 66\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNot sure what you mean. Type \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mexplore\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m or \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mexamine\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "Cell \u001b[1;32mIn[2], line 133\u001b[0m, in \u001b[0;36mexamine_item\u001b[1;34m(item_name, start_time)\u001b[0m\n\u001b[0;32m 131\u001b[0m play_room(next_room, start_time) \u001b[38;5;66;03m# Include start_time argument here\u001b[39;00m\n\u001b[0;32m 132\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 133\u001b[0m play_room(current_room, start_time)\n", + "Cell \u001b[1;32mIn[2], line 58\u001b[0m, in \u001b[0;36mplay_room\u001b[1;34m(room, start_time)\u001b[0m\n\u001b[0;32m 56\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 57\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mYou are now in \u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m+\u001b[39m room[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n\u001b[1;32m---> 58\u001b[0m intended_action \u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWhat would you like to do? Type \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mexplore\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m or \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mexamine\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m? \u001b[39m\u001b[38;5;124m\"\u001b[39m)\u001b[38;5;241m.\u001b[39mstrip()\n\u001b[0;32m 60\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m intended_action \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mexplore\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[0;32m 61\u001b[0m explore_room(room)\n", + "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\ipykernel\\kernelbase.py:1262\u001b[0m, in \u001b[0;36mKernel.raw_input\u001b[1;34m(self, prompt)\u001b[0m\n\u001b[0;32m 1260\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mraw_input was called, but this frontend does not support input requests.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 1261\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m StdinNotImplementedError(msg)\n\u001b[1;32m-> 1262\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_input_request(\n\u001b[0;32m 1263\u001b[0m \u001b[38;5;28mstr\u001b[39m(prompt),\n\u001b[0;32m 1264\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_parent_ident[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mshell\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[0;32m 1265\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mget_parent(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mshell\u001b[39m\u001b[38;5;124m\"\u001b[39m),\n\u001b[0;32m 1266\u001b[0m password\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 1267\u001b[0m )\n", + "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\ipykernel\\kernelbase.py:1305\u001b[0m, in \u001b[0;36mKernel._input_request\u001b[1;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[0;32m 1302\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m:\n\u001b[0;32m 1303\u001b[0m \u001b[38;5;66;03m# re-raise KeyboardInterrupt, to truncate traceback\u001b[39;00m\n\u001b[0;32m 1304\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInterrupted by user\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m-> 1305\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m(msg) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 1306\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m:\n\u001b[0;32m 1307\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlog\u001b[38;5;241m.\u001b[39mwarning(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInvalid Message:\u001b[39m\u001b[38;5;124m\"\u001b[39m, exc_info\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n", + "\u001b[1;31mKeyboardInterrupt\u001b[0m: Interrupted by user" ] } ], "source": [ + "start_countdown()\n", + "\n", "game_state = INIT_GAME_STATE.copy()\n", "\n", - "start_game()" + "start_game()\n" ] }, { @@ -226,7 +379,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -240,9 +393,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.11.7" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }