Add alt code to 1993/rince

This is based on the suggestion of the judges that some people might
want to slow the game down a bit.

It is easy to configure at compile time like:

    make CDEFINE=-DZ=18 clobber alt

More details are in the README.md file.

Updated .gitignore and thanks file (not just for this but also
making something else clearer in another entry).
This commit is contained in:
Cody Boone Ferguson committed 2023-10-02 09:58:49 -07:00
1 parent 0f5ac2be03
commit 5c0b571623
5 files changed
+169 -24

No files matched your search

+1
View File
@@ -1,4 +1,5 @@
jkb
rince
rince.orig
rince.alt
prog.orig
+3 -3
View File
@@ -58,7 +58,7 @@ ARCH=
# Defines that are needed to compile
#
CDEFINE=
CDEFINE= -DZ=17
# Include files that are needed to compile
#
@@ -115,8 +115,8 @@ OBJ= ${PROG}.o
DATA=
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
#################
+35 -19
View File
@@ -1,9 +1,6 @@
# Most Well Rounded
James Bonfield
MRC Laboratory of Molecular Biology,
Hills Road
Cambridge
England
@@ -13,6 +10,8 @@ England
make all
```
NOTE: there is an alternate version of this program that allows one to slow down
the game. See the Alternate code section below.
## To run:
@@ -21,12 +20,39 @@ make all
```
where:
`[cabbage]` is a CABBAGE description file (default: `rince.c`)
### Alternate code: slowing down the game
Some people may want to slow down the game by increasing the
value 17 in the lines:
```c
struct timeval v= {0,1<<17} ;
```
and
```c
refresh(),c=select(k,&y,0,0,(v.tv_usec=1<<17,&v))?getch():0;
```
to another value like 18 or 19. You can do this via the alternate code like:
```sh
make CDEFINE="-DZ=18" clobber alt
```
Replace 18 with whatever number you wish.
Use `rince.alt` as you would `rince` above.
## Judges' remarks:
The author has provided several CABBAGE files for your amusement:
- [rince.data1](rince.data1) plays
@@ -72,7 +98,7 @@ should be replaced with:
```c
select(k,&y,0,0,(v.tv_usec=1<<whatever_you_want,&v))
```
```
where `whatever_you_want` is some integer such as 17 or 19.
@@ -83,20 +109,10 @@ compiler in the first place), this program may be used to log
out very quickly. Unfortunately, you can't do anything else
with it.
### Slowing down the game
Some people may want to slow down the game by increasing the
value 17 in the line:
```c
struct timeval v= {0,1<<17} ;
```
to something like 18 or 19.
### Additional notes
One may also need to do a `stty sane` if you kill the program
to restore your terminal state.
to restore your terminal state. If that does not work try `reset`.
Some people report that `rince` dumps core on their system.
@@ -144,7 +160,7 @@ I have compiled in on the following systems:
---
```
System OS Compiler (and flags)
System OS Compiler (and flags)
DECstation 5000/240 Ultrix 4.2A c89 -std
SPARCstation 1+ SunOS 4.1 gcc -ansi -pedantic
SPARCstation 10/31 Solaris 2.1 gcc -ansi -pedantic (*)
+123
View File
@@ -0,0 +1,123 @@
/** J.K.Bonfield **
^ <
^ >
< # > v
< <
< > > < v
X X j
x X j
X x ^ k
^ ^
^ #
X X X X
^ v
v v
v #
v X
v x
> # < v
> >
X X l
x X l
41 20
########################################
# #
# < < < < <> < < < #
# > > > <> > > > > #
# < < < < <> < < < #
# > > > <> > > > > #
# < < < < <> < < < #
# > > > <> > > > > #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# X #
########################################*/
#include <stdio.h>
#include <curses.h>
#include <stdlib.h>
#include <setjmp.h>
#include <sys/time.h>
int _tty_ch;
bool _echoit;
bool _rawmode;
int _tty;
#define U char
#define G for(
#define I )malloc(sizeof(
typedef struct z {U x[20]; struct z*y; } j; j*J[2][256];
struct timeval v= {0,1<<Z} ;
U**X,c,*P="noopoqqnr",d;
j*a(int Q, int i) {
G
clear(),noecho(),cbreak(); ;
)
{
int x=0,y=0,W=Q,Q=i-1,k;
G;
y<=Q;
(mvaddch(y,x,X[y][x]),++x^W-1)||(x=0,y++));
k=y=- --x;
G
refresh(),c=select(k,&y,0,0,(v.tv_usec=1<<Z,&v))?getch():0;
k?++x-W||(x=1,++y-Q||(--k,x=W-1,y=Q-1)):--x||(y--,x=W-1),k|y;
)
{
j *t;
G
t=J[1-k][X[y][x]]; t; t=t->y) {
U*f=t->x;
if (d==f[17]|f[17]==c) {
int i=k&2,u=9,k=1,w=x,_=y,T;
G;
--u||(d-f[8]&&(X[y][x]=f[8]),w---_--,i=0,u=8,k--);) {
_+=P[T=i>u?u:i]-'o';
w+=P[4+T]-'p';
if(k) {
if (d-f[i]&&f[i]-X[_][w]) break;
i++;
} else
f[++i+8]-d && (X[_][w]=f[i+8]);
} } } } } }
jmp_buf E;
int main(int open, U**exit) {
FILE*C=fopen (
open-2?__FILE__:*++exit,P+8);
j*t;
volatile int Q,Y=0;
int i,q; d=open-2?'\t':'*'; L:
Q=0; G; setjmp(E)<256; Q--
)
longjmp(E,(J[Y][Q]=0,Q++));
G; ; ) {
if(!C)return 1;
if('\n'==(c=getc(C)))
if(!Y++)goto L; else
{ fscanf(C,"%d %d\n",&i,&q);
X=(U**I P++)*q*(i+1));
Q=0; G; Q<q; Q++)
X[Q]=(U*)&X[q]+Q*i;
fread(*X,(initscr(),q*i),1,C);
a(i,Q);
}
t=(j*I*a(Q--,--Q)));
t->y=J[Y][c]; J[Y][c]=t;
fgets(t->x,20,C); }
}