home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMIGA PD 1
/
AMIGA-PD-1.iso
/
Programme_zum_Heft
/
Programmieren
/
Kurztests
/
ACE
/
Prgs
/
games
/
SerStratego1.5.lha
/
stratego
/
StrategoDocs
< prev
next >
Wrap
Text File
|
1994-08-21
|
21KB
|
444 lines
Serial Stratego Version 1.5
Written By: Daniel Oberlin
I. INTRODUCTION
Serial Stratego is a program I wrote which allows Stratego to be played on two
computers linked by a serial connection. The game Stratego is a strategic
board game marketed by Milton Bradley. In this implementation, a serial
connection can be made by null-modem (direct serial connection), modem, or by
logging onto a networked computer and using UNIX or INTERNET resources such as
Talk, Write, or even IRC (Internet Relay Chat). The program communicates by
sending packets which are encoded using standard printable ASCII characters
(like uuencode, see technical section for more information). It filters out
all other characters, including anything which is not found between the start
and stop character which define the packet. This makes it possible to employ
resources found on the host computers to create a "virtual-serial" connection
between the remotely connected computers.
This program was written on the Amiga using the ACE Basic Compiler by David
Benn. It has been tested successfully on an Amiga 500 running Kickstart 1.3
and an Amiga 4000/040. If you do not have the narrator device and the
translator library, you will need to obtain them or change a line in the
stratego.prefs file (see later section).
Serial Stratego is now shareware. If you like the program, please send $5 US
to register. See the end of the document for my address.
II. THE RULES OF STRATEGO (skip this if you know them)
Stratego is played on a 10*10 board by two players (red and blue). In the
middle of the board, there are two "lakes" which occupy 4 squares each. The
playing pieces of stratego are designed so that their identities remain hidden
to the opponent (the pieces stand up on the board, and each piece is labelled
on one side only). Each player begins with 40 playing pieces, and players
alternate turns, moving one piece into a new square each turn. If a piece is
moved into a square that is occupied by one of the opponent's pieces, then
this is called a strike, and one of the two pieces will be removed from the
board (according to certain rules). The object of the game is to capture the
flag of your opponent, which is one of his pieces.
There are 12 different kinds of playing pieces:
Symbol: Name: Quantity:
1 Marshall 1
2 General 1
3 Colonel 2
4 Major 3
5 Captain 4
6 Lieutenant 4
7 Sergeant 4
8 Miner 5
9 Scouts 8
S Spy 1
* Bomb 6
F Flag 1
The pieces are numbered according to their power, the lowest numbers being the
most powerful.
Before the game begins, each player arranges his pieces on his side of the
board. All of his pieces must be placed within the four rows closest to his
side of the board. For example:
BBBBBBBBBB
BBBBBBBBBB "B" - Blue Playing Pieces
BBBBBBBBBB "R" - Red Playing Pieces
BBBBBBBBBB "*" - Empty Squares
** ** ** " " - Lake
** ** **
RRRRRRRRRR
RRRRRRRRRR
RRRRRRRRRR
RRRRRRRRRR
As soon as both players have finished setting up their pieces, the game
begins. At this point, neither player knows the identity of any of his
opponent's pieces. The red player takes the first turn.
All pieces are movable except for the bombs and the flag. During his turn, a
player moves one of his movable pieces to an adjacent square (but not
diagonally). The Scout (9) is special, and can be moved across any number of
unoccupied squares (horizontally or vertically). According to the original
rules, the scout may not move across multiple squares and strike a piece
during the same turn, however in this implementation a provision has been made
so that this rule may be changed. If this option is selected, then a scout
may move and strike in the same turn.
When a piece strikes an opponent's piece, the identities of both pieces are
revealed. The winner is determined by the ranks of the two pieces. In
general, a piece may defeat any other piece of a higher number (with one
exception), and if one piece strikes another piece of the same rank then both
pieces are lost. A two will defeat a three or four but not a one, for
example. The only exception to this hierarchy is the spy. Any piece may
strike the spy and defeat it, but if the spy strikes a Marshall (1), then the
spy will prevail. Bombs defeat all pieces except the miner (8). When the
attacking piece wins the strike, it is moved into the square occupied by the
defending piece. When the defending piece wins the strike, it is moved into
the square occupied by the attacking piece. In this implementation, there is
an option to allow the defending piece to remain in its square when it wins a
strike (another popular way to play the game).
The game is won when one player strikes his opponent's flag or removes all of
his opponent's pieces. If a player is unable to move a piece, then he loses.
III. USING THE PROGRAM
The program may be started from Workbench or the Shell. If the program does
not load, make sure that the serial port is not being used by another program.
Run the program from the Shell to see any error messages.
Once loaded, the program will begin a simple terminal program to facilitate
making a serial connection. While in terminal mode, there are 10 user
programmable macros that can be accessed through the Macros menu. These are
stored one macro per line in a file called "stratego.macros". The macros can
be useful in dialing phone numbers, logging on to a computer, or other tasks.
Once the connection is made, you should talk to the other player and decide
which sides you will be playing. Then select your color from the Setup menu
to begin playing the game. Here are some examples of different ways Serial
Stratego may be used:
Modem-
Use the terminal program to manually dial another computer. Have the other
computer answer. Verify the connection and then start the game from the Setup
menu.
Null Modem-
Connect two computers with a null modem cable, verify that the connection is
functioning, and then start the game from the Setup menu. It may be necessary
to change your system's serial preferences to "no handshaking" when using a
null modem connection.
Remote login and Talk/Write/IRC-
Use the terminal program to dial a computer on Internet. Establish a talk
session with another user, or have both players use the write command to talk
to each other. Once the connection has been verified, start the game from the
Setup menu. It is also possible to use this program with IRC. Just begin
using IRC on the remote computer, join a channel with the other player, and
then press ESCAPE. It is desirable to use the "-d" switch when invoking the
IRC client since this will eliminate the screen control characters, but
stratego will function properly without the "-d" switch. IRC usage may be
unreliable at times due to netsplits. The raw serial communications can
always be monitored by switching screens to the terminal emulator.
As soon as your color has been selected from the Setup menu, a new screen will
appear with two windows. One window will contain the board and the other will
be used for text, messages, and information.
When the board is first displayed, the pieces will be arranged in groups
according to their rank. Before play begins, the pieces must be set up. The
pieces are arranged by exchanging the locations of pieces. To select a
particular piece, just move the pointer onto it and click the left mouse
button. Then do the same thing for the piece that you want to exchange
positions with. When you have set the board up and are ready to continue
playing, select "Done Setting Up" from the Setup menu.
The Setup menu also allows you to load or save up to five different board
setups. These boards may be created and saved during the game setup so that
you can store your favorite configurations for use in later games. Once a
setup is loaded, you can still re-arrange pieces on the board. You may also
save the board in the middle of a game in the event that the connection is
lost. To resume playing, restart and load the saved board. If a board is
saved after the game has begun, it cannot be modified during the game setup
when it is loaded again.
When you have finished setting up, your opponent will be notified. When the
second player is done setting up, the game will begin. Players take turns
moving their pieces. To move a piece, click on the piece and then on the
square to which you want to move it. If you decide not to move the piece,
click on it again to unselect it. If it is impossible to move any of your
pieces, if you have run out of pieces to move, or if you would like to concede
the game, you may select "Concede Game" from the game menu. Otherwise, the
game will be finished when a player strikes his opponent's flag. When your
opponent moves his pieces, a "+" symbol will be placed on the last piece that
he moved. This is done in case a move is made while you are not watching the
screen.
When the game is completed, both players will be notified. If a player wishes
to reveal the locations of his remaining pieces to his opponent, he may do so
by selecting "Reveal Pieces" from the game menu. At this point, a new game
may be started or you may return to the terminal emulator using the game menu.
At any time during the setup, gameplay, or after the game, you may send
messages to your opponent. Just begin typing a message from the keyboard.
When you press return, the message will be sent to your opponent. All
messages are printed and spoken using the Amiga's SPEAK: device. The last 13
messages that you send are logged, and you can resend them quickly by
selecting them under the dialog menu. Message logging may be turned off and
on using the "Message Buffer is Off/On" menu selections under the dialog menu.
This permits you to record certain messages which you may want to send
frequently and have them easily available via a menu selection.
The "Rank Report" selection under the game menu displays the number of pieces
of each type that you have captured. This is useful in determining which
pieces your opponent has left.
There are two variations of the stratego rules that may be played. These are
controlled by the "Scout Strike" and "Defender Occupies" selections in the
game menu. These options may be changed by the red player only. Normally, a
player may move his scout across many unoccupied squares, but may not strike
in the same turn unless it is to an adjacent square. When the "Scout Strike"
option in the game menu is enabled, both players may move and strike across
multiple unoccupied squares with a scout during a single turn. The other
option that may be changed concerns the placement of the piece that is being
attacked in a strike. If the piece that is being struck wins, then that
piece is moved into the square that was occupied by the attacking piece. If
the "Defender Occupies" mode is turned off, then the attacked piece will
remain in its original square if it defeats the attacker.
The "Send Ping" menu selection is useful to determine if both programs are
sending and receiving packets. When selected, you should send a "Ping..." and
receive a "Pong" slightly later. Both of these events should be displayed in
the text window. If no "Pong" is received, then there is something wrong with
the connection. Wait and send some more "Pings". If the connection becomes
re-established, then the "Sanity Check" feature should be used to
re-synchronize the packet counters on both computers. If "Ping" is still
having problems, then return to terminal mode. The ping function should
normally be used to verify that the other player is still there if you haven't
heard from him (maybe his computer crashed, or the modem was disconnected,
etc.).
Another diagnostic is the "Sanity Check" under the game menu. This has two
functions. It checks to make sure that the pieces are arranged in the same way
on both boards (this may not be the case if some packets were completely lost
during the game because of bad line noise or other circumstances). The
"Sanity Check" will report a fatal error if the boards do not match. The
second feature of the sanity check function is the synchronization of packet
counters on both computers. Each computer keeps track of how many messages
have been sent by the other, so that if there is an error, a re-send may be
requested. If a packet is completely lost and undetected for some reason,
then these numbers will be inconsistent. The sanity check will check for an
inconsistency in the packet counters and automatically correct it ("Sync
Error" will be displayed).
IV. THE PREFERENCES FILE
The file "stratego.prefs" contains a few parameters that may be modified to
suit your needs. The following is a listing of the standard preferences file:
-------------------- Begin file after this line.
19200
N81SF
serial.device
+++
ath
0
SPEAK:
$%&'
0
-------------------- File ends with previous line.
Here is a detailed description of the elements of the preferences file:
Line #: Description:
1 The baud rate of your serial connection.
2 The ACE parameters for opening the serial device:
N/E/O Parity none, even, odd
8/7 bits per word
0/1 stop bit
3 - 3 wire handshaking (optional)
S - Shared access to serial device (optional)
F - Fast serial mode (optional)
3 The name of the serial device. Maybe you would like to use the AUW
device or a faster serial device instead. Just put the name of the device
that you want to use here.
4 The unit number of the serial device.
5 The command mode sequence for your modem (this should not need to be
changed).
6 The hangup command for your modem (this should not need to be
changed).
7 The name of the device/file that you want spoken text to be
directed to. If you don't have the speak device with your version of
AmigaDOS, get it from someone or direct this to NIL: or another device
instead. You can also change the sound of voice by adding parameters to the
end of the device name (see AmigaDOS manuals).
8 The four characters that are used to mark the beginning and ending
of packets sent by both players. This line MUST be the same for both players.
this should only be changed when the characters that are being used might
interfere with the connection in some way (see technical notes).
9 Miscellaneous flags. Currently this may have the following values:
0 --> Default
1 --> Poll the keyboard frequently (improves keyboard performance on
slower machines)
2 --> Don't load or use sounds (conserve CHIP memory)
3 --> Poll keyboard frequently and don't use sounds.
V. TECHNICAL NOTES (how the packet subroutines work)
I have always found it neat that you can talk to people on other networked
computers around the world for free. The "talk" program on most UNIX machines
allows you to call up another person on a different computer connected to the
network. You can then carry on a conversation by typing text, character by
character, to the other person's screen. The "write" program lets you type
and send sentences of text to another person's screen (provided that they are
logged on to the same computer). When two people "write" to each other, they
can carry on a conversation by taking turns sending lines of text and pressing
return after each line. Internet Relay Chat lets groups of people on
different computers talk and send messages to each other on different
channels.
I am also interested in multiplayer computer games. The only problems with
modem or null-modem type games are that it costs money to play games over long
distances and it is difficult to find ways to connect more than two players
using modems.
This gave me the idea to develop some subroutines which would encode strings
into packets which could be sent as normal text and thus be transmitted
through the network via programs that were intended to be used for
communicating text in real-time. One subroutine would take as input a
character string, encode it, and send it. The other routine would monitor the
serial device, decode packets, and return them to the program. In many ways
this is similar to network layers which provide an "invisible" channel through
which to communicate. My subroutines convert these network resources into
"virtual-serial" connections between two remotely connected computers.
I wanted the subroutines to be as generally useful as possible, so I decided
to use only standard ASCII printable characters to encode the packets. This
implementation uses characters 63-126 and 36-39. Characters 63-126 are used
to send data, and 36-39 are used to mark the beginnings and endings of
packets. In order to prevent interference between messages that are sent and
echoed back (the remote computer sends back everything that you type so you
can see it), and what the other player sends you, I divided the usable
characters into two portions- one for each player. The packet send routine
uses only the characters allowed for that player and includes a CR (carriage
return) at the end of each packet ("write" requires a CR before a sentence is
sent to the other terminal). The packet receive routine filters out all
characters except those of the kind sent by the other player. In addition, it
filters out ALL characters that are not found between a packet begin and
packet end character. This means that anything not contained inside the
packet delimiters will be filtered out and ignored. In addition, VT-100
screen escape sequences are filtered from input inside of each packet. The
four characters that are used to define a packet begin, and end, for both
players may be changed if they interfere with the communication method. These
characters are located in the preferences file, but should be changed with the
understanding that both players must have the same string on this line in
their preferences file or the programs will not communicate.
A CRC-16 checksum is used for error detection, and a data timeout is detected
when a certain amount of time elapses after a packet begin is received, but no
packet end is received. If an error is detected, a resend can be requested.
The previous 10 packets sent (including resends and resend requests) are
buffered so that if extreme durations of line noise occur, all packets can be
eventually recovered. All errors and resends are displayed in the text
window, notifying the players.
If anyone is interested in writing more multiplayer games in ACE, I would be
more than happy to donate these subroutines and assist in their implementation
into a program.
VII. MISCELLANEOUS INFORMATION
If you like this program, please send $5 US to:
Daniel Oberlin
3A Gaslight Village
Ithaca NY, 14850
I would appreciate hearing from anyone who has suggestions, bug reports, or an
interest in playing stratego with this program. In fact, please send me
E-mail just letting me know that you have tried my program and under what
circumstances. If you have an interest in using the packet sending/receiving
subroutines to write other games with ACE, I would be happy to provide the
source code. Here is how I can be reached (start with the top E-mail address,
the others are longer term but checked less frequently):
fkrj@crux2.cit.cornell.edu
oberlin@chemres.tn.cornell.edu
doberlin@math.fsu.edu
IRC Nicks: obi1, DogMaps. Generally found on channel #amiga.
Program History:
Version 1.0 -
first beta test version.
Version 1.2 -
contains many added features and enhancements.
Version 1.3 -
first public release.
Version 1.4 -
beta release of version 1.5
Version 1.5 -
Not compatible with previous versions!
Messages may now be initiated by simply typing from the keyboard.
User definable menu macros are added to the terminal emulator.
Menu performance is improved.
Messages are limited in size preventing an overflow.
Boards can be saved in mid game and recovered.
Sound effects are added.
Data error checking now uses CRC-16.
Code has been cleaned up somewhat.
Future plans:
A title page. If people show enough interest, I might add AmiTCP support as
well.
Acknowledgments:
David Benn-
for writing the ACE compiler used to compile this program. I really like ACE
a lot and hope that it will be developed further.
My brother Richard-
who patiently tested the program with me.
Amiga-
the best microcomputer platform.