1
0
Fork 0

Added BattleShips

This commit is contained in:
acn 2019-10-25 09:59:49 +02:00
parent 9e8f5d6c5e
commit 231c991d98
5 changed files with 1429 additions and 0 deletions

70
Battleships/README.md Normal file
View File

@ -0,0 +1,70 @@
# Battleships
CP/M port of the Unix game.
Copyright:
* bs.c - original author: Bruce Holloway
* salvo option by: Chuck A DeGaul
* with improved user interface, autoconfiguration and code cleanup
* by Eric S. Raymond <esr@snark.thyrsus.com>
* v1.2 with color support and minor portability fixes, November 1990
* v2.0 featuring strict ANSI/POSIX conformance, November 1993.
* v2.1 for Linux, October 1994.
* Slipstreamed in fixes to make it gcc -Wall clean, May '95.
* fairly seriously hacked for Hitech C and CP/M, rjm 95/8/14
I found it as part of the ZCN repository: https://github.com/jamesots/zcn
The C source has been modified for VT100 compatibility and some minor
changes have been made by me (Anna Christina Naß <acn@acn.wtf>.
``bs.com`` is the compiled binary.
See the ``*.txt`` files for more information.
## Modes
* ``-b`` selects a "blitz" variant
* ``-s`` selects a "salvo" variant
* ``-c`` permits ships to be placed adjacently
The "blitz" variant allows a side to shoot for as long as
it continues to score hits.
The "salvo" game allows a player one shot per turn for
each of his/her ships still afloat. This puts a premium
scoring hits early and knocking out some ships and also
makes much harder the situation where you face a superior
force with only your PT-boat.
## Keys
To position your ships: move the cursor to a spot, then type the first letter of a ship
(using CAPITAL letters) type to select it, then type a direction ([hjkl] or [4862]),
indicating how the ship should be pointed.
You may also type a ship letter followed by `r' to position it randomly, or type `R' to
place all remaining ships randomly.
Navigation and aiming keys:
yz k u 7 8 9
\|/ \|/
h-+-l 4-+-6
/|\ /|\
b j n 1 2 3
| Key | Action | Key | Action |
| ----- | ------------------------ | --------- | ------------------------ |
| h / 4 | move left | y / z / 7 | move up+left |
| l / 6 | move right | b / 1 | move down+left |
| j / 2 | move down | u / 9 | move up+right |
| k / 8 | move up | n / 3 | move down+right |
| r | place this ship randomly | R | place all ships randomly |
| ^L | screen redraw | Q | quit game |
## Compiling
HiTech C has been used to compile it, but it needs a lot of free memory (TPA).
For compiling, I used the command ``c bs.c`` in CP/M.

1251
Battleships/bs.c Normal file

File diff suppressed because it is too large Load Diff

BIN
Battleships/bs.com Normal file

Binary file not shown.

38
Battleships/esr.txt Normal file
View File

@ -0,0 +1,38 @@
BS 2.0
Battleships is an intrinsically silly game, but I couldn't resist fixing this
sucker. It now has a purely visual interface (you place ships and call for
shots by moving the cursor around the board using the standard yuhjklbn keys).
The default game now disallows placement of ships so that they touch. A new
-c option is available to force the older behavior.
I also removed the `seemiss' option (now always on) and `ask' (which is only
useful for cheating). And I ifdefed out the ditsy opening screen; if you want
it back, compile with -DPENGUIN. One strike against featureitis...
The code now lints as clean as the broken SysV curses lint library will let it.
Some #ifdefs in the code should result in the right things being done for
BSD or USG systems. They key off A_UNDERLINE. If you're using the Linux
ncurses library, tell the makefile.
This was probably a waste of a day or so. But what the hack -- rewriting the
strategy robot as an FSM was fun, and maybe the interface will set a good
example for the next guy.
<*** FLAME ON ***>
People who write termcap games that require you to enter #@!!#$! coordinates
rather than doing the natural pick-and-place with cursor motions should be
stuffed in suits and condemned to write COBOL for the rest of their days...
<*** FLAME OFF ***>
O.K., I feel better now that I've got that off my chest...
November 1993: I've added function key support, and ANSI/POSIXized the code.
Eric S. Raymond
esr@snark.thyrsus.com
(WWW: http://www.ccil.org/~esr/home.html)

70
Battleships/readme.txt Normal file
View File

@ -0,0 +1,70 @@
This is a version of Battleships played on a 10x10 grid, with you
playing against the computer. There's a reasonable amount of onscreen
help, so you should be able to figure out how to work it pretty
quickly.
It's a port of a Unix curses version hacked by a few different people.
A formatted version of the man page (documentation) is given below,
and the 'readme' from the last person to hack it is in 'esr.txt'.
-Rus.
BATTLESHIPS(6) BATTLESHIPS(6)
NAME
bs - battleships game
SYNOPSIS
bs [ -b | -s ] [ -c ]
DESCRIPTION
This program allows you to play the familiar Battleships
game against the computer on a 10x10 board. The interface
is visual and largely self-explanatory; you place your
ships and pick your shots by moving the cursor around the
`sea' with the rogue/hack motion keys hjklyubn. If your
UNIX has a modern (non-BSD) curses, your arrow keys will
also work.
Note that when selecting a ship to place, you must type
the capital letter (these are, after all, capital ships).
During ship placement, the `r' command may be used to
ignore the current position and randomly place your cur-
rently selected ship. The `R' command will place all
remaining ships randomly. The ^L command (form feed, ASCII
12) will force a screen redraw).
The command-line arguments control game modes.
-b selects a `blitz' variant
-s selects a `salvo' variant
-c permits ships to be placed adjacently
The `blitz' variant allows a side to shoot for as long as
it continues to score hits.
The `salvo' game allows a player one shot per turn for
each of his/her ships still afloat. This puts a premium
scoring hits early and knocking out some ships and also
makes much harder the situation where you face a superior
force with only your PT-boat.
Normally, ships must be separated by at least one square
of open water. The -c option disables this check and
allows them to close-pack.
The algorithm the computer uses once it has found a ship
to sink is provably optimal. The dispersion criterion for
the random-fire algorithm may not be.
AUTHORS
Originally written by one Bruce Holloway in 1986. Salvo
mode added by Chuck A. DeGaul (cbosgd!cad). Visual user
interface, `closepack' option, code rewrite and manual
page by Eric S. Raymond <esr@snark.thyrsus.com> August
1989. Keypad support and ANSI/POSIX conformance, November
'93. See http://www.ccil.org/~esr/home.html for updates,
also other software and resources by ESR.
Nov 15 1993 1