home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
forum16.lzh
/
SOFTWARE
/
C
/
PUZZLE15
/
puzzle15.doc
< prev
Wrap
Text File
|
1990-01-07
|
8KB
|
199 lines
PUZZLE15(6)
NAME
puzzle15 - simulate a well known toy with many variations
SYNOPSIS
puzzle15 [<width[x<height>]] [movemethod] [cursormethod]
[facemethod]
DESCRIPTION
_P_u_z_z_l_e_1_5 simulates a game that is available in many toy
shops. This computerized version is crt-oriented and offers
fewer possibilities for cheating.
When invoked without arguments _p_u_z_z_l_e_1_5 presents a 4 by 4
grid with 15 numbered tiles and one empty square. The tiles
are not ordered in sequence. The tiles adjacent to the
empty square can exchange places with the empty square. This
is done by indicating the direction that the empty square is
to move with the vi(1) cursor keys (k for up, j for down, h
for left and l for right).
The intention of the game is to rearrange the tiles in their
``natural'' sequence.
The program keeps track of the time and the number of moves
used. This makes it possible to arrange competitions where
time, or the number of moves used determines the winner.
The program ends when the tiles are arranged in sequence, or
when you type your interrupt character (usually ctrl-C or
break). On computers that lack good support for keyboard
interrupts a key can be selected that will terminate the
program. (This is a compile-time option.)
VARIATIONS
The look and feel of the program can be altered by specify-
ing different dimensions for the array, the way that the
tile to move is selected (movemethod), the keys that specify
where the cursor is to go (cursormethod) and the faces that
are shown on the tiles (facemethod).
DIMENSIONS
The dimensions of the board can be varied within the limits
of your terminal screen. To obtain a square array a single
numeric argument is required. _P_u_z_z_l_e_1_5 _3 presents a 3x3
array with 8 numbered tiles. With numbered tiles it is not
possible to extend the array beyond 10 by 10, because only
two digits are used to identify each tile.
To obtain a non-square array an argument that consists of a
number, the character 'x' and another number must be sup-
plied. _P_u_z_z_l_e_1_5 _6_x_3 presents a grid that is 6 columns wide
and 3 rows high with 17 numbered tiles.
1
PUZZLE15(6)
MOVEMETHODS
The default movemethod is to indicate the direction that the
empty (blank) field is to move. This is called _m_o_v_e_b_l_a_n_k.
There are two other methods that can be selected by an argu-
ment on the command line.
_M_o_v_e_t_i_l_e tells _p_u_z_z_l_e_1_5 that you want to indicate the direc-
tion that an adjacent tile is to be moved. This is
equivalent to reversal of the directions of the cursor keys.
_S_e_l_e_c_t_t_i_l_e tells _p_u_z_z_l_e_1_5 that you want to indicate the new
position of the empty field by moving the cursor to that
position and then typing a <space>, or <return> (or whatever
you like). In this way you can move several tiles in one
blow.
CURSORMETHODS
The default way to move the cursor or the empty field is to
use the vi(1) cursor keys.
On some computers it is possible to specify _a_r_r_o_w_k_e_y_s, which
tells _p_u_z_z_l_e_1_5 to use the arrow keys of your terminal to
specify a move.
If you specify _n_u_m_b_e_r_k_e_y_s on the command line, _p_u_z_z_l_e_1_5 will
use '8' for up, '2' for down, '4' for left and '6' for
right. this corresponds to arrows on the numeric key pad of
most personal computers.
Another way to specify where the empty field is to go is
obtained by specifying _f_a_c_e_k_e_y_s on the command line. In this
mode you move the empty field to a new position by typing
the character(s) shown on the tile that currently occupies
that position. _F_a_c_e_k_e_y_s implies use of the movemethod
_s_e_l_e_c_t_t_i_l_e. If the _f_a_c_e_k_e_y_s cursormethod is used with num-
bered tiles, some tile numbers are shown with leading zero.
To select such a tile a leading zero is required. Tiles
that are labeled with a single digit can be selected with
that digit, or with a leading zero followed by that digit.
Finally you can specify your own cursor movement keys with
_k_e_y_s <_u_p><_d_o_w_n><_l_e_f_t><_r_i_g_h_t> on the command line. <Up> is
the key that you will use to move up, etc.
FACEMETHODS
The default way that _p_u_z_z_l_e_1_5 uses to identify the tiles is
to number them. If you prefer tiles that are marked with
letters you must specify _a_l_p_h_a_f_a_c_e_s on the command line.
_P_u_z_z_l_e_1_5 will now use the lower-case letters a..z to iden-
tify the tiles.
Similarly, if you specify _n_u_m_b_e_r_a_l_p_h_a_f_a_c_e_s _p_u_z_z_l_e_1_5 will use
the digits 0..9 followed by the lower-case letters a..z to
identify the tiles.
_A_l_p_h_a_n_u_m_b_e_r_f_a_c_e_s selects the lower-case letters a..z fol-
lowed by the digits 0..9.
Finally, you can specify the characters to use on the com-
mand line with _f_a_c_e_s <_f_a_c_e_c_h_a_r_a_c_t_e_r_s>. The order in
<_f_a_c_e_c_h_a_r_a_c_t_e_r_s> will be used to determine when the tiles
2
PUZZLE15(6)
are ordered.
EXAMPLES
_p_u_z_z_l_e_1_5 _f_a_c_e_s '_1_2_3_4_5_6_7_8_9_0_q_w_e_r_t_y_u_i_o_p_a_s_d_f_g_h_j_k_l;_z_x_c_v_b_n_m,.'
_1_0_x_4
creates a 10 by 4 array filled with the symbols of a type-
writer keyboard. The position to achieve is the ordering of
the keys on the typewriter. Quoting is necessary to prevent
the shell from treating the ``;'' as a special character. By
adding the option _f_a_c_e_k_e_y_s the program turns into a tough
typing tutor, especially if you decide not to take your eyes
off the screen.
DIAGNOSTICS
An unknown keyword or an illegal combination of keywords on
the command line generates a complete list of possible key-
words and restrictions on their combinations.
If you type an undefined key during the game, the program
lists the keys that are valid.
On startup fatal diagnostics from the curses screen handling
package are possible if your terminal is ill-defined.
If the program detects an internal error a diagnostic start-
ing with the letters _a_a_r_g_h: is printed. If you manage to get
one of these, I like to know how you did it.
AUTHOR
P. Knoppers - knop@duteca.UUCP.
Paul Lew added arrow keys.
Bo Kullmar added the clock and the move counter.
Larry Hastings suggested the selecttile method.
COPYRIGHT
The _p_u_z_z_l_e_1_5 program is protected by copyright (C) 1984,
1988, 1989 by P. Knoppers. Distribution of unmodified copies
of the program with source is unrestricted. You are not
allowed to distribute modified copies. This is to prevent
uncontrolled spreading of a zillion different versions. You
can mail suggestions for improvements to me. I _m_a_y incor-
porate them in a future version.
3