Final Project
Distributed Text-Based Adventure
Due dates may be found on the schedule.

Changelog

2024-12-14 15:10
Added a page explaining more about depth. It has no new information, but may make some things clearer.

As decided by roughly a ⅔ majority vote of those in class on November 7, our final project will be a distributed text-based adventure game in the spirit of Colossol Cave or Zork.

This page assumes you have implemented and understood the closely-related MP 10.

1 Initial files

You may start working on this project by copying your MP10 solution, renaming domain.py as newdomain.py, and modifying those files.

We provide starting files in project.zip:

You will need to submit a file named newdomain.py

2 Coding task beyond MP10

The sections below are outlined in the order we recommend completing them. First refactor your MP10 to allow multiple users, then implement /depart’s 409 responses, and so on.

2.1 Multiuser

Track one copy of game state for each user that /arrives.

Nothing that one user does should impact the game experience of other users.

Test multi-user experience by opening up two web UIs at once in separate browser tabs or windows.

  • If one user picks up an item, the other user still sees it where it was
  • If one user opens a door, flips a switch, or otherwises changes game state, the other user does not see that change.

New hub

Multiple users also requires some hub support not present in MP10’s hub. This support is present in hub.py found in project.zip.

2.1.1 Departure and re-arrival

When a user leaves the domain the hub will send you a /depart message with the user’s ID. You should refuse to answer commands from that user until they again /arrive.

The data provided to /arrive will include a new field, "from". This will be one of six possible values:

  • "login" if they just logged in and this is their first domain

  • "north", "south", "east", or "west" if they journeyed from that direction.

    In other words, if the user arrived after saying journey east, /arrive will get "from":"west".

  • "direct" if they journeyed to the domain by name or ID.

The entire domain should be accessible from any arrival type. Do not have puzzles that have to be solved by journeying to the domain from the north or have users coming from the east get different items than users coming from the west.

Journey limitations

The hub server will create a map of domains which may have borders or gaps. Because of this, journey south may return a response like You can't journey in that direction with neither a /depart nor an /arrive being generated.

Handle departures and arrival’s from different directions

  • Have a /depart endpoint that returns status 200.
  • If a user has /departed more recently than they’ve /arrived, return 409-status responses to all commands until they next /arrive.
  • Optionally, you may also use /arrive’s "from" to make your domain more location-aware.

New hub

/depart is not sent by MP10’s hub. It is sent by the hub.py found in project.zip. "from" is not sent by MP10’s hub. It is sent by the hub.py found in project.zip.

2.2 Creative Domain

Make a new domain, with multiple locations and items.

Verify that your domain

  • is unlike the MP 10 dmain
  • has 4 or more locations
  • has 4 or more items2 These all get sent to the hub during /newhub, including at least
    • 1 depth-0 item for other domains to host
    • 1 depth-1 item for other domains to host3 like the key in MP10
    • 2 no-depth items you host yourself4 like the paper in MP10
    • as many more items (either self-hosted or depth 0, 1, or 2) as you wish
  • has somewhere to store depth-0, depth-1, and depth-2 items5 These items are provided as "prize"s during /arrive
    • the depth-0 can be found from the domain itself6 like the item found in the classroom in MP10
    • the depth-1 can be found after getting the depth-0 item that was hosted elsewhere
    • the depth-2 can be found after getting the depth-1 item that was hosted elsewhere7 like the item found in the cabinet in MP10
    • You may have more than one location for the same depth if you wish; you’ll likely get several of the same depth to host.
  • has no lose scenario: each user can keep trying until they solve it
  • explains any allusions or outside knowledge that it requires

New hub

MP10’s hub doesn’t follow all the depth rules outlined above. They are followed by the hub.py found in project.zip.

The project’s hub.py will randomly pick one depth (either 0, 1, or 2) to give 2 items.

We have a page explaining more about depth

2.3 Completion and Score

When a user completes your domain, send the hub a /score message with value 1:

{ "domain": ... # your domain ID
, "secret": ... # your domain's secret
, "user": ...   # the user's ID as given in /arrive
, "score": 1.0  # the user's score in this domain
}

You are welcome to also give scores between 0 and 1 if you wish.

