I’ve been working on such a project, as I hinted recently. It is now up and running on the IFTF Discord server in the #zarfbot-9000 channel.
Feel free to jump in and try it. Be respectful if the channel is already in use; the bot can only play one game at a time in the channel. If the channel is not in use, switching games is easy.
The bot’s system commands are Discord slash commands. Game actions are regular channel messages that start with >. That is, you just type >get lamp in the channel to play.
/install URL to install a game. Currently supports Z-code and Glulx (and zblorb and gblorb) only. (Why? See below.)
Once the game is installed, type /start to launch it and view the opening text.
/status to display the current status line.
/games to list the currently installed games.
/select GAME to select a different game. If people have played that game before, you will wind up in the already-running session.
/newsession GAME to select a game and start a brand-new session. (A session is basically an autosave state and a collection of save files.)
/sessions to see a list of sessions. The session which is active in the channel will be marked.
If a game gets really stuck, /forcequit to clobber the session. You will then have to type /start again.
In-game commands like >save should work. You’ll be asked to enter a filename as a second input. Type /files to see all save files in the current session. (Not including the autosave, which you get for free.)
There are likely to be many bugs. Please report them! One big bug is that undo is busted in Z-code games.
If if gets more popular on the IFTF server, we can talk about adding more play channels (#zarfbot-9001!)
I have no idea how many simultaneous sessions it can handle, is the problem. It’s currently running on a Mac Mini, which is pretty beefy, but it’s on my home wifi – not a server-grade network connection. I will eventually want to transfer it to an IFTF machine, which will have better connectivity but much less CPU and RAM.
So I’m not opening the bot up to install on any Discord instance. It will be available only on the IFTF instance and a few associated IF communities.
However, the bot is open source, so anybody can run their own copy (and install that on their own Discord instance). The code lives at https://github.com/iftechfoundation/discoggin.
How does this bot differ from previous IF Discord bots?
It runs interpreters with a RemGlk wrapper using autosave and the -singleturn option. This means that the interpreter is not a persistent process. When you type a command, the bot launches the interpreter which (a) autorestores your position from disk; (b) accepts the command; (c) hands the output to the bot; (d) autosaves; and (e) shuts down. By the time you see the output on the Discord channel, the interpreter has already exited.
This means there is no RAM or CPU cost for a session in between game turns. We could have a hundred or a thousand game sessions going on. It’s all static autosave files until a command arrives. The only resource limit is how many commands the bot can execute per minute.
(In fact I’m going to clean out old sessions if they haven’t been played in, say, 30 days. But I haven’t written that cleanup code yet!)
The down side is that only Glulxe and Bocfel are currently supported.
You can’t link just any old interpreter with RemGlk and hand it to the bot. Autosave is a major piece of interpreter engineering. I did the autosave work for Glulxe a few years ago. Bocfel supports autosave, but not in the exact way the bot needs; I had to do a fair amount of surgery to get it to work. (Currently in this fork. I am currently talking with Chris about turning that into PRs for Bocfel.)
I am interested in getting other interpreters up to speed, but I probably won’t be able to dedicate time to anything beyond Bocfel and Glulxe. If you’re interested in helping with another one, let me know.
It strikes me that it would be very easy to support Ink games. The InkJS library is perfectly happy to run one turn at a time and autosave after every turn.
However, InkJS runs on an Ink .json file, which is not how Ink games are usually distributed.
(Is there an easy way to extract the .json game definition from, say, one of the games in Index: if-archive/games/ink ? It looks like there’s usually a JSON file somewhere in there…)
Hmm… I think the Inky editor names the game data file after the game name, rather than having a consistent name.
It’s a JS wrapper, not direct JSON, so you could look for a .js file starting with var storyContent = and then grab everything after that? (minus the trailing semicolon?)
And it won’t be main.js (the web runner interaction code) or ink.js (the ink runtime engine)…
I’m curious if it can record transcripts…I guess I could just try it, but I don’t want to break anything. (Or do you want people to try things that might break it?)
Edit: It looks like the transcript question was already answered on GitHub:
you can create a transcript, but there is no way to view it.
/recap works now. Although you can’t recap any further than this afternoon, because that’s when I installed the new code that records a transcript to recap. :)
This only shows you the last few moves – it’s not a full transcript. I suspect I will want a way to download transcripts and save files directly from the bot server, rather than trying to push large files (or binary files) through Discord.
Ok, I’ve tried it, and it works great… a somewhat simplistic question… Does everyone see everyone else’s game play with the bot, or is it a separate conversation with each player? I assume to have a hundred sessions going on, you’d need separate channels or conversations to keep it from becoming a very confusing channel. (
Ink games which rely on external functions or a web framework will not work. This is a plain unornamented Ink runner.
Some Ink games (including Arkuwar) include inline HTML tags, because the output is meant to be written raw into a web page. The bot doesn’t try to translate these tags, so you’ll see them as written. Sorry.
Are Dialog games supported? (I would assume that if an interpreter can play Z-code games, it should be able to play Dialog games that have been compiled to Z-code, but I have heard that is not true of Floyd, so maybe it’s not a safe assumption?)