Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

phoenix-cart

Native code version of Walid Maalouli's UCSD-Pascal chess engine for the TI99/4A.

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

Phoenix-Cart

Native code version of Walid Maalouli's UCSD-Pascal chess engine for the TI99/4A (https://github.com/wmaalouli/Phoenix-Chess))

The repository contains a port of the UCSD sources to StatPascal, enabling native 9900 code running in a bank switched cart. To build the cart under Linux, one needs to install StatPascal as a 9900 cross compiler (https://www.github.com/statpascal/spc)) Moreover, the Free Pascal Compiler for Linux is required to generate a binary representation of the the opening book that is linked into the cart.

The original sources are stored in the UCSD directory, the port is contained in the sp directory. The main branch is kept as close as possible to the original UCSD sources and requires SAMS memory. The major changes are a split of some procedures that exceeded the code size limit of 8 KB (the size of a single bank in cartridge address space) and different calling conventions for assembly modules.

Current development is done on the development branch, which only requires a 32K memory extension. Dropping the rather time-consuming SAMS memory management required to interoperate with TI's UCSD system and using native 9900 code it is about 50 times faster than the original UCSD version.

Building the cart

Install the SP compiler and build it as cross compiler for the TI99:

pascal
git clone https://github.com/statpascal/spc statpascal
cd statpascal
make ti99=1

Moreover, the xdt99 cross development tools are required (the SP compiler produces a source file to be assembled with xas99).

The cart uses an opening book that may contain up to 20000 positions, with up to 20 moves for each position (the actual move is picked randomly). A simple example (that one may want to replace) is stored in the file book/opening.txt: the file consists of lines with moves in coordinate notation and optional comment lines starting with #:

pascal
# Four knights
e2e4 e7e5 g1f3 b8c6 b1c3 g8f6 f1b5 f8b4 e1g1 e8g8 d2d3 d7d6
e2e4 e7e5 g1f3 b8c6 b1c3 g8f6 f1b5 f8c5 d2d3 d7d6

For inclusion into the cart, it must be converted to an internal hash format by changing to the book directory and executing the script compile.sh:

pascal
cd book
bash compile.sh opening.txt

This generates the source file sp/cartbook.pas and one or more binary files book0.dat, book1.dat, ... in the book directory.

After that, return to the previous directory and build the cart with

pascal
cd ..
bash build.sh

The last step produces a bank switched cart (phoenix.bin) that can be loaded in an emulator or executed on the real hardware with an FG99.

Building a UCI version

The core engine can be compiled natively to an executable providing a UCI interface; thus enabling fast testing on a modern machine. The file uci.pas provides the required main program.

Game play of the UCI version is the same as in the cartridge for the TI99.

The UCI engine supports the following command line options:

option description
-ply n set ply to n
-qs n set quiescnese search level to n
-nodes n set minimum number of nodes to be evaluated to n * 1000 (increasing ply if not reached after move calculation)
-deepen n increases minimum number of nodes to n times the nodes evaluated in each position. This avoids moving too fast in end game.
-opening fn load opening book from given file (in the format described above)
-log fn log decision tree to given file

The options -nodes and -deepen should not be used together.

Acknowledgements

The chess pieces of the light mode are provided by https://spicygame.itch.io/chess-pieces under a CC0 license.

Phoenix uses a VGA font from IBM available under https://github.com/dhepper/font8x8 which is in the public domain.

Arne Bailliere (https://www.playchessgate.comm provided the DTM tables and greatly improved the program.