Keep and report score.

  • define a win condition
  • when a user wins, send /score with "score":1.0 to the hub

New hub

MP10’s hub doesn’t have a working /score endpoint. project.zip’s hub.py does.

2.3.1 Secret Areas

You may chose to add secret areas to your domain. A secret area has the following properties:

  1. It is not obvious from normal play that the secret even exists.

    You have some some clues, or can have it fully unadvertised.

  2. The content accessible via the secret is significantly smaller than the main part of the domain.

  3. Each secret a user discovers gives them +0.001 to their score, possibly exceeding the usual 1.0 maximum.

  4. A secret area cannot host items for other domains.

  5. Secrets areas have exceptions to some of the Creative Domain rules. Even if there are secret areas, those rules continue to apply outside of the secret.

2.4 Submit your code

The code you upload must match the code you run during the project checkoff.

Submit your code

3 Distributed Game design

3.1 Two-layer navigation

Each student VM will manage one domain. Each domain has multiple locations.

Travel within a domain is done with the go command and its six directions: down, east, north, south, up, west. Optionally, a domain may allow shortcut travel commands like go house The web front-end will automatically expand w or west to go west before sending it to the domain VM.

Travel between domains is done with the journey command and its four directions: east, north, south, west; or the number of any domain server (e.g. 567 to journey to the domain served by fa24-cs340-567.cs.illinois.edu); or the self-reported name of a domain, if that name is unique among all domains. These commands are managed by the central server and are not even sent to the domain server, though the hub will send the domain /arrive and /depart requests to let the domain know that the user journeyed.

It is recommended that each domain have one or more locations from which the request to go north gets the response $journey north, and so on for the other four cardinal directions. This is recommended, but not required.

3.2 Hosting other domain’s items

Each domain must provide at least one item of depth 0 and one item of depth 1 to the hub during /newhub to be hosted by other domains.

Each domain must have at least one of each of the following

The hub will put copies of each hosted item in more than one domain to protect against one getting lost in a misconfigured or impossibly-hard domain. The hub will remove all other copies from its internal tracking once one of the host domains /transfers the item to the user’s "inventory". Because of this, the following sequence is possible:

  1. A user /arrives with a given item in their list of prizes.
  2. The user journeys to another domain and gets that item there (this is invisible to your domain).
  3. The user /arrives again; the item is no longer in their list of prizes.

If you are tracking your own inventory, you should check for this condition to avoid giving them the same hosted item twice.

3.3 Duplicate item names

Item names are in general not unique.

It is quite possible that a user may get an item named "key" in domain 1, and another item named "key" in domain 2, and then travel to domain 3 and try to use key on lock without first getting domain 3’s "key".

Your domain should use the following conventions:

  1. Always allow users to specify items by id.

    Example: take 42 should take the item with id = 42.

  2. Allow users to specify items by unambiguous names.

    Example: take key should take item 42 if item 42 is the only item in the location with name key.

  3. Decide whether to have actions require item IDs or item names.

    Example: use axe on door probably makes sense to work with any item named axe.

    Example: use key on door probably makes sense to work only with one specific item named key.

  4. If the user does something that would have worked with a different item with the same name, give a response that makes that clear.

    Example: You don't have a key that fits this lock.

  5. If you need a specific item ID, make that item’s description sufficiently complex to likely be unique.

3.4 Multi-player

Each user will get their own copy of the entire game world. In other words, when I play the game, no part of my play experience should depend on what other players are doing.

The hub will track the following information about users:

  1. Their inventory.
  2. Items they have once held but since dropped, and where they dropped them.
  3. The set of domains they’ve visited.
  4. A completion score per domain provided by domains they’ve visited in the form of a number between 0 and 1.

This will be used to display a map and scoreboard.

3.5 Praise and Report

When a user finds something about a domain that they think is nifty, they can use the praise ... command to leave a comment for the designer of the domain. These comments have no impact on grades, but will be given to the domain developer after the course completes.

When a user finds something about a domain that they think is broken, they can use the report ... command to leave a comment for the course staff to look into. The report will be accompanied by the log of actions the user has taken. These reports may result in course staff removing points from the project based on failure to implement it correctly.

To help us review the reports, we will group them by their first word. The following opening words are predefined for specific purposes: