AI for IF games – question about different kinds of IF games

The idea is that you do some in-game diagnostic actions to figure out how the character corresponds to the booklet, and then figure out how to handle them. The source code is also available ( ).

(And yes, that’s all the types – the feelie is basically a formatted and slightly spoiler-reduced version of the actual in-code table of characteristics.)

Hi. A little more info about Six that may help. In the first round, 4/6 kids can mostly be tipped with a set sequence of commands (there could be some minor random decisions about where they’re strolling to that block a verbatim walkthrough, but it wouldn’t vary much). In round 2, only 1/6 can be tipped this way. After that it’s basically search and play by ear to locate everybody. They will all have started in different places, gone to different places, plus there are other timing and random elements that will have been scrambled or be turning on and off over time.

Something else that may help in AI-dom is that a lot of events in Six randomly present with slightly different prose in different games.

The score system remains elementary in any case - 1 point per person, and at 6 points you win.


Thank you very much Wade, I completely forgot about the second round even though I knew it was there. Some randomness in description is also very useful. This is great news, then, thanks again :slight_smile:

As for the scoring system – the AI could be penalized for every step it took and that could be used as a secondary scoring function, i.e. it would be rewarded for tipping as many players as possible but also for tipping them faster.

I have some technical issues/questions now, so before I post them to the apropriate section, I’d just like to get the basics right – I’m not that well acquainted with the various systems and platforms, so please feel free to correct me if I’m wrong:

This would indeed be ideal. The problem is:

  1. Six is distributed as a Glulx game and therefore requires a Glulx interpreter (such as Glulxe) which (dumb)frotz doesn’t support (it only runs Z-machine files).
  2. Child’s Play is compiled for Z-machine yet when I tried loading it with the latest Windows version (2.44) of dumbfrotz, it didn’t work (‘Unknown Z-code version when loading…’).

Since I would potentially like to use both Z-machine and Glulx games, I’m not sure what would be the easiest way to support both. I suppose there isn’t any general interpreter. I only need a very simple stdin/stdout interpreter without any GUI. Or could this issue be perhaps solved by recompiling the selected games for only one of the platforms (this would obviously limit me to games with available compilable source which for example Six isn’t if I chose Z-machine)?

For Z-machine, I only found dumbfrotz, which doesn’t seem to work so far (but maybe I’m doing something wrong?).

As for Glulx, there are a lot of different packages and layers that confuse me – I’m not sure if cheapglk is what I’m looking for (it might be). I’m also unsure whether the Windows CLI version mentioned here on the forums of Git is what I’m looking for: … sXgit.html

To paint the bigger picture, I would like to create an API in Python between IF games (their interpreters, to be precise) on one side and AI controllers (neural networks, …) on the other side.
So what my API would need from the IF interpreter would simply be:
– loading a game file with a specified random seed (this is important)
– writing user input to the game (via stdout)
– reading the game output (doesn’t matter if in a structured-data way or in plain text) (via stdin)
– detecting the state of the game when relevant (score, ending, …) (some signals/flags, I suppose)

So the question is: is there an equivalent of dumbfrotz for Glulx game files? Should this version of dumbfrotz be working with Child’s Play (I would submit a github ticket if I was sure there was a bug but I’m really not :))?

I’ve been setting up a much MUCH simpler equivalent of this recently (for regression testing on Scroll Thief) and Git+cheapglk has been working wonderfully. For the randomness you could alter terp.c, in which there are two calls to srand(time(NULL)) - those are the only places where real unpredictability comes in.

You might find pages 2 and 3 of this thread about automated testing of glulx and zcode games from a python script using glulxe+remglk (glulx) and fizmo+remglk (zcode) to be helpful. The same approach that the test script uses to send game input to and receive game output from a remote interpreter process could be used by your AI controller.

If you decide you want to use the same interpreter for all Inform games, I think most z-machine games could be compiled to glulx. But glulx games may be too big to compile to z-machine.

Yes, and it is compiling glulxe with the cheapglk front end. You were on the right track.

Thank you :slight_smile: Are there any differences between Git and glulxe that might be relevant for me? As mentioned, I only need the interpreter to be fast (I read that Git was faster than glulxe) so that it doesn’t become a bottleneck, and I need it to support custom random seeds.

