(Updated December 29, 2022)
The idea behind interactive fiction (IF) is to create a world in which the player is captivated by the need to use their imagination to determine the next step to winning the game. IF does not use graphics, it is entirely text-based, and the player is encouraged to take notes and perhaps draw a map of the world they are in.
Below are several of the most famous IF games ever released.
https://rickadams.org/adventure/maps/CaveMap.jpg
While there is a world of wonder waiting to be discovered by the player, there is but a simple interface – a basic command line.
This can be simulated with a simple EOF loop:
import java.util.Scanner;
public class CommandLine {
static Scanner kb = new Scanner(System.in);
public static void printStringParts(String t) {
String[] parts;
parts = t.split(" ");
for (String s : parts)
System.out.println(s);
}
public static void main(String[] args) {
String s;
System.out.print("> ");
while (kb.hasNext()) {
s = kb.nextLine();
printStringParts(s);
System.out.print("> ");
}
}
}
What we do with those commands after they are typed is part of the magic that is hidden from the player. How does it translate the statement into actions, and how are they applied to the world in which they are immersed? Well, that is what we will dive into as we cover each subsequent topic.
Concepts related to lexical and syntax analysis will be covered. These are the beginning topics related to interpreters and compilers. We will only be covering a small amount of knowledge in these areas, but it will reveal how these tools get the job done.
We will also delve into world-building and hash out a simple means by which we can manage the world. The player, their location, objects, and people they encounter, and how they are allowed to interact will be explored.