Files
Cody Boone Ferguson 5a99d745c5 Fix infinite loop in 2000/robison w/invalid input
If someone entered invalid input (say because they don't know the format
yet or because they make a typo or some other reason) their terminal
would be flooded with an error message, forcing them to kill the game.
This was done in much the same way as the fix for 1987/lievaart. Without
this fix the words:

    Black position and direction: illegal

would flood the screen.

The Makefile CINCLUDE now has -include stdio.h (not strictly necessary
however).

Format and typo check README.md.
2023-11-14 11:49:59 -08:00

852 lines
2.9 KiB
C

#define A B.
#define C if(
#define D >>E&1
#define F return
#define G typedef
#define H printf( I(
#define J(E,K) for(E=K; E--; )
#define L(M) =N(O.M)+3*N(O.M&O.P),
G
int
Q;
G
unsigned
R;
G
struct
{
Q
N,
S,
P,
T,
U,
V;
}
W;
R
_;
R
N(
R
X)
{
R
Y=
2,
Z;
for
(;
Y
;
Y*=
Y)
{
Z=
-1
/-
~Y
;
X=
(X
/Y
&Z
)+
(X
&Z
)*
(Y
*_
-~-
_)
;
}
F
X;
}
W
S(
W
a)
{
W
B;
_=
1;
A
N=
N(
a.
S)
;
A
S=
N(
a.
N)
;
A
P=
N(
a.
P)
;
A
U=
-1
<<
30
;
A
V=
-a
.U
;
F
B;
}
Q
P(
Q
Y,
Q
b,
R
c)
{
Q
E=
Y+
(b
+8
)%
10
-5
+Y
/4
%2
&31
;
F
c
D||
Y/
4-
E/
4-
~-
(b
&2
)?
-1
:E
;
}
Q
T(
W
B,
Q
a,
Q
b)
{
Q
E=
P(
a,
b,
A
N)
;
F~
E?
A
S
D?
~P
(E
,b
,A
S|
A
N)
?128
|b
*32
|a
:-
1:
b*
32
|a
:E
;
}
Q
U(
W
B,
R
c,
Q
Y)
{
Q
E,
b;
J(
E,
32
)C
(A
N&
c)
D)
J(
b,
2<<
(A
P
D)
)C
T(
B,
E,
b)
>=
Y<<
7)
F
1;
F
0;
}
W
V(
W
B,
Q
Z)
{
R
E=
Z&
31
,b
=Z
/32
&3
,Y
=A
T=
P(
E,
b,
0)
,K
=1
<<
Y;
A
N|=
K;
A
P&=
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*
2,
".xoXO"
[(
A
P
D)
*2
+(
A
S
D)
*2
+(
A
N
D)
])
;
}
H" } } } } } } "
),
-~
E)
;
}
J(
g,
1)
{
O=
l;
H"} } } } { } } } } { ; ; }"
)+
o/
2*
2)
;
e=
0;
C
o<
4)
B=
S(
B)
;
C!
U(
B,
-1
,0
))
{
H" } } { ; { ; } ; } } "
))
;
F
0;
}
H" { { ; { ; ; { ; ; { { } } ; ; { } } } ; ; { ; } } } { ; { ; ; { { ; } } "
)+
(o
&1
)*
13
,I
(" } { { } ; } "
)+
U(
B,
-1
,1
))
;
C
o&
4)
{
char
X1[
5]=
{'\
\0'}
,X2
[5]
={\
'\0\
'};
C o
&1
){
scanf
("%4s"
,X1);
n=at\
oi(X1);
}else
{X1[
0]=
'\
\0'
;X2
[0]
='\0';
scanf
("%4s\
%4s",
X1,
X2);
m=
atoi
(X1);
n=
atoi
(X2)
;--m;
Z=
A
N>>
m&
1?
T(
B,
m,
n)
:-
1;
C
g=
Z>>
7!=
U(
B,
-1
,1
))
{
H"{ ; { { } { } { ; } ; { "
))
;
}}
}
else
{
A
U=
-(
A
V=
1<<
30
);
for
(b
=4
;
e<
65536
&&
b<
20
;
b++
){
Z=
(o
&1
?f
(B
,m
,b
,-
2)
:d
(B
,b
))
.T
;
}
o&
1?
H" } { } "
),
Z>>
5&
3^
3)
:H
" } { } } } { } "
),
32
-(
Z&
31
),
Z>>
5&
3^
3)
;
}
}
B=
V(
B,
Z)
;
g=
o;
C
_)
{
o|=
1;
m=
A
T;
}
else
{
o=
o/
2*
2^
4;
}
C
g<
4)
{
B=
S(
B)
;
}
}
}