I7: Testing Games with Random Elements

I have never before had much call to use the skein for testing, but I am currently working on a fairly sizeable game which is somewhat linear, so that a fair amount of playing needs to be done before one reaches the point in the game which is controlled by the code I am now writing. It would facilitate testing immensely if I could quickly play past the earlier stages of the game, so that I could test the new material. It sounds like this is the type of thing that the skein should be useful for.

The difficulty is that the earlier portion of the game (i.e., that part I want to play past without manually typing in every command) has some random elements. Specifically, there is an event which may or may not occur; if it does occur, there is some random variability in when it occurs. Depending on whether it happens, and, if so, when, the sequence of commands that the player needs to type will differ significantly. However, eventually, the divergent play paths once again converge. The portion of the game that I am currently writing (and for which I would like to facilitate testing) is past the “re-convergence” point.

Other than using the skein to play to the first “break-point” and then playing manually after that, can anybody suggest an approach to testing which would allow me easily to play to the point I want to test, in effect bypassing the earlier divergent paths which would depend on the random factors?


Robert Rothman

See section 8.18 of the documentation for a couple of ways you could do this – you could write a line to seed the RNG while testing, or use an option in the Settings panel to fix the RNG while you’re playing in the IDE.

Thanks. That sounds like exactly what I need.

Robert Rothman

Another angle is to program cheat(s) into the game.

If there are lines which randomly decide when these major random events happen, and what is their nature, add a line of code right after each decision is made which directly sets the outcome to your desired result, thus overriding the random decision.

To remove a cheat, you can just [comment it out by sticking braces around it like this.] And in a comment with each cheat, put the word ‘cheatz’ (or something else completely distinctive.) When you want to toggle cheats on or off, you can search for the word ‘cheatz’ in your source to jump to them, then can bracket or unbracket them.

This approach is a little manual labory, but ultimately it can be necessary for certain tests, especially to test each of a set of possible circumstances in turn.

Also, you can add cheats that you can access from in-game. Just program cheat commands into a section with a heading like:

Book - My Cheats - Not For Release

This will compile in the IDE, but not in releases.

Finally, don’t forget that you can set random outcomes to go the same way every time (based on one compilation of the game - if you recompile, you get a new set of outcomes which doesn’t change until you compile again, etc.) by ticking that checkbox in the ‘settings’ panel of Inform.