_______________________________________________________
|    ________                    __  ___                |
|   / ____/ /_  ____  ________  /  |/  /____ ____  ___  |
|  / /   / __ \/ __ `/ ___/ _ \/ /|_/ / __ `/_  / / _ \ |
| / /___/ / / / /_/ (__  )  __/ /  / / /_/ / / /_/  __/ |
| \____/_/ /_/\__,_/____/\___/_/  /_/\__,_/ /___/\___/  |
|_______________________________________________________|
The terminal-based maze and chase game

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:

jdown
kup
lright
hleft

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:

-cRun in chase mode.
-dRun 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!
-lList all the map files in the default location, along with a brief description if the map file makes one available.
-t secsReplace 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 tenthsReplace 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 mapfileUse 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:

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.