Skip to content

nferraz/gpt-adventures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

GPT Adventure Game Engine

This is a text adventure game engine that uses an AI language model to generate all game elements (plot, locations, objects, etc).

For example:

The Quest of the Lost Talisman

You are a brave adventurer who has been called upon to save the
kingdom from an evil sorcerer who has stolen the talisman that holds
the key to immortality. You must journey through treacherous terrain
and overcome many obstacles to retrieve the talisman and save the
kingdom.

Type your instructions using one or two words, for example:

> look
> take $object
> look at $object
> inventory
> go north
> drop $object
> ?

What do you want to do?

Every detail in the game is generated by a LLM (gpt-3.5-turbo by default).

Playing

The player will be prompted to interact with the game by typing commands. The game will then respond to the player's commands with text generated by OpenAI's language model.

The game engine includes the following default actions:

  • look: Describes the current location.
  • look <object>: Describes that object.
  • take <object>: Take an object if it is in the same room.
  • drop <object>: Drop an object if the player is carrying it.
  • go <north|south|east|west>: Move to a different location in the game.
  • help: Displays a list of possible actions.

For any other action, the game engine will delegate the response to the language model, which will act as a game master, providing a response and modifying the game state as necessary. (See function: magic_action)

Game Structure

The game structure object contains a title, plot and entities (player, locations, and objects).

Each entity has a type, a position, a short description, and a long description. Locations also have exits ("north", "south", "east", "west").

Modifying

The script can be extended by modifying the GAME_TEMPLATE, the prompts or by adding additional game actions.

AUTHOR

Nelson Ferraz (@nferraz)

DEVELOPMENT / SUPPORT

This module is developed on GitHub.

Send ideas, feedback, tasks, or bugs to GitHub Issues.

About

A text adventure game engine based on GPT-3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages