Code Jam for creating a text-based adventure game engine and custom worlds

Overview

Text Based Adventure Jam

Author: Devin McIntyre

Our goal is two-fold:

  1. Create a text based adventure game engine that can parse a standard file format
  2. Create a text based adventure game using the standardized file format

We'll be looking to implement a very, very basic engine that includes support for rooms, items, doors, commands, and effects, as well as an inventory system.

What you need to build

Provided below is a definition for a text based adventure game configuration. The configuration contains a list of items, the commands they take, the effects they can have, the rooms that hold them, the doors that connect those rooms, the starting position and the final room. Your goal is to build an engine that can parse this defintion, and any definition matching the standard, into a playable text based adventure game.

The basics of the game are as follows:

  1. Players always start in the room defined by startingRoomId.
  2. Players have an inventory of infinite size and space, which they can fill with items.
    • Items that are used for a task can be used ONLY ONCE. After use they should be removed from a players inventory
  3. Players can interact with the world by use of text commands.
    • The expected commands are
      • LOOK
      • TAKE
      • READ
      • USE $A ON $B
      • GO $DIRECTION
      • INVENTORY
    • What these commands should do is outlined below
  4. Using commands on items can produce effects
    • Expected effects are
      • UNLOCK_DOOR
      • LOCK_DOOR
      • CHANGE_ITEM_TEXT
    • What these effects should do is outlined below
  5. A player's goal is to arrive at the room defined with the endingRoomId property

File Format Breakdown

Commands:

Commands are the building block of a users interaction with the world. Users issue commands with or without targets, and are given feedback resulting from the command. These are verbs, specifying an action, such as "GO", "READ" and "TAKE".

Command structure

{
    "command" : string,
    "text" : string,
    "acceptedItems" : [
        {
            "itemId" : string,
            "text" : string,
            "effectIds" : string[]
        }
    ]
}

Commands to implement:

LOOK - displays the text of the LOOK command for the specified object. Valid objects are any visible objects in a room, and any object in a users inventory. If no object given, instead display text of the current room, along with any doors and visible items.

  • Use
    • Looking at an item : "LOOK book"
    • Looking at a room : "LOOK"

TAKE - adds item to inventory if available, hides item when looking at the room. If no item provided, prompt for an item. If item provided is invalid, display error message

  • Use
    • Specifying no item: "TAKE"
    • Specifying item : "TAKE pizza box"

READ - displays the text of the READ command for the specified object. If no object is given, prompt for an object. If object is invalid, or object lacks read command, display error message

  • Use
    • Specifying object : "READ cheese"

USE $A ON $B - Takes two objects and applies any effects if the object $A is allowed to be used on the object $B. If objects are missing or the combination is invalid, display error message

  • Use
    • Specifying objects : "USE book ON book shelf"

GO $DIRECTION - Attempts to move the player to the next room in the direction they specify. If a door exists in the direction, and the door is unlocked, the player is moved to the next room. If the door exists but is locked, display an error message about the doors status. If the door doesn't exist, display an error message.

  • Use
    • Specifying a direction : "GO north"

INVENTORY - Displays any items by name in the users inventory.

Effects

Effects give us the ability to have latent actions following a users input. Actions take 0 or more items or doors, specify an effect type, and can provide contextual text to accompany the effect (either by displaying the text to the user, or modifying existing text). Examples of effects are "UNLOCK_DOOR" and "CHANGE_ITEM_TEXT"

Effect Structure

{
    "id" : string,
    "type" : string,
    "doorIds" : string[],
    "itemIds" : string[],
    "text" : string
}

Effects to implement

UNLOCK_DOOR - Unlocks any provided door IDs. If text is provided, display the text to the user.

LOCK_DOOR - Locks any provided door IDs. If text is provided, display the text to the user.

CHANGE_ITEM_TEXT - Updates the descriptive text of an item to the provided text.

Items

Items provide the user with tools to solve puzzles between rooms. Items contain lists of valid commands, an ID, a visibility state, and a name.

Item Structure

{
    "id" : string,
    "name" : string,
    "commands" : Command[],
    "visible" : boolean
}

Doors

