Toledo chess program

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Toledo chess program

Post by petersieg »

See here:
https://nanochess.org/chess.html
https://nanochess.org/faq.html

Just wanted to see, if glcc would compile it and if it would even run ;-)

It compiles and runs - but:
It always says 'illegal' to any input - something is wrong at reading and compute input?
Since computer playing is activated with command parameter, this is not working right now.

Maybe the c experts want to have a look at this nice piece of obfuscated source ;-)

Have fun.
Attachments
Bildschirmfoto 2024-04-04 um 12.33.30.png
Bildschirmfoto 2024-04-04 um 12.33.30.png (349.27 KiB) Viewed 421 times
Bildschirmfoto 2024-04-04 um 12.33.16.png
Bildschirmfoto 2024-04-04 um 12.33.16.png (54.19 KiB) Viewed 421 times
toledo.zip
(29.67 KiB) Downloaded 16 times
lb3361
Posts: 367
Joined: 17 Feb 2021, 23:07

Re: Toledo chess program

Post by lb3361 »

From the FAQ
Screenshot 2024-04-05 at 08.02.18.png
Screenshot 2024-04-05 at 08.02.18.png (549.29 KiB) Viewed 389 times
Checked on ROMv6.
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Re: Toledo chess program

Post by petersieg »

Thanks! I just did the required changes for modern C++ compiler. But now I replaced all occurrences of 1e5 with 2e4, and 1e9 with 3e4 and it runs fine now. Now we just need to figure out, how to have computer play black ;-)

best, Peter
Attachments
Bildschirmfoto 2024-04-05 um 11.56.59.png
Bildschirmfoto 2024-04-05 um 11.56.59.png (62.93 KiB) Viewed 377 times
toledo.zip
(18.81 KiB) Downloaded 13 times
lb3361
Posts: 367
Joined: 17 Feb 2021, 23:07

Re: Toledo chess program

Post by lb3361 »

petersieg wrote: 05 Apr 2024, 09:57 Thanks! I just did the required changes for modern C++ compiler. But now I replaced all occurrences of 1e5 with 2e4, and 1e9 with 3e4 and it runs fine now. Now we just need to figure out, how to have computer play black ;-)

best, Peter
According to the web page, one has to invoke it with one dummy argument to make it play black.
Because there is no command line, glcc programs always start with argc=0 and argv=0.
But here we just have to change this

Code: Select all

int main(int argc, char *argv[])
{
  X((int)argc, 0, 0, 0);
}
into

Code: Select all

int main(int argc, char *argv[])
{
  X(2, 0, 0, 0);
}
This is not fast. Compiling for v6 or dev7 is a bit faster because of the faster multiplication code, but be ready to wait minutes between turns...

To compare with MSCP, go to https://www.gigatron128k.com, select "SpiCard", then "Apps", then "MSCP", then "mscp_128k.gt1".
This is a much bigger program.
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Re: Toledo chess program

Post by petersieg »

Thx. On PC with i5 3GHz, the answer is instantly. On Gigatron emulation, I had to wait probably "hours" (broken up - hat to go).
I will test on real hardware the next days.

best, Peter
Attachments
Bildschirmfoto 2024-04-07 um 19.20.21.png
Bildschirmfoto 2024-04-07 um 19.20.21.png (42.09 KiB) Viewed 325 times
lb3361
Posts: 367
Joined: 17 Feb 2021, 23:07

Re: Toledo chess program

Post by lb3361 »

Replacing all the 1e4, 2e4, 3e4 by integers 10000,20000,30000 should make it run a bit faster.
Otherwise the expression is promoted to floating point which is emulated in software.
Still waiting ... is something wrong?
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Re: Toledo chess program

Post by petersieg »

ok.
Did that. In small sdl2 emu, I am waiting now app. 50min for any computer answer. In real HW, with 128kd7 rom, I am waiting now app. 30min.
No computer answer? I compiled again for PC i5 3k. Runs fine and answer is instandly there.

??

best, Peter
Attachments
toledo.zip
(39.28 KiB) Downloaded 18 times
lb3361
Posts: 367
Joined: 17 Feb 2021, 23:07

Re: Toledo chess program

Post by lb3361 »

The main difference is the size of integers, two bytes vs four bytes. The faq says that it can work, but that might be old information. It might also be possible that glcc has a bug but this is not the right way to isolate it (obfuscation does not help debugging).
veekoo
Posts: 123
Joined: 07 Jun 2021, 07:07

Re: Toledo chess program

Post by veekoo »

- I tried this in Linux X86 and it runs ok. Responds in a second. Compiled with GCC shows no errors.

- Then I tried Gigatron version and it runs forever to respond to move. It took more than hour to respond. Compiled with GLCC it showed couple of errors, but those were easy to fix with return 0;

Code: Select all

../CODE/toledo.c:14: warning: missing return value
../CODE/toledo.c:79: warning: missing return value
- I gave a try with OpenAI / ChatGPT to cleanup the code. It was too complex to cleanup and I don't think it's a real AI processing it. ;)

- Second try with OpenAI / ChatGPT was to make similar chess game that AI would make. Well it is not up to making full games.

There is nothing else besides microchess that can run so small amount of memory.
https://github.com/kervinck/gigatron-ro ... Microchess
lb3361
Posts: 367
Joined: 17 Feb 2021, 23:07

Re: Toledo chess program

Post by lb3361 »

I added some printf() into the code to debug. Looking at the output and comparing with the same on a PC, I realized that the Gigatron would take about 12 hours to answer an initial e2e4. (compiled for the dev7 rom).

Then I compiled a gtsim version because gtsim runs faster than real hardware. It plays!

Code: Select all

$ glcc -rom=dev7 -map=sim -o toledos.gt1 toledo.c
...
$ gtsim -rom=.../dev7.rom -vmode=1975 toledos.gt1
e2e4
...
Post Reply