Move 1988-2004 entries into subdirs
We we move 1988-2004 entries from all of a year's winning entries in a single directory to each winner being in their own sub-directory under the given year directory.
This commit is contained in:
1 parent
1e82e8aa3e
commit
d2a42f42e8
478 files changed
No files matched your search
@@ -0,0 +1,162 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#define A(x,y) i[a++]=(N){c,c+x,y};
|
||||
#define B(x,y) j[b++]=(N){c,c+x,y};
|
||||
#define C(j,k) for (j=0; j<k; j++){
|
||||
#define D(x) C(_,8)if(!(c+x[_]&136)){ if(p[c+x[_]]*p[c]<0)B(x[_],0)else if(!p[c+x[_]])A(x[_],0)} }
|
||||
#define J printf(
|
||||
#define O(v) _=v; while(!(c+_&136)){ x=p[c+_]*p[c]; if(x<0){B(_,0)E; } else if(x>0)E; else A(_,0)_+=v; }
|
||||
#define X(x) G(x,L)
|
||||
#define Z(x,y) memcpy(x,y,256);
|
||||
|
||||
typedef struct {
|
||||
F a,b,c;
|
||||
} N;
|
||||
|
||||
F g[]="KSLAU",
|
||||
p[256],v[]="{ ; } ; { ; ; ; { } ; { ; } { ; } { } ; { ; ; ; { ; } ; } } ; { ; ; { } ; { } } ; { ; ; { { ; ; { } } ; } ; ; { } ; { } } ; { ; ; { { ; { } } ; { ; ; { } ; { { ; ; { } ; ; ; ; { ; } { { ; ; ; { } ; { ; ; ";
|
||||
F S[]="{}; ",W[256],L[1024];
|
||||
P q[]={-14,-31,-33,-18,14,31,33,18},r[]={-1,-17,-16,-15,1,17,16,15},_,a,b,c,d,e,t=1,x,y,z;
|
||||
N i[500],j[500],*k,u;
|
||||
P f(N *V) {
|
||||
a=b=0;
|
||||
C(d,8)
|
||||
C(e,8)
|
||||
c=d<<4|e;
|
||||
if(p[c]==0||p[c]*t<0)continue;
|
||||
switch(p[c]<0?-p[c]:p[c]){
|
||||
K 80:
|
||||
if(56+t*40==(c&112)&&!p[c-32*t])
|
||||
A(t*-32,0)
|
||||
if(56+t*-40==(c&112)){
|
||||
if(!(c-17*t&136)&&p[c-17*t]*t<0){
|
||||
C(_,5)
|
||||
B(-17*t,(g[_]^_)*t)}
|
||||
}
|
||||
if(!(c-15*t&136)&&p[c-15*t]*t<0){
|
||||
C(_,5)
|
||||
B(-15*t,(g[_]^_)*t)}
|
||||
}
|
||||
C(_,5)
|
||||
A(t*-16,(g[_]^_)*t)}
|
||||
}else{
|
||||
if(!p[c-16*t])
|
||||
A(t*-16,0)
|
||||
if(!(c-(17*t)&136)&&p[c-17*t]*t<0){
|
||||
B(-17*t,0)
|
||||
}
|
||||
if(!(c-(15*t)&136)&&p[c-15*t]*t<0){
|
||||
B(-15*t,0)
|
||||
}
|
||||
}
|
||||
E;
|
||||
K 78:D(q)E;
|
||||
K 81:
|
||||
K 66:O(17)O(-17)O(15)O(-15)
|
||||
if(p[c]==66||p[c]==-66)
|
||||
E;
|
||||
K 82:O(1)O(-1)O(16)O(-16)E;
|
||||
K 75:D(r)
|
||||
} ;
|
||||
}
|
||||
}
|
||||
if ( b > 0 ) {
|
||||
C(_,b)V[_]=j[_]; }
|
||||
R b;
|
||||
} else {
|
||||
C(_,a)V[_]=i[_]; }
|
||||
R a;
|
||||
}
|
||||
}
|
||||
F *G(F *n, F *o){
|
||||
a=b=0;
|
||||
for(; n[b]; d=0){
|
||||
do{
|
||||
d*=4;
|
||||
d+=W[n[b++]];
|
||||
} while(++b<8*a+8);
|
||||
o[a++]=d;
|
||||
}
|
||||
o[a]=0;
|
||||
R o;
|
||||
}
|
||||
m(N a){ p[a.b]=a.c?a.c:p[a.a]; p[a.a]=0; }
|
||||
h(){
|
||||
J X("{ ; { { { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { { ; ; "));
|
||||
c=0; C(c,120)c%8==0&&putchar(56-c/16);
|
||||
if(p[c]<0){
|
||||
J X("} { { ; { { { ; ; ; { ; } } } ; { "),-p[c]);
|
||||
} else if(p[c]>0)
|
||||
J X("} { { ; { { { ; } } } ; { { ; { { "),p[c]);
|
||||
else
|
||||
J"| ");
|
||||
c%8==7?J X("} { { { ; ; { ; { { { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { ; } { ; } { ; } { ; ; { { ; ; ")),c+=8:0;
|
||||
}
|
||||
}
|
||||
s() {
|
||||
b=0; C(a,256)
|
||||
if(v[b]==94){
|
||||
b++; C(c,v[b]-32)p[a++]=v[b+1]-120;}
|
||||
b+=2; a--;
|
||||
} else
|
||||
p[a]=v[b++]-120;
|
||||
}
|
||||
}
|
||||
P w() {
|
||||
P v=0;
|
||||
C(_,120)
|
||||
p[_]&&(p[_]*t>0&&v--,p[_]*t<0&&v++);
|
||||
}
|
||||
v+=f(i); v-=b?100:0;t=-t; v-=f(i); v+=b?100:0;t=-t;
|
||||
|
||||
R v;
|
||||
}
|
||||
P V(P n, P o) {
|
||||
P s=-I,G,H,Y;
|
||||
N M[500];
|
||||
F u[256];
|
||||
|
||||
if(!(n+o))R w()+time(NULL)%9-4;
|
||||
if(!(H=f(M)))R I;
|
||||
H<5?H==1?n++:(o<6?o++:0):0;
|
||||
Z(u,p)
|
||||
C(G,H)
|
||||
Z(p,u)
|
||||
m(M[G]);
|
||||
t=-t;
|
||||
s=(e=-V(n-1,o))>s?Y=G,e:s;
|
||||
t=-t;
|
||||
}
|
||||
e=Y;
|
||||
R s;
|
||||
}
|
||||
main(P db, F *bd[]){
|
||||
N o[500];
|
||||
F T[256];
|
||||
|
||||
C(a,256)W[a]=-1; }
|
||||
C(a,4)W[S[a]]=a; }
|
||||
G(v,v); s();
|
||||
while(1){
|
||||
h();
|
||||
b=f(o);
|
||||
scanf("%s",L);
|
||||
if(strcmp(L,"quit")==0)R 0;
|
||||
else if(strcmp(L,"g")==0){
|
||||
Z(T,p)
|
||||
J G("} } } ; } ; { } } ; { } } } } ; } } { ; { { { ; } } } ; } { { { ; ; ",L), V(db>1?atoi(bd[1]):3,0));
|
||||
Z(p,T)m(o[e]); t=-t;
|
||||
}else{
|
||||
u.a=896-16*L[1];
|
||||
u.b=896-16*L[3];
|
||||
u.a+=L[0]-97;
|
||||
u.b+=L[2]-97;
|
||||
u.c=L[4]?L[5]:0;
|
||||
C(a,b)
|
||||
if(u.a==o[a].a&&u.b==o[a].b&&u.c==o[a].c)E;
|
||||
}
|
||||
a==b?J X("} { ; } } ; { } ; { } ; } } } ; } } ; { } } ; { { ; { { } ; } } ; } } ; } ; } } { { ; ; ")):(m(u),t=-t);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
Best AI:
|
||||
|
||||
Doug Beardsley
|
||||
Southern Adventist University
|
||||
359 Davis Rd. NW
|
||||
Cleveland, TN 37312
|
||||
USA
|
||||
|
||||
|
||||
Judge's Remarks:
|
||||
|
||||
To build:
|
||||
|
||||
make dgbeards
|
||||
|
||||
Try:
|
||||
|
||||
./dgbeards
|
||||
|
||||
This is probably the worst AI we've ever seen. So, then, why did
|
||||
the entry win? Because it's *trying* to lose.
|
||||
|
||||
This is also one of the first chess games we've seen.
|
||||
|
||||
Of particular interest is the author's decision that the program should
|
||||
crash if it loses. I've played chess with a lot of people like that, and
|
||||
I appreciate the realism.
|
||||
|
||||
|
||||
Selected Author's Comments:
|
||||
|
||||
FAQ:
|
||||
|
||||
Q: What does this program do?
|
||||
|
||||
A: It lets the user play two player or single player games of suicide
|
||||
chess. Suicide Chess (also known as Losing Chess) is a variant of normal
|
||||
chess. It is played on the same board and uses the same pieces. Here is
|
||||
a list of the differences:
|
||||
|
||||
1. The object of the game is to get to a position where you have no legal
|
||||
moves. This is usually accomplished by losing all of your pieces.
|
||||
Sometimes, the game can end when you still have some pawns on the board,
|
||||
but they are blocked and cannot move. The general rule is if a player
|
||||
has no legal moves, the game is over. The winner is the player with fewer
|
||||
pieces on the board. This is almost always the same player that had no
|
||||
moves, but not always.
|
||||
|
||||
2. In suicide chess, piece captures are compulsory. If a player can
|
||||
capture an opponent's piece, he is required to do so. If he can capture
|
||||
more than one of the opponent's pieces or can capture one piece with more
|
||||
than one of his own pieces, he can choose which capture to play.
|
||||
|
||||
3. The king is not significant. There is no concept of check and the king
|
||||
can be captured.
|
||||
|
||||
4. Because of rule 3, pawns are allowed to promote to a king.
|
||||
|
||||
5. Castling is not allowed.
|
||||
|
||||
Q: How do you use this program?
|
||||
|
||||
A: The program is fairly straightforward. When you start the program,
|
||||
it displays the opening position for a game of suicide chess and waits
|
||||
for user input. Commands are as follows:
|
||||
|
||||
quit - Quits the program
|
||||
g - Causes the computer to make a move
|
||||
|
||||
Moves are represented by the long algebraic notation for the move. For
|
||||
those not familiar with long algebraic notation, a move consists of a
|
||||
square to move from followed by a square to move to. Squares are denoted
|
||||
by a letter and a number. The letter specifies the column or file of the
|
||||
square and the number specifies the row rank. Files are named from left
|
||||
to right by the letters a-h. Rows are numbered from bottom to top with
|
||||
the numbers 1-8. A sample move from the opening position is e2e3. This
|
||||
means to move a piece from square e2 to e3. From the opening position,
|
||||
this corresponds to moving the king pawn forward one square. This is
|
||||
generally to be considered one of the best opening moves in suicide
|
||||
chess. All moves, captures and otherwise, are represented with this
|
||||
notation. A special case is pawn promotion moves. They use the same
|
||||
notation followed by an '=' and a letter representing the piece to
|
||||
promote to. The letters are R,N,B,Q,K representing rook, knight, bishop,
|
||||
queen, and king respectively. The letters must be upper case.
|
||||
|
||||
You can also specify a command line argument of a single digit to change
|
||||
the search depth of the program. If no argument is specified, it
|
||||
defaults to a depth of 3.
|
||||
|
||||
Q: Are there any limitations in your program?
|
||||
|
||||
A: Yes. The first of the limitations is that you can only play legal
|
||||
moves according to the rules of suicide chess. En passant captures are
|
||||
not recognized. They are rarely encountered in suicide chess and when
|
||||
they do happen, they usually do not change the outcome of the game. As
|
||||
mentioned above, castling is not allowed either.
|
||||
|
||||
It also does not detect the end of the game. It can see sure wins or
|
||||
losses several moves ahead, but does not announce the end of a game or
|
||||
the winner. Given the existing code it is easy to do this, but it was
|
||||
deemed unnecessary fluff.
|
||||
|
||||
Q: What is the playing strength of this program?
|
||||
|
||||
A: Playing strength is a relative term. Relative to other computer
|
||||
programs that play suicide chess, it is about the bottom. There is one
|
||||
freeware program in existence called kenny that this program can beat,
|
||||
but that is about it.
|
||||
|
||||
Suicide chess is a very tactical game. Most humans who do not have any
|
||||
experience in suicide chess will lose to this program. The Free Internet
|
||||
Chess Server (http://www.freechess.org) is a free online chess server
|
||||
that supports suicide chess. This server keeps track of ratings. The
|
||||
human ratings for suicide chess range from 1000 to about 2400. This
|
||||
program would probably be rated somewhere around 1700-1900. It is better
|
||||
than most players, but will get destroyed by experienced human opponents.
|
||||
|
||||
This program searches to a fixed depth of 3 ply. Because it does not
|
||||
search very deep, it performs very poorly in quiet strategic positions.
|
||||
In such positions, it will often just shuffle pieces around aimlessly
|
||||
until a tactical exchange presents itself.
|
||||
|
||||
A small amount of randomness has been added to make the program a more
|
||||
interesting opponent. The to avoid a call to srand(), rand() and the
|
||||
extra code for the required include files, the time() function is used as
|
||||
the source of random data. It is a slow function, and since it is
|
||||
executed inside the search loop, there is a significant performance
|
||||
decrease. To make it faster, replace the time() call with rand() and add
|
||||
the line srand(time(0)); to the beginning of main(). I used the more
|
||||
inefficient time() function to illustrate a different (and somewhat
|
||||
obfuscated?) way of generating random numbers.
|
||||
|
||||
Q: Why is this program obfuscated?
|
||||
|
||||
A: Here are several reasons:
|
||||
|
||||
First, without preprocessing, the code is not easy to read. The
|
||||
preprocessor is used to compress the code and obfuscate it. The main
|
||||
obstacle to entering this program is the source code size limit. This is
|
||||
the reason that the preprocessor was used so liberally. It is one of the
|
||||
best ways to compress C source code.
|
||||
|
||||
Second, when possible, variables in the program were made global. Their
|
||||
names are not descriptive and they are used for a variety of purposes
|
||||
throughout the program. Because of this, it is difficult to determine
|
||||
exactly what the code does even after preprocessing and beautifying the
|
||||
code.
|
||||
|
||||
Third, all function names are a single character and are obviously not
|
||||
descriptive of they're actual purpose. Again this serves the dual
|
||||
purpose of compression and obfuscation.
|
||||
|
||||
Fourth, most string variables have been encoded. This encoding serves
|
||||
to obfuscate the program as well as reduce the number of countable
|
||||
characters and get the program under the size limit of this year's IOCCC.
|
||||
There are some places where other simple encoding methods are used to
|
||||
hide the real purpose of strings. These layers of obscurity cannot be
|
||||
penetrated by just preprocessing and beautifying the program.
|
||||
|
||||
Fifth, various small obfuscations have been used in places all over the
|
||||
program. Short circuit evaluation is used as a substitute for if()
|
||||
statements in some places. The ternary operator is used. In the
|
||||
author's opinion, use of the ternary operator is almost always a strong
|
||||
argument for employee turnover.
|
||||
|
||||
Last, if you have succeeded in wading through the previous layers of
|
||||
obfuscation, you are confronted by the fact that the game that it
|
||||
implements is an obscure game. Casual inspection of the program might
|
||||
lead one to believe that it is an implementation of classic chess, but
|
||||
this is not so.
|
||||
|
||||
Q: What about the compiler warnings?
|
||||
|
||||
A: When compiled with gcc -Wall, the compiler generated the following
|
||||
warnings:
|
||||
|
||||
suggest parentheses around + or - in operand of &
|
||||
array subscript has type 'char'
|
||||
return type defaults to 'int'
|
||||
control reaches end of non-void function
|
||||
value computed is not used
|
||||
|
||||
The "value computed is not used" warning happens because I use the &&
|
||||
operator and take advantage of short circuit evaluation instead of using
|
||||
an if() statement.
|
||||
|
||||
The "suggest parentheses..." warnings are given because of expressions
|
||||
that depend on operator precedence details in the C language.
|
||||
Eliminating these warnings would reduce obfuscation.
|
||||
|
||||
The other warnings are there because it would require more code to
|
||||
eliminate them and that can't be done given the size limit.
|
||||
|
||||
Q: Why does this program crash when it loses?
|
||||
|
||||
A: What better way to admit defeat? The author thought this was
|
||||
appropriate sportsmanship for a program of this genre and can think of
|
||||
no worse job than trying to find an elusive bug in an intentionally
|
||||
obfuscated program.
|
||||
|
||||
[judge's note: This was followed by a description of the bug, and
|
||||
the comment:]
|
||||
|
||||
(Note, if this program wins, the author thinks it would be good to leave
|
||||
this information out of the remarks and encourage others to try and
|
||||
figure it out for themselves)
|
||||
|
||||
[should you be too lazy to figure it out yourself, here's the author's
|
||||
fix. I would have rot13'd it, but the punctuation would have survived.]
|
||||
|
||||
begin 644 fix.txt
|
||||
M5&AI<R!B=6<@8V%N(&)E(&9I>&5D(&EN(&$@;G5M8F5R(&]F('=A>7,L(&)U
|
||||
M="!T:&5R90II<R!A('=A>2!T:&%T(&%D9',@;VYL>2!O;F4@8GET92!T;R!T
|
||||
M:&4@<V]U<F-E(&-O9&4N("!);B!T:&4@<W1A=&5M96YT"G,]*&4]+58H;BTQ
|
||||
M+&\I*3YS/UD]1RQE.G,[(&-H86YG92!T:&4@/B!T;R!A(#X](&%N9"!T:&4@
|
||||
38G5G('=I;&P@8F4@9V]N92X*"FYG
|
||||
`
|
||||
end
|
||||
Reference in new issue
Block a user