SpyderTL wrote:How does JavaScript sound? I'm not a huge JS fan, but in this case, I think it makes a lot of sense.
Maybe it would, if you want it to run online and emulate the machine code of the chess playing programs, but that would take a lot of work to set up. I was picturing a simple x86 operating system being adapted to become a host for the competing programs to run under, providing data showing where the pieces are in memory so that both programs can read it (but not alter it), and keeping the two programs and their workspace apart so that they can't interfere with each other.
To write a chess playing program (to run on the host OS), you would assemble or compile it to run at a particular address and to use a restricted address range as workspace, being blocked from using any more than that. These programs would need to know where to find the data about where the pieces are, where the timers are, and how to communicate their moves to the host OS (which would then update the data about where the pieces are). It might initially be best if only one program is run at a time so that it isn't necessary for either to compute speculatively when it isn't its turn to make a move - it would thus know whenever it runs that its timer is ticking down and that its rival has just made a move. The timers' locations would be switched over after each move so that the program always sees its own timer at a fixed location and its rival's timer at a different fixed location (without having to check a variable to work out which timer is its own). The data about where the pieces are would also be adjusted after each move so that the programs don't need to care whether their pieces are black or white - they would simply be labelled in some way as "mine" and "enemy's", and these labels would be swapped by the host on each move so that the program can instantly recognise its own pieces, while the whole board would also be reversed so that the the program always plays in the same direction. This simplifies the chess-playing programs and allows them use their limited program size to focus purely on their game.
The OS would also handle the display of the board for humans to follow the action on, and to allow a human to be the opponent of a program. Setting this up would be a nice OS project for someone (and more than one might be written by different people too). Such an OS could run directly on real hardware or in an emulator, and it should offer a 640x480 graphics mode to make it emulator friendly (with the option of providing something more fancy as a selectable alternative). If a human wants to play against a program, the performance of the program will vary widely depending on the hardware used, but clearly the faster hardware would be better as a good human player should still be able to win with ease - it's unlikely to be a challenge, so the real purpose of playing against a program in this way would simply be to test how well it plays. The length of the game should be adjustable, as should the size of the program space and the size of the workspace (so that the host can adapt to cover different categories of the competition as things evolve in the direction of more complex and capable programs while the rules change to accommodate that).
But, which processor mode should be used for the programs? Real mode is no use as there are no protection mechanisms to stop the programs interfering with each other (or with the data about where the pieces are, or hacking the host). 16-bit modes might disappear from processors too at some point, so it may be best to require 32-bit mode from the start. Would there be compatibility issues between a host OS running protected mode and one using long mode though?
Edit: I realise now that the host program should ideally be an app running on an OS rather than part of an adapted OS, and that it should be able to protect itself in turn from the two chess-playing programs that run "under" it. Is this kind of functionality normally available in any OS with an app placing two binary blobs into their own address spaces and running them whenever it needs to while protecting itself and its data from them?