Skip to main content

Play ai dungeon from your terminal

Project description

AI Dungeon CLI

This is basically a cli client to play.aidungeon.io.

This allows playing AI Dungeon 2 inside a terminal.

I primarily did this to play the game on a DEC VT320 hardware terminal for a more faithful experience.

For more context, read the accompanying blog post.

AI DUngeon on a VT320

Installation

pip

PyPI version fury.io

$ python3 -m pip install ai-dungeon-cli

Of for unstable release from the source code:

$ python3 -m pip install .

Arch Linux

AUR version

Package is on AUR.

Using trizen:

$ trizen -S ai-dungeon-cli-git

Old school way:

$ git clone https://aur.archlinux.org/ai-dungeon-cli-git.git
$ cd ai-dungeon-cli-git
$ makepkg -si

Playing

Unless specified, all user inputs are considered Do actions.

Quoted input entries are automatically interpreted as Say actions, e.g.:

> "Hey dragon! You didn't invite me to the latest BBQ party!"

Do be explicit about the action type, prefix your input with a command:

  • /do
  • /say
  • /story
  • /remember

For example, the previous Say prompt could also be written:

> /say Hey dragon! You didn't invite me to the latest BBQ party!

To quit, either press Ctrl-C, Ctrl-D or type in the special /quit command.

Running

In any case, you first need to create a configuration file.

Installed

$ ai-dungeon-cli

From source

With a conda env (assuming you're using anaconda):

$ cd ai-dungeon-cli
$ conda env create
$ conda activate ai-dungeon-cli-env
$ ./ai_dungeon_cli/__init__.py

With a viltualenv:

$ cd ai-dungeon-cli
$ virtualenv -p $(command -v python3) ai-dungeon-cli-venv
$ source ai-dungeon-cli-venv/bin/activate
$ python3 -m pip install -r requirements.txt
$ ./ai_dungeon_cli/__init__.py

Please note that all those examples use a virtual env in order to not mess up with the main Python env on your system.

Configuration (optional)

Several things can be tuned by resorting to a config file.

Create a file config.yml either:

  • in the same folder in your home folder: $HOME/.config/ai-dungeon-cli/config.yml
  • in the same folder as the sources: ./ai-dungeon-cli/ai_dungeon_cli/config.yml

Authentication

By default, if no authentication configurati is provided, an anonymous session is created.

ai-dungeon-cli supports 2 ways to configure user authentication.

Either precise a couple of credentials in conf:

email: '<MY-USER-EMAIL>'
password: '<MY-USER-PASSWORD>'

Or sniff a Authentication Token and use it directly:

auth_token: '<MY-AUTH-TOKEN>'

To get this token, you need to first login in a web browser to play.aidungeon.io.

Then you can find the token either in your browser localStorage or in the content of the connection_init message of the websocket communication (first sent message).

Either way, developer tools (F12) is your friend.

Prompt

The default user prompt is '> '.

You can customize it with e.g. :

prompt: 'me: '

Slow Typing Animation

By default, responses are printed to the screen instantly.

To enable a fun "slow" typing animation, use:

slow_typing_effect: True

Dependencies

Please have a look at requirements.txt.

Limitations and future improvements

Right now, the code is over-optimistic: we don't catch cleanly when the backend is down.

A better user experience could be achieved with the use of the curses library.

For now /revert and /alterspecial actions are not supported.

It would also be nice to add support for browsing other players' stories (Explore menu).

Implementation details

We fallback to a pure ASCII version of the splash logo if we detect an incompatible locale / terminal type.

Support

As you might have heard, hosting AI Dungeon costs a lot of money.

This cli client relies on the same infrastructure as the online version (play.aidungeon.io).

So don't hesitate to help support the hosting fees to keep the game up and running.

Author

Jordan Besly @p3r7 (blog).

Contributors & acknowledgements

Major contributions:

  • Idan Gur @idangur: OOP rewrite of game logic
  • Alberto Oporto Ames @otreblan: packaging, submission to AUR
  • @jgb95: slow typing effect
  • Alexander Batyrgariev @sasha00123: help on porting to new websocket/gql-based version of the API

Minor contributions:

  • Robert Davis @bdavs: pip requirements
  • @Jezza: suggested login using creds

Code for slow typing effect inspired by this message from Magnus Lycka on the Python Tutor mailing list.

Similar projects

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai-dungeon-cli-0.4.0.tar.gz (13.7 kB view details)

Uploaded Source

File details

Details for the file ai-dungeon-cli-0.4.0.tar.gz.

File metadata

  • Download URL: ai-dungeon-cli-0.4.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for ai-dungeon-cli-0.4.0.tar.gz
Algorithm Hash digest
SHA256 dedbf91cd99127443c4c2d1729940639646f103d5b900304b697ad471e56554c
MD5 8f6562f45bb2469590eb2d19e382afbe
BLAKE2b-256 3d36baf1dac2a2e94f434610e1e1f196ba6d5a083ed28f52c7657387ac94e3b8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page