Doors are used to signify a transition point between rooms. They may be locked or unlocked by effects, a state that is global to the door, and contain an id.

Door Structure

{
    "id" : string,
    "locked" : boolean
}

Rooms

Rooms represent areas of the world. Each room may have up to 4 doors (One in each cardinal direction), descriptive text, zero or more items, and can be marked as the victory condition. Reaching the room marked as the victory condition should end the game after printing the descriptive text.

Room Structure

{
    "id" : string,
    "text" : string,
    "itemIds" : string[],
    "doors" : [
        {
            "doorId" : string,
            "direction" : string,
            "connectedRoomId" : string
        }
    ]
}

Full Game Format Structure

{
    "items" : Item[],
    "effects" : Effect[],
    "doors" : Door[],
    "rooms" : Room[],
    "startingRoomId" : string,
    "endingRoomId" : string
}

Example of a valid adventure (3 rooms, 2 items, 3 effects, and one simple puzzle):

{
    "items" : [
        {
            "id" : "1",
            "name" : "Book",
            "commands" : [
                {
                    "command" : "LOOK",
                    "text" : "An old book, worn with time."
                },
                {
                    "command" : "TAKE"
                },
                {
                    "command" : "READ",
                    "text" : "The old book is filled with mostly useless, outdated information"
                }
            ],
            "visible" : true
        },
        {
            "id" : "2",
            "name" : "Book Shelf",
            "commands" : [
                {
                    "command" : "LOOK",
                    "text" : "An old dusty bookshelf full of tomes.  One seems to be missing."
                },
                {
                    "command" : "USE",
                    "acceptedItem" : [
                        {
                            "itemId" : "1",
                            "text" : "You place the book into it's place on the shelf",
                            "effectIds" : ["1", "2", "3"]
                        }
                    ]
                }
            ],
            "visible" : true
        }
    ],
    "effects" : [
        {
            "id" : "1",
            "type": "UNLOCK_DOOR",
            "doorIds" : ["2"],
            "text": "The door to the east makes a satisfying click."
        },
        {
            "id" : "2",
            "type": "LOCK_DOOR",
            "doorIds" : ["1"],
            "text": "The door to the south makes a unsatisfying click."
        },
        {
            "id" : "3",
            "type" : "CHANGE_ITEM_TEXT",
            "itemIds" : ["2"],
            "text" :"An old dusty bookshelf full of tomes."
        }
    ],
    "doors" : [
        {
            "id" : "1",
            "locked" : false 
        },
        {
            "id" : "2",
            "locked" : true
        }
    ], 
    "rooms" : [
        {
            "id": "1",
            "text" : "A simple room with a bed and a side table.",
            "itemIds" : ["1"],
            "doors" : [
                {
                    "doorId" : "1",
                    "direction" : "NORTH",
                    "connectedRoomId" : "2"
                }
            ]
        },
        {
            "id" : "2",
            "text" : "A simple room with some furniture.",
            "itemIds" : ["2"],
            "doors" : [
                {
                    "doorId" : "2",
                    "direction" : "EAST",
                    "connectedRoomId" : "3"
                },
                {
                    "doorId" : "1",
                    "direction" : "SOUTH",
                    "connectedRoomId" : "1"
                }
            ]
        },
        {
            "id" : "3",
            "text" : "The world outside is bright, you have escaped the dungeon!"
        }
    ],
    "startingRoomId" : "1",
    "endingRoomId" : "3"
}
Owner
HTTPChat
HTTPChat
TextStatistics - Get a text file wich contains English text

TextStatistics This program get a text file wich contains English text. The program analyses the text, and print some information. For this program I

2 Nov 15, 2021
An anthology of a variety of tools for the Persian language in Python

An anthology of a variety of tools for the Persian language in Python

Persian Tools 106 Nov 08, 2022
Parse Any Text With Python

ParseAnyText A small package to parse strings. What is the work of it? Well It's a module to creates parser that helps to parse a text easily with les

Sayam Goswami 1 Jan 11, 2022
The Levenshtein Python C extension module contains functions for fast computation of Levenshtein distance and string similarity

