chasemaze: Escape from the maze! Catch the target!
Chase! Escape from a maze! The user (appearing as @) must reach the target (appearing as *). How he gets there is the fun!
NOTE: I have recently become aware that integer overflows can sometimes cause security problems. I do not think this is a likely problem here, but I don't have the bandwidth or knowledge needed to guarantee it. So, as always, use at your own risk.
Gameplay
chasemaze is a simple, terminal-based game of escaping and hunting. It is extremely simple, yet often challenging and a lot of fun!
Your character is the @; your goal is the *. You move it around by using the bog-standard arrow-key substitutes that are common in so many programs:
j | down |
k | up |
l | right |
h | left |
In maze mode, the target is stationary and the user attempts to navigate whatever obstacles the map file presents to him. He might get trapped and be unable to win, or he might find his way to the end and take the target, resulting in a victory.
In chase mode, the target is mobile, and the user attempts to chase it down and catch it before it moves again. The target will move to a random point on the board every 2.5 seconds; however, this can be changed via command-line options to any period of seconds and tenths of a second that the user desires.
In hard mode, which is available in both maze and chase modes, the game works the same way, but the user cannot retread any space he has already occupied. This makes things considerable harder. Hard mode is activated by a command-line switch at run time.
Screenshots
The first screenshot we'll look at is with the built-in map file maze_one, which is (obviously) intended to be used in maze mode:
Here, we can see the player (@) a little more than halfway down from the top and a fifth of the way from the left, attempting to navigate the maze. The target, or victory point (*) is in the upper right corner. Clearly, our player has a long way to go!
Our next screenshot will be using the build-in map file chase_one, which is (also obviously) intended to be used in chase mode:
The emphasis in chase-mode maps is, of course, different. Here we have a few obstacles to make it harder to zip from one side of the screen toward the other. The player character (again, @) is toward the bottom left, while the target (*) has now bounced over to the upper right. He'd better move quickly if he wants to get it before it moves again!
Of course, while chasemaze can open any map file you give it, it has a default location for its map files ($HOME/.config/chasemaze/); you can ask chasemaze to print a list, along with a description if one is available:
And now you know everything you need to know to play the game!
Running the Game
So if you want to play chasemaze, how do you actually do it?
Once you've installed the game (if you don't have a package for it, then download the source code) and go into the source directory. Then, type "make" and enter; then, using sudo or whatever privilege-escalating means you have at your disposal, type "make install" and enter. And you will have a fully functional chasemaze installation. It's that simple.
Once you have a chasemaze installation, you can run the game just by typing "chasemaze". This will give you a blank mapfile, and by default will be in maze mode. For more interesting play:
-c | Run in chase mode. |
-d | Run in hard mode (difficult mode). Remember that this mode means you cannot go back to any location you've already been; those locations will be marked appropriately. This, obviously, makes the game considerably harder! |
-l | List all the map files in the default location, along with a brief description if the map file makes one available. |
-t secs | Replace secs with the number of seconds you'd like to elapse before chasemaze moves the target when in chase mode. The default is 2. |
-T tenths | Replace tenths with the number of tenths of a second you'd like to elapse before chasemaze moves the target when in chase mode. This will be added to the number of seconds which will elapse. The default is 5. |
-f mapfile | Use the mapfile named. chasemaze will look for the named mapfile first in the current directory, and then in the directory $HOME/.config/chasemaze. If it cannot find the map file in either place, it will complain and quit. |
Map Files
chasemaze allows the user to use any arbitrary map for his game. These files can contain any ASCII characters, and there is no requirement that they even be possible to win. However, there are a few requirements for chasemaze to understand and use these files:
- The mapfile must be exactly twenty-three lines long. (Shorter, and chasemaze will object to it and quit; longer, and any line after the twenty-third will be silently ignored.)
- Each and every line of the mapfile must be exactly eighty (80) characters long. If any line is not this long, chasemaze will object and quit, telling you which line it choked on and whether it was long or short.
- There must be some place in the map file for the player character to go. If you don't put the player's start point in explicitly, chasemaze will do its best to find a good place; but if it isn't able to do so, it will complain about this and quit.
- There may be, optionally, extra lines after the twenty-third. This is a good place to credit whomever made the map. Also, you can include a description which will appear when you ask chasemaze to list the mazes available to it. If you include the string "DESC:" (without the quotes), the remainder of the line after the colon will be the description that appears. E.g., "DESC: an impossible maze" in the file "hellomaze" will print "hellomaze: an impossible maze" when you run the list. Otherwise, it will appear merely as "hellomaze"; useful, but not very helpful.
And that is it! chasemaze comes with a few maps: chase_one and maze_one, intended to be used in the modes which their names suggest, and a few more auto-generated mazes. On installation, they are placed in the user's home config directory; specifically, in $HOME/.config/chasemaze/. When you ask chasemaze to use a map file, it will look first in the current directory, then in the above config directory for said file. If it cannot find it, it will complain and quit.
There is no fundamental difference between maze map files and chase map files. Obviously, the intended game play may make designers do different things, but any map file can be used in either game mode. Sometimes, using a map in a different game mode can significantly increase the challenge!
Technical Stuff
chasemaze is written entirely in standards-compliant C code with no external libraries whatsoever; that is, every part of the system should work on any Unix-based system without having to install anything other than the game itself.
It is usual to use ncurses when writing code that has lots of printing at arbitrary points in the terminal, but I was hoping to learn something about terminal handling, so I did not use it. I'm not sure I learned much of anything about the back-end terminal stuff; however, I did learn how to manipulate ANSI-compliant terminals using ANSI-compliant code, and I'm pretty happy about how it turned out.