Fix 1989/tromp alt code
Originally I put in the author's code without fixes in place. This is one of the reasons I did not see the improvements that he suggested. Several fixes had to be made and now it works. It should be noted I have not tested more than one user updating the high score file but the file is now created (I had to make a similar fix to the original entry as well). Format/typo check README.md file. Not sure I'm done with this one though as presentation might be improved.
This commit is contained in:
1 parent
8f119955cb
commit
3d9f7763d0
3 files changed
+66
-46
No files matched your search
+46
-36
@@ -1,9 +1,6 @@
|
||||
# Best game
|
||||
|
||||
John Tromp\
|
||||
Centre for Mathematics and Computer Science (CWI)\
|
||||
Oetgensstraat 7\
|
||||
1701CK Heerhugowaard\
|
||||
Netherlands
|
||||
|
||||
## To build:
|
||||
@@ -19,39 +16,44 @@ make all
|
||||
```
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./tromp 5
|
||||
|
||||
# fast with vim keys
|
||||
# h - left (left)
|
||||
# k - rotate (arbitrary, in vim k = up)
|
||||
# l - right (right)
|
||||
# j - drop (down)
|
||||
# space - pause (literal space in vim)
|
||||
# q - quit (similar to :q in vim)
|
||||
|
||||
./tromp 10 "hklj q"
|
||||
./tromp 10 "hkl jq"
|
||||
```
|
||||
|
||||
NOTE: after this game ends a file called `HI` will be in the directory with the
|
||||
The second command, `./tromp 10 "hkl jq"`, will set up the keys kind of like
|
||||
vim:
|
||||
|
||||
- h - left (left)
|
||||
- k - rotate (up)
|
||||
- l - right (right)
|
||||
- j - drop (down)
|
||||
- space - pause (space)
|
||||
- q - quit (:q)
|
||||
|
||||
|
||||
NOTE: after the game ends a file called `HI` will be in the directory with the
|
||||
high scores (up to 20 runs saved) so one can see who has the highest score. The
|
||||
file might look like:
|
||||
|
||||
```
|
||||
330 by luser
|
||||
136 by loser
|
||||
100 by winner
|
||||
```
|
||||
|
||||
... or so, where in this case the luser is the winner and the loser is the loser :-)
|
||||
... or so, where in this case the [luser is the winner, the loser is in second
|
||||
place and the winner is the
|
||||
loser](https://web.archive.org/web/20181023221954/https://www.chicagotribune.com/news/ct-xpm-2002-07-31-0207310310-story.html) :-)
|
||||
|
||||
|
||||
### Alternate code:
|
||||
|
||||
The author provided an alternate version of the code with some improvements. We
|
||||
were unable to see the improvements in modern systems even after fixing it to
|
||||
compile (the high score file was not created at all) but if you have an old
|
||||
compiler you can try compiling it in its original unmodified form by running:
|
||||
The author provided an alternate version of the code with some improvements. See
|
||||
the judges' additional remarks in the author's remarks, for more details.
|
||||
|
||||
#### To use:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
@@ -59,29 +61,33 @@ make alt
|
||||
|
||||
Use `tromp.alt` as you would `tromp` above.
|
||||
|
||||
NOTE: testing more than one user updating the high score file, one of the
|
||||
benefits of the alt version, has not been done.
|
||||
|
||||
The original unmodified alternate code is provided later.
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
This is a character terminal version of the TETRIS program.
|
||||
This is a character terminal version of the `TETRIS` game.
|
||||
It runs on a VT100 compatible terminal or emulator. It is
|
||||
best used at 4800 baud or more.
|
||||
|
||||
By default, "drops_per_sec", the number of times an object
|
||||
will drop in a second, is 2. The default "cmd_string" is
|
||||
"jkl pq". The first 6 characters of "cmd_string" relate
|
||||
By default, `drops_per_sec`, the number of times a tetrimino
|
||||
will drop in a second, is 2. The default `cmd_string` is
|
||||
`jkl pq`. The first 6 characters of `cmd_string` relate
|
||||
to the following 6 game commands:
|
||||
|
||||
- j - left
|
||||
- k - rotate
|
||||
- l - right
|
||||
- space - drop
|
||||
- space - drop
|
||||
- p - pause
|
||||
- q - quit
|
||||
|
||||
Specifying "cmd_string" allows one to re-define the commands.
|
||||
Specifying `cmd_string` allows one to redefine the commands.
|
||||
The pause command pauses the game, clears the screen and
|
||||
prints the current score. To resume, type the pause
|
||||
character again, which by default is "p".
|
||||
character again, which by default is `p`.
|
||||
|
||||
As was stated last year, we are likely to be more strict about
|
||||
portability in the future. [ We mean it this time :-) ]
|
||||
@@ -89,7 +95,7 @@ portability in the future. [ We mean it this time :-) ]
|
||||
|
||||
## Author's remarks:
|
||||
|
||||
This program plays the familiar game of `TETRIS' with the
|
||||
This program plays the familiar game of `TETRIS` with the
|
||||
following features:
|
||||
|
||||
* outputs vt100-like escape-sequences for cursor
|
||||
@@ -98,32 +104,34 @@ following features:
|
||||
|
||||
* continuously increasing speed (except in pause)
|
||||
|
||||
* start speed selectable by giving n as first argument,
|
||||
where n is the number of drops per second (default=2).
|
||||
* start speed selectable by giving `n` as first argument,
|
||||
where `n` is the number of drops per second (default=2).
|
||||
|
||||
* controls also selectable by giving as the second argument
|
||||
a string of 6 characters. By default they are "jkl pq".
|
||||
a string of 6 characters. By default they are `jkl pq`.
|
||||
|
||||
* screen is blanked during the pause and the score is shown
|
||||
|
||||
* maintains a high-score table
|
||||
|
||||
Giving a full path name for the table will result in a
|
||||
system-wide hiscore allowing a competition between users.
|
||||
system-wide high-score allowing a competition between users.
|
||||
|
||||
### Additional remarks from the judges:
|
||||
|
||||
The author provided us with the following notes and new version of
|
||||
the program:
|
||||
|
||||
Here is a somewhat improved version of my tetris entry. All the
|
||||
changes are in the popen() at the end. Formerly a move was done
|
||||
changes are in the `popen()` at the end. Formerly a move was done
|
||||
to the HI score file which is not permitted for other users. Now
|
||||
other users can change the HI score file. The extra option -m is
|
||||
other users can change the `HI` score file. The extra option `-m` is
|
||||
passed to sort, so that it knows that its input files are already
|
||||
sorted. The -o output option of sort is used instead of a
|
||||
sorted. The `-o` output option of sort is used instead of a
|
||||
temporary file.
|
||||
|
||||
You may also want to consider giving just the raw option to stty
|
||||
at the start and -raw at the end. This further reduces the size of
|
||||
You may also want to consider giving just the raw option to `stty`
|
||||
at the start and `-raw` at the end. This further reduces the size of
|
||||
the program, but has the possible disadvantage that the program
|
||||
can only by stopped by 'q' or by the `kill -9' command.
|
||||
|
||||
@@ -149,6 +157,8 @@ can only by stopped by 'q' or by the `kill -9' command.
|
||||
"%4d from level %1d by %s\n",w,l,getlogin());pclose(d);}
|
||||
```
|
||||
|
||||
NOTE: the alternate version was fixed for modern systems in 2023.
|
||||
|
||||
## Copyright and CC BY-SA 4.0 License:
|
||||
|
||||
This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
|
||||
Reference in new issue
Block a user