{"id":13,"date":"2023-10-09T22:14:01","date_gmt":"2023-10-09T22:14:01","guid":{"rendered":"https:\/\/blogs.oregonstate.edu\/alsbrooc\/?p=13"},"modified":"2023-10-09T22:14:01","modified_gmt":"2023-10-09T22:14:01","slug":"text-adventure","status":"publish","type":"post","link":"https:\/\/blogs.oregonstate.edu\/alsbrooc\/2023\/10\/09\/text-adventure\/","title":{"rendered":"Text Adventure?!"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>You are standing in an open field west of a white house, with a boarded front door. \nThere is a small mailbox here.\n&gt;open mailbox\nOpening the mailbox reveals a small leaflet.\n&gt;read leaflet\n(Taken)\n\"Welcome to my Senior Software Engineering Project!\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">The Project<\/h2>\n\n\n\n<p>I have been assigned my project for the next three quarters, and it is a text based adventure engine. This project will require developing software that can make text adventures, and software that can play these games. The idea behind it is to create a platform for educators to easily create and distribute Text Adventure Games to their school computers.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Game Creator<\/h3>\n\n\n\n<p>This will be how educators create their interactive fiction. It has to be designed in order to be usable by people with low levels of tech familiarity (i.e. it can&#8217;t require programming or be a CLI). This system will then export the game as a large JSON file which contains all of the rooms, descriptions, puzzles, NPCs, inventory, and items.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"Rooms\":\n    {\n        \"R1\":\n        {\n            \"Description\":\"A room with a couch and two chairs. There are two cats sleeping on the couch.\",\n            \"NPCs\":&#091;\"Cat1\",\"Cat2\"],\n            \"InteractableObjects\":&#091;\"Couch\"]\n        }\n    },\n    \"NPCs\":\n    {\n        \"Cat1\":\n        {\n            \"Name\":\"Pickle\",\n            \"Description\":\"A soft siamese cat sleeping peacefully.\" \n        }\n    }\n}<\/code><\/pre>\n\n\n\n<p>Even writing this out made me start to realize how complicated the interconnections of a Text Adventure will be. I imagine we will have to standardize the interactions available for this project. I don&#8217;t believe we would have the time for developing customizable actions (look, drink etc.).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Game Player<\/h3>\n\n\n\n<p>This takes the game file an educator makes, and allows students to play through it. There are some interesting questions about whether game state should be stored in cookies in the browser, or if it should be stored server side. I lean towards saving game state server side, but I know that implementing that is more difficult. The advantages of being able to pick up where you left off on another device outweigh the difficulty in creating it. If I were to guess the best way to implement it, I&#8217;d say that after every action, the current game state would be updated from client to server. Upon restoring a session, the client would just pull the state from the server. This would also require account creation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Text Adventures<\/h2>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:50%\">\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full wp-duotone-default-filter\"><img loading=\"lazy\" decoding=\"async\" width=\"220\" height=\"262\" data-id=\"21\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7165\/files\/2023\/10\/image-8.png\" alt=\"\" class=\"wp-image-21\" \/><\/figure>\n<\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:50%\">\n<figure class=\"wp-block-image size-full is-resized wp-duotone-default-filter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7165\/files\/2023\/10\/image-7.png\" alt=\"\" class=\"wp-image-20\" width=\"332\" height=\"371\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7165\/files\/2023\/10\/image-7.png 299w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7165\/files\/2023\/10\/image-7-269x300.png 269w\" sizes=\"auto, (max-width: 332px) 100vw, 332px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p>Text adventures are one of the oldest forms of computer game, and are actually making somewhat of a comeback. You can go to itch.io and find many examples of modern interactive fiction. Traditionally text adventures are games delivered, you guessed it, entirely through text. Interaction with the game is done through typing in commands. This often involved focusing on verb noun pairs such as <code>look bookcase<\/code> or <code>walk North<\/code>. As text adventures got more complex, their input parsing did as well. The most well known text adventures are Zork I, and The Hitchhiker&#8217;s Guide to the Galaxy.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Zork Implementation Language<\/h4>\n\n\n\n<p>Zork Implementation Language was created to handle text command inputs from players. It is a rather robust system as far as text adventures go. I was able to find a <a href=\"https:\/\/web.archive.org\/web\/20100807003406\/http:\/\/xlisp.org\/zil.pdf\">manual<\/a> that teaches you how to use ZIL. It divides command words into two categories, objects and routines. Objects can be rooms you stand in or even items, and routines are sub programs that perform various tasks.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">ChatGPT<\/h4>\n\n\n\n<p>All of this parsing got me thinking about language models like chatGPT. It might be possible to make API calls to chatGPT in order to parse player input into actionable terms. I tested this with chatGPT and got pretty good results. Chatlog below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>Me:<\/strong>\nI'm writing a text based adventure game. I want you to parse player input into actions that will be passed into my program. The program takes a verb, a object, and an indirect object. The indirect object is optional. Some example interpretations would be taking user input \"hit the man with my bat\" and returning \"hit, man, bat\". Another example would be taking the user input \"look at the lake\" and returning \"look, lake\". If you understand say yes\n\n<strong>ChatGPT:<\/strong>\nYes\n\n<strong>Me:<\/strong>\nPlayer input: Look at the room\n\n<strong>ChatGPT:<\/strong>\nFor the player input \"Look at the room,\" the parsed action would be:\n\n- Verb: Look\n- Subject: room\n\nSo, the output would be: \"Look, room\"\n\n<strong>Me:<\/strong>\nPlayer input: eat the moldy bread\n\n<strong>ChatGPT:<\/strong>\nFor the player input \"eat the moldy bread,\" the parsed action would be:\n\n- Verb: eat\n- Subject: bread\n\nSo, the output would be: \"eat, bread\"\n\n<strong>Me:<\/strong>\nPlayer input: cut the bread with a knife\n\n<strong>ChatGPT:<\/strong>\nFor the player input \"cut the bread with a knife,\" the parsed action would be:\n\n- Verb: cut\n- Subject: bread\n- Indirect Subject: knife\n\nSo, the output would be: \"cut, bread, knife\"\n\n<strong>Me:<\/strong>\nPlayer input: use my knife to cut the bread\n\n<strong>ChatGPT:<\/strong>\nFor the player input \"use my knife to cut the bread,\" the parsed action would be:\n\n- Verb: use\n- Subject: knife\n- Indirect Subject: bread\n\nSo, the output would be: \"use, knife, bread\"<\/code><\/pre>\n\n\n\n<p>I checked the chatGPT api pricing and it seems pretty reasonable for our student project. I used GPT-3.5 Turbo for this example, and its pricing is as follows:<\/p>\n\n\n\n<p>1000 tokens = ~750 words<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Model<\/th><th>Input<\/th><th>Output<\/th><\/tr><\/thead><tbody><tr><td>4K context<\/td><td>$0.0015\/1K tokens<\/td><td>$0.002\/1K tokens<\/td><\/tr><tr><td>16K context<\/td><td>$0.003\/1K tokens<\/td><td>$0.004\/1K tokens<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full wp-duotone-default-filter\"><img loading=\"lazy\" decoding=\"async\" width=\"245\" height=\"400\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7165\/files\/2023\/10\/image-3.png\" alt=\"\" class=\"wp-image-16\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7165\/files\/2023\/10\/image-3.png 245w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7165\/files\/2023\/10\/image-3-184x300.png 184w\" sizes=\"auto, (max-width: 245px) 100vw, 245px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Choose Your Own Adventure<\/h3>\n\n\n\n<p>These books are worth making a note of. Choose Your Own Adventure is another form of interactive fiction which is significantly more limited than text adventures. The interaction in CYOA is limited to the pages in the book. A typical page in a CYOA book would describe your current situation and then give you a few options based on choices you could make. The choices are limited to what the page presents you. Though this is more limited and less immersive, it makes both the creation of the stories, and the creation of the project much easier.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Existing Tools for Text Adventures<\/h2>\n\n\n\n<p>Because text adventures have been around for so long, there are quite a few ways to create them. I&#8217;m running out of steam in my research today, but will leave a small collection of what I&#8217;ve found so far so that I can review them next time. I hope to gain insight into how they work, and their user interface choices.<br><a href=\"https:\/\/twinery.org\/\">Twine<\/a><br><a href=\"http:\/\/textadventures.co.uk\/\">TextAdventures.co.uk which apparently uses Quest<\/a><br><a href=\"https:\/\/www.adrift.co\/\">Adrift<\/a><br><a href=\"https:\/\/ganelson.github.io\/inform-website\/\">Inform<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Project I have been assigned my project for the next three quarters, and it is a text based adventure engine. This project will require developing software that can make text adventures, and software that can play these games. The idea behind it is to create a platform for educators to easily create and distribute [&hellip;]<\/p>\n","protected":false},"author":13726,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.oregonstate.edu\/alsbrooc\/wp-json\/wp\/v2\/posts\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.oregonstate.edu\/alsbrooc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.oregonstate.edu\/alsbrooc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/alsbrooc\/wp-json\/wp\/v2\/users\/13726"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/alsbrooc\/wp-json\/wp\/v2\/comments?post=13"}],"version-history":[{"count":2,"href":"https:\/\/blogs.oregonstate.edu\/alsbrooc\/wp-json\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":22,"href":"https:\/\/blogs.oregonstate.edu\/alsbrooc\/wp-json\/wp\/v2\/posts\/13\/revisions\/22"}],"wp:attachment":[{"href":"https:\/\/blogs.oregonstate.edu\/alsbrooc\/wp-json\/wp\/v2\/media?parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/alsbrooc\/wp-json\/wp\/v2\/categories?post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/alsbrooc\/wp-json\/wp\/v2\/tags?post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}