Thank you, this should come in really handy. Although I’m having some problem with Python subprocess management – what I would like is a continuos interaction rather than sending a fixed list of commands – but that is another story :slight_smile:

Alright, cheers, I’ll work in glulx first, then.

Thanks, I managed to compile glulxe with cheapglk on Linux now. How can I work with random seeds, please? Is it possible at all? I found some external functions in the code, but how do I call them? As far as I can tell, seed can’t be specified as a parameter when launching glulxe (which is what you can do in dumbfrotz).

I don’t know anything about specifying parameters from glulxe, but if all else fails, it should be very easy to add a few lines to the game’s code that will let you specify whatever seed you want via a command.

Edited to add:

Something like

[code]Seeding with it is an action out of world applying to one number. Understand “seed [number]” as seeding with it.

Carry out seeding with it:
seed the random-number generator with the number understood.[/code]

should let you use the command “seed 1234” (or whatever the number is) to seed the random number generator. (In an Inform 7 game.)

It will require some changes, but it shouldn’t be a problem. If you look at run() in, you’ll see the core of how the interaction with the remglk-enabled interpreter works:

        gamestate.initialize()    # tell interpreter to begin
        gamestate.accept_output()    # receive game's initial output
        for cmd in cmdlist:
            gamestate.perform_input(cmd)    # send "player's" command
            gamestate.accept_output()    # receive response to command

You’ll want to do something like:

        while not game_over(gamestate):
            cmd = ai.choose_next_action(gamestate)

Obviously, many details left as an exercise for the reader.

You can do this at several layers of the system. If you have game source code, it’s probably easier to do it at the game level than the interpreter level.

The simplest option is to compile an Inform 6 or 7 game with debugging enabled and use the random command at the input prompt:

This sets the seed to a specific number (100). If you want a known seed, this is all you need.

If you want to choose your own seed, you can do one of:

I6 z-machine (see §1.14 of the DM4):

[ SetSeed a_seed;
  random(-a_seed);  ! pass -x to set the seed to x

I6 glulx (see §2.14 of the glulx spec):

[ SetSeed a_seed;
  @setrandom a_seed;

I7 (see §8.18 of Writing with Inform):

seed the random-number generator with 42;

With these techniques, you could do as bg suggests and implement a command, similar to the ‘random’ debug cmd above, that would allow the player to set a seed from the command prompt (or via remglk from python). Ask on the Inform dev forum if you need help with this.

Thank you both :slight_smile:

The thing is I would ideally like my framework to be universal in the sense that you can supply any game to it and it would offer the whole API for them. Which is why it would be really nice to have the random seed setting at the interpreter level (instead of having to compile every game). I suppose that I could add a -s launch parameter to glulxe, but then again, it wouldn’t guarantee the corret seed anyway, since the games can change it themselves. So a game-by-game check would be needed anyways.

You could make it guarantee the correct seed. There’s a specific Glulx opcode to seed the random-number generator; you could alter Glulx so that if the game passes “0” (meaning “be actually random somehow”) it uses your interpreter-level seed.

Hello everyone,

as mentioned in this post, I’m currently looking for purely choice-based or hypertext-based (i.e. no parsing) with multiple endings (two or more).

I’m having trouble finding such games; on IFDB, I can’t seem to find a tag related to choice-based and hypertext-based games: … g%3Achoice

The “choice” tag isn’t really what I’m looking for. I do know about the choicescript games, but these are mostly commercial if I understand that correctly.

Edit: The hypertext tag did help: … Ahypertext
Games such as Taghairm, HUNTING UNICORN or others from that list could hopefully work for me, but any suggestions are still very much welcome!

Any tips on either concrete games (got Saving John and Machine of Death so far) or tags on IFDB that could be helpful would be greatly appreciated :slight_smile:

I find it useful to search for system:twine to find Twine games.

Or you can try subtracting parser games by -system:inform -system:quest -system:tads -tag:infocom, sorted by most ratings (most ratings is a better measure of quality than highest ratings)

Here’s a link to that search: link

The CYOA tag (like a choose-your-own-adventure) is often used for choice-based works.

cyoa AND multiple endings

You could possibly try searching for the “time cave” or “time-cave” tag, which means the game and plot diverges massively based on choices made.

Thank you very much for your suggestions, they were really helpful.

In the end, I implemented four additional games in the pyfiction library and it should be easy to add more games in the future.