Fix 2006/toledo3 + format fix README.md

The problem with the crash is that it relied on 32-bit sized ints. Some
of these were changed to longs instead.
This commit is contained in:
Cody Boone Ferguson committed 2023-05-01 05:44:08 -07:00
1 parent 15af4f67e8
commit 54d9461d77
3 files changed
+47 -33

No files matched your search

+43 -30
View File
@@ -1,10 +1,7 @@
# Most Portable Chess Set # Most Portable Chess Set
Oscar Toledo Oscar Toledo
Av. Santa Cruz del Monte 9-304 Mexico
Ciudad Satelite. Edo. de Mexico
CP. 53110
Mexico
## To build: ## To build:
@@ -18,12 +15,28 @@ make
./toledo3 [1 | 2 | 3 [b]] ./toledo3 [1 | 2 | 3 [b]]
``` ```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed a crash and a
display problem in this entry so that it would work in modern (64-bit) systems.
The problem was that it relied on 32-bits so some `int`s were changed to
`long`s. At this time we don't have an easy way to test this theory but it might
be that using `-m32` would let this work in 32-bit systems. Thank you Cody for
your assistance!
## Try: ## Try:
```sh ```sh
./toledo3 1 ./toledo3 1
``` ```
### Alternate versions:
The author provided two additional versions, [toledo3-sbar.c](toledo3-sbar.c)
and [toledo3-txt.c](toledo3-txt.c). Respectively these create a status bar and
make the game text only. These are built by default.
Use `toledo3-sbar` and `toledo3-txt` as you would `toledo3` above.
## Judges' remarks: ## Judges' remarks:
It's pretty obvious from looking at it what this program does, It's pretty obvious from looking at it what this program does,
@@ -34,12 +47,11 @@ the code for Deep Blue.
## Author's remarks: ## Author's remarks:
There are so many text-based chess programs, what is that of There are so many text-based chess programs, what is that of
A1, H5, C4, D5? The queen is really pointing to the king? `A1`, `H5`, `C4`, `D5`? The queen is really pointing to the king?
So I managed to do a graphical X11 chess program (WYSIAIE, or So I managed to do a graphical X11 chess program ('`WYSIAIE`', or 'What You See
What You See Is An IOCCC Entry), point'n'click to move pieces Is An IOCCC Entry'). Pointing and clicking to move pieces is the only required
is the only required action, and of course the command-line action, and of course the command-line options:
options:
```sh ```sh
./toledo3 # Two-players mode (useful if you don't have a board at hand) ./toledo3 # Two-players mode (useful if you don't have a board at hand)
@@ -51,7 +63,7 @@ options:
./toledo3 3 b # Human black - Computer white, level 3 (slow) ./toledo3 3 b # Human black - Computer white, level 3 (slow)
``` ```
The computer will check that your moves are legal, full legal The computer will check that your moves are legal. Full legal
chess moves are allowed, except minor promotions on human side. chess moves are allowed, except minor promotions on human side.
The game will continue up to its logical conclusion, you make The game will continue up to its logical conclusion, you make
@@ -59,37 +71,38 @@ a mistake and the computer surpasses you. ;)
### WHAT ABOUT THE ENGINE ### WHAT ABOUT THE ENGINE
Uses an alpha-beta search up to a depth of 3+level ply, extended Uses an [alpha-beta](https://en.wikipedia.org/wiki/Alpha_Beta) search up to a
with quiescence search, that helps playing strength, something depth of 3+level [ply](https://en.wikipedia.org/wiki/Ply_(game_theory)),
around 1500 ELO (level 1) to 1700 ELO (level 3) extended with quiescence search, that helps playing strength, something around
1500 ELO (level 1) to 1700 ELO (level 3).
It searches the board and generates moves for each piece located, It searches the board and generates moves for each piece located. A lot of
a lot of comparisons are used for empassant, castling and comparisons are used for [en passant](https://en.wikipedia.org/wiki/En_passant),
promotion. Would be faster with optimizations, but that castling and promotion. Would be faster with optimizations, but that
optimizations use valuable IOCCC characters. optimizations use valuable IOCCC characters.
It plays a different game every time, using the C library random It plays a different game every time, using the C library random
number generator. number generator.
Because it is resource-hungry, I strongly recommend to compile it Because it is resource-hungry, I strongly recommend to compile it
using maximum optimization, on GCC you can use: using maximum optimization. With GCC you can use:
``` ```sh
gcc -O3 -fexpensive-optimizations prog.c -o prog -lX11 gcc -O3 -fexpensive-optimizations prog.c -o prog -lX11
``` ```
### KNOWN "FEATURES" ### KNOWN "FEATURES"
1. Because this is my second X11 program (the first was 1. Because this is my second X11 program (the first was
point'n'click happy face), I added sentences everywhere point n click happy face), I added sentences everywhere
until it worked. :) until it worked. :)
2. It is portable to Wind*ws (using the supplied layer.c file) 2. It is portable to Windows (using the supplied layer.c file)
Change #include <X11/Xlib.h> to #include "layer.c" and Change `#include <X11/Xlib.h> to #include "layer.c"` and
use a Wind*ws compiler (only tested with Dev C/C++ 4.9.9.2) use a Windows compiler (only tested with Dev C/C++ 4.9.9.2)
The play level is fixed, though you can change it easily. The play level is fixed, though you can change it easily.
Of course, this is an example of an obfuscated Wind*ws Of course, this is an example of an obfuscated Windows
program (there exists another way of write them?) program (there exists another way of write them?).
3. It will give warnings on compilation, so you can be sure 3. It will give warnings on compilation, so you can be sure
that your compiler works. that your compiler works.
@@ -97,13 +110,13 @@ gcc -O3 -fexpensive-optimizations prog.c -o prog -lX11
4. It will not update the window while it is "thinking" 4. It will not update the window while it is "thinking"
5. The space character has many useful applications, specially 5. The space character has many useful applications, specially
when it comes about the character limit. 8) when it comes to the character limit (8).
6. I still don't understand what to do after semicolons. :P 6. I still don't understand what to do after semicolons. :P
### CHALLENGES ### CHALLENGES
It is possible to convert this code into Javascript with a It is possible to convert this code into JavaScript with a
graphical interface. Can you do it? graphical interface. Can you do it?
Can the evaluation function be enhanced to make the program Can the evaluation function be enhanced to make the program
@@ -111,10 +124,10 @@ play stronger?
### UPGRADES ### UPGRADES
Using toledo3-sbar.c (which is too large for this IOCCC size Using [toledo3-sbar.c](toledo3-sbar.c) (which is too large for this IOCCC size
rules) creates a status display about gameplay on the window title bar, rules) creates a status display about gameplay on the window title bar.
Using toledo3-txt.c turns this into being purely text based. Using [toledo3-txt.c](toledo3-txt.c) turns this into being purely text based.
## Copyright and CC BY-SA 4.0 License: ## Copyright and CC BY-SA 4.0 License:
+2 -2
View File
@@ -10,11 +10,11 @@ Plane(d, r[I[A]+7+14*(i+b>>6&1)+28*(A==z)],w,C,0,0,64,64,b,i,1); XFlush(d);
#define a X(0,0,0, #define a X(0,0,0,
#define H while( #define H while(
#define D ;if( #define D ;if(
long
I[304],b,i,z;main(x,W) char**W; { Display *d = I[304],b,i,z;main(x,W) char**W; { Display *d =
XOpenDisplay(""); Window w = XCreateSimpleWindow XOpenDisplay(""); Window w = XCreateSimpleWindow
(d, DefaultRootWindow(d), 64,64,512,512,2,G(Black) (d, DefaultRootWindow(d), 64,64,512,512,2,G(Black)
,G(Black)); XGCValues g; XButtonEvent e; int A,r ,G(Black)); XGCValues g; XButtonEvent e; long A,r
[56],Z,* m = I , C ,Y; XSelectInput(d,w,32772); [56],Z,* m = I , C ,Y; XSelectInput(d,w,32772);
XMapWindow( d, w); g. foreground = G(White); XMapWindow( d, w); g. foreground = G(White);
C=XCreateGC(d,w,4,&g); F+=48; H f=I,i=0,z<56){ C=XCreateGC(d,w,4,&g); F+=48; H f=I,i=0,z<56){
+2 -1
View File
@@ -11,10 +11,11 @@ Plane(d, r[I[A]+7+14*(i+b>>6&1)+28*(A==z)],w,C,0,0,64,64,b,i,1); XFlush(d);
#define H while( #define H while(
#define D ;if( #define D ;if(
long
I[304],b,i,z;main(x,W) char**W; { Display *d = I[304],b,i,z;main(x,W) char**W; { Display *d =
XOpenDisplay(""); Window w = XCreateSimpleWindow XOpenDisplay(""); Window w = XCreateSimpleWindow
(d, DefaultRootWindow(d), 64,64,512,512,2,G(Black) (d, DefaultRootWindow(d), 64,64,512,512,2,G(Black)
,G(Black)); XGCValues g; XButtonEvent e; int A,r ,G(Black)); XGCValues g; XButtonEvent e; long A,r
[56],Z,* m = I , C ,Y; XSelectInput(d,w,32772); [56],Z,* m = I , C ,Y; XSelectInput(d,w,32772);
XMapWindow( d, w); g. foreground = G(White); XMapWindow( d, w); g. foreground = G(White);
C=XCreateGC(d,w,4,&g); F+=48; H f=I,i=0,z<56){ C=XCreateGC(d,w,4,&g); F+=48; H f=I,i=0,z<56){