Contents Maintainer wanted Introduction Installation Documentation License History Source code Authors Maintainer wanted I am looking for a new mainta

Antti Haapala 1.2k Dec 16, 2022
Athens: a great tool for taking notes and organising knowldge

AthensSyncer Athens is a great tool for taking notes and organising knowldge. But it is a bummer that you cannot use it accross multiple devices. Well

6 Dec 14, 2022
Build a translation program similar to Google Translate with Python programming language and QT library

google-translate Build a translation program similar to Google Translate with Python programming language and QT library Different parts of the progra

Amir Hussein Sharifnezhad 3 Oct 09, 2021
Question answering on russian with XLMRobertaLarge as a service

QA Roberta Ru SaaS Question answering on russian with XLMRobertaLarge as a service. Thanks for the model to Alexander Kaigorodov. Stack Flask Gunicorn

Gladkikh Prohor 21 Jul 04, 2022
汉字转拼音(pypinyin)

汉字拼音转换工具(Python 版) 将汉字转为拼音。可以用于汉字注音、排序、检索(Russian translation) 。 基于 hotoo/pinyin 开发。 Documentation: http://pypinyin.rtfd.io/ GitHub: https://github.co

Huang Huang 4.2k Jan 03, 2023
Free & simple way to encipher text

VenSipher VenSipher is a free medium through which text can be enciphered. It can convert any text into an unrecognizable secret text that can only be

3 Jan 28, 2022
A program that looks through entered text and replaces certain commands with mathematical symbols

TextToSymbolConverter A program that looks through entered text and replaces certain commands with mathematical symbols Example: Syntax: Enter text in

1 Jan 02, 2022
"Complexity" of Flags of the countries of the world

"Complexity" of Flags of the countries of the world Flags (png) from: https://flagcdn.com/w2560.zip https://flagpedia.net/download/images run: chmod +

Alexander Lelchuk 1 Feb 10, 2022
Convert ebooks with few clicks on Telegram!

E-Book Converter Bot A bot that converts e-books to various formats, powered by calibre! It currently supports 34 input formats and 19 output formats.

Youssif Shaaban Alsager 45 Jan 05, 2023
Wikipedia Reader for the GNOME Desktop

Wike Wike is a Wikipedia reader for the GNOME Desktop. Provides access to all the content of this online encyclopedia in a native application, with a

Hugo Olabera 126 Dec 24, 2022
Username reconnaisance tool that checks the availability of a specified username on over 200 websites.

Username reconnaisance tool that checks the availability of a specified username on over 200 websites. Installation & Usage Clone from Github: $ git c

Richard Mwewa 20 Oct 30, 2022
Shows twitch pay for any streamer from Twitch leaked CSV files.

twitch_leak_csv_reader Shows twitch pay for any streamer from Twitch leaked CSV files. Requirements: You need python3 (you can install python 3 from o

5 Nov 11, 2022
Utility for Text Normalisation or Inverse Normalisation

Text Processor Text Normalisation or Inverse Normalisation for Indonesian, e.g. measurements "123 kg" - "seratus dua puluh tiga kilogram" Currency/Mo

Cahya Wirawan 2 Aug 11, 2022
Fixes mojibake and other glitches in Unicode text, after the fact.

ftfy: fixes text for you print(fix_encoding("(ง'⌣')ง")) (ง'⌣')ง Full documentation: https://ftfy.readthedocs.org Testimonials “My life is li

Luminoso Technologies, Inc. 3.4k Jan 08, 2023
🍋 A Python package to process food

Pyfood is a simple Python package to process food, in different languages. Pyfood's ambition is to be the go-to library to deal with food, recipes, on

Local Seasonal 8 Apr 04, 2022
A minimal python script for generating multiple onetime use bip39 seed phrases

seed_signer_ontimes WARNING This project has mainly been used for local development, and creation should be ran on a air-gapped machine. A minimal pyt

CypherToad 4 Sep 12, 2022
A pipeline for making highlighted text stand-alone.

title emoji colorFrom colorTo sdk app_file pinned decontextualizer 📤 green gray streamlit main.py false Decontextualizer As a second step in improvin

Paul Bricman 26 Dec 17, 2022