Porting for MorphOS of chess program Stockfish
  • Just looking around
    Posts: 12 from 2020/8/2
    Good morning!!

    I'm writing to ask help on development of a modern chess program for MorphOS. On the OS4 platform, I released Amifish, a GUI for the chess engine Stockfish, a command line program UCI compliant (Universal Chess Interface). Some time ago, I released MorphOS version also, but MorphOS version of Stockfish wasn't existing, so I used another engine, Predateur.

    Stockfish is a very strong program, free and opensource. Is wrote in C++ language. Moreover, several forks of that project are born.

    The goal I want to achieve, is to give to the Amiga community a modern chess program, for several platforms (OS4, AROS, MorphOS), releasing it for free.

    I tried several times to compile Stockfish, but I never did. I ask if someone is able to do it, and if so, to contact me, as I have an optimal version of Stockfish in order to give a complete program to the community, because it can manage both the opening books and the Syzygy tables of the finals. It would therefore be excellent, in my opinion, to port this version instead of the one available on the official website of Stockfish, which has the advantage of giving the strongest algorithm, but does not support the opening books, which I could not easily implement in the GUI. If it can help, Stockfish has already been ported for OS4 and AROS, the makefile of these versions can be a help to make others.
    Some links on the topic:

    STOCKFISH
    https://stockfishchess.org/

    AMIFISH FOR MORPHOS:
    https://www.morphos-storage.net/?id=1532021

    STOCKFISH FOR OS4:
    https://aminet.net/package/game/board/stockfish-5-amigaos4

    STOCKFISH FOR AROS:
    http://archives.aros-exec.org/index.php?function=showfile&file=game/misc/stockfish5_aros-i386.zip

    Thanks in advance
    Domenico
  • »02.08.20 - 10:17
    Profile
  • Yokemate of Keyboards
    Yokemate of Keyboards
    amigadave
    Posts: 2789 from 2006/3/21
    From: Northern Calif...
    Hello domenikov,


    I usually demonstrate MorphOS at the annual AmiWest Show in Sacramento, California, each October, and from what I have seen recently, the show is still planned to go forward this year, even though there is the risk of COVID-19. Reading your thread here gave me the idea to challenge someone who owns an A-Eon X5000 running AmigaOS4, to a friendly chess game, if someone here can provide a working port of Stockfish for MorphOS, for me to run on either my 2.7GHz G5 PowerMac, or hopefully the Quad G5 PowerMac I will be picking up around the middle of this month, from fellow member here, Doffo. I'm trading to him one or two of my Classic Amiga big box systems, but we have not worked out all of the trade details yet.

    So, if you or someone else that has good porting skills can complete the port of Stockfish to MorphOS in time for this year's AmiWest Show, I will issue a friendly challenge to one of the show attendee's, perhaps Alex Perez, or Bill Bosari. It could be a fun event to watch during the show.
    MorphOS - The best Next Gen Amiga choice.
  • »02.08.20 - 22:24
    Profile
  • Just looking around
    Posts: 12 from 2020/8/2
    Hello amigadave,

    what you have in mind is an interesting challenge! I'd like to see Stockfish's performance under the more powerful Amiga systems.
  • »04.08.20 - 08:23
    Profile
  • MorphOS Developer
    zukow
    Posts: 602 from 2005/2/9
    From: Poland
    I usually play on lichess.org which uses Stockfish, although they changed some internals and it stopped working with Odyssey and under Wayfarer beta it works without visible chess pieces movement (probably the same problem as in twitter).
  • »04.08.20 - 09:12
    Profile Visit Website
  • Paladin of the Pegasos
    Paladin of the Pegasos
    koszer
    Posts: 1121 from 2004/2/8
    From: Poland
    Quote:

    amigadave wrote:
    I will issue a friendly challenge to one of the show attendee's, perhaps Alex Perez, or Bill Bosari. It could be a fun event to watch during the show.



    ...and the winner takes the loosers' hardware. That would be exciting. As exciting as... a chess game can be :)
  • »04.08.20 - 11:36
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    Tom01
    Posts: 168 from 2009/9/20
    Quote:

    koszer wrote:
    Quote:

    amigadave wrote:
    I will issue a friendly challenge to one of the show attendee's, perhaps Alex Perez, or Bill Bosari. It could be a fun event to watch during the show.



    ...and the winner takes the loosers' hardware. That would be exciting. As exciting as... a chess game can be :)


    What?
    Yes, I also don't like Chess. Checkers is much better.
  • »05.08.20 - 03:17
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    eliot
    Posts: 554 from 2004/4/15
    I just had a look quick into the sources of Stockfish.
    As far as can see the mmap stuff needs to be replaced, that should be all.
    I can do the changes in the next few weeks if nobody else had done this till then.
    But it should not be too hard to get this stuff running on Mos.
    regards
    eliot
  • »05.08.20 - 08:00
    Profile
  • Just looking around
    Posts: 12 from 2020/8/2
    Quote:

    eliot wrote:
    I just had a look quick into the sources of Stockfish.
    As far as can see the mmap stuff needs to be replaced, that should be all.
    I can do the changes in the next few weeks if nobody else had done this till then.
    But it should not be too hard to get this stuff running on Mos.


    GREAT! As I told before, I have a slightly different version, outdated for the strenght, but more complete: it supports opening books, starting from Stockfish 6 aren't supported anymore. Using the functionality of the engine to access books, there will be no need to implement this functionality in the GUI. Contact me if you want to receive this version.

    In this moment, is important to have an UCI interface with all important features, and a strong chess engine. Other functionalities can be added subsequently.
  • »05.08.20 - 09:32
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    eliot
    Posts: 554 from 2004/4/15
    I checked out the current master from git.
    First compile errors were in one cpp file
    where mmap etc was used.
    All other cpps seem to be fine.
    Really a just a ten minutes quick look into
    the sources. There might be more?!
    regards
    eliot
  • »05.08.20 - 18:05
    Profile
  • Just looking around
    Posts: 12 from 2020/8/2
    Quote:

    eliot wrote:
    I checked out the current master from git.
    First compile errors were in one cpp file
    where mmap etc was used.
    All other cpps seem to be fine.
    Really a just a ten minutes quick look into
    the sources. There might be more?!


    I gave a look at sources of Stockfish 5 ported on OS4 and AROS. No references to mmap found, if you want to give a try...

    In the complete version that I would like to port, there are some mmap references, so at moment I don't know if it is a good idea to submit it to you. There would be the same problem.
  • »05.08.20 - 21:46
    Profile
  • Just looking around
    Posts: 12 from 2020/8/2
    I found this version of Stockfish very interesting to be ported to the Amiga, CFish, which is a port of Stockfish from the C ++ language to the C language:

    CFish on GitHub

    It seems optimal to me for many reasons:

    - Can directly exploit the books of the openings in bin format for an excellent conduction of the opening
    - Can take advantage of the Syzygy endings tables (for those curious: https://syzygy-tables.info), for perfect play in the final phase of the game
    - Possibility to launch more threads making the most of any multicore CPU present
    - Thanks to the NNUE (Efficiently Updatable Neural Network) options, it can evaluate the moves to be played even with neural networks (a feature recently introduced in chess programs) and improving its game game after game, thanks to the recording of its learning on file.

    With the last feature listed, we would have on the Amiga a very modern chess program that would have nothing to envy to others!

    The official Stockfish version, on the other hand, does not have support for opening books which is instead delegated to the interface that hosts it and that is why I recommend porting CFish (which, on the other hand, supports them) instead of Stockfish.
  • »04.04.21 - 15:13
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    polluks
    Posts: 665 from 2007/10/23
    From: Gelsenkirchen,...
    At least I have an executable with this hack
    Code:
    --- misc.c.bak	2021-04-04 19:45:23 +0200
    +++ misc.c 2021-04-04 20:41:57 +0200
    @@ -315,6 +315,30 @@
    }
    #endif

    +#ifdef __MORPHOS__
    +void flockfile(FILE *F)
    +{
    +#if 0
    + if ((F >= (&__iob_func()[0])) && (F <= (&__iob_func()[_IOB_ENTRIES-1]))) {
    + _lock(_STREAM_LOCKS + (int)(F - (&__iob_func()[0])));
    + F->_flag |= _IOLOCKED;
    + } else
    + EnterCriticalSection(&(((_FILEX *)F)->lock));
    +#endif
    +}
    +
    +void funlockfile(FILE *F)
    +{
    +#if 0
    + if ((F >= (&__iob_func()[0])) && (F <= (&__iob_func()[_IOB_ENTRIES-1]))) {
    + F->_flag &= ~_IOLOCKED;
    + _unlock(_STREAM_LOCKS + (int)(F - (&__iob_func()[0])));
    + } else
    + LeaveCriticalSection(&(((_FILEX *)F)->lock));
    +#endif
    +}
    +#endif
    +
    FD open_file(const char *name)
    {
    #ifndef _WIN32
    Pegasos II G4: MorphOS 3.9, Zalman M220W · iMac G5 12,1 17"
    Power Mac G3: OSX 10.3 · PowerBook 5,8: OSX 10.5, MorphOS 3.15
  • »04.04.21 - 19:55
    Profile
  • Just looking around
    Posts: 12 from 2020/8/2
    Great! To test if it works, launch it from a Shell, then try to give to it the command "uci" (typed with the keyboard, followed by return). This type of output would appear on the console:

    ========================
    option name Contempt type spin default 24 min -100 max 100
    option name Analysis Contempt type combo default Off var Off var White var Black
    option name Threads type spin default 1 min 1 max 512
    option name Hash type spin default 16 min 1 max 33554432
    option name Clear Hash type button
    option name Ponder type check default false
    option name MultiPV type spin default 1 min 1 max 500
    option name Move Overhead type spin default 10 min 0 max 5000
    option name Slow Mover type spin default 100 min 10 max 1000
    option name nodestime type spin default 0 min 0 max 10000
    option name UCI_AnalyseMode type check default false
    option name UCI_Chess960 type check default false
    option name SyzygyPath type string default <empty>
    option name SyzygyProbeDepth type spin default 1 min 1 max 100
    option name Syzygy50MoveRule type check default true
    option name SyzygyProbeLimit type spin default 7 min 0 max 7
    option name SyzygyUseDTM type check default true
    option name BookFile type string default <empty>
    option name BookFile2 type string default <empty>
    option name BestBookMove type check default true
    option name BookDepth type spin default 255 min 1 max 255
    option name EvalFile type string default nn-62ef826d1a6d.nnue
    option name Use NNUE type combo default Hybrid var Hybrid var Pure var Classical
    option name LargePages type check default true
    uciok
    ========================

    Is this what happens (less or more)?
  • »04.04.21 - 21:01
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    polluks
    Posts: 665 from 2007/10/23
    From: Gelsenkirchen,...
    Code:
    Cfish 040421 by Syzygy based on Stockfish
    uci
    id name Cfish 040421
    id author The Stockfish developers

    option name Contempt type spin default 24 min -100 max 100
    option name Analysis Contempt type combo default Off var Off var White var Black
    option name Threads type spin default 1 min 1 max 512
    option name Hash type spin default 16 min 1 max 2048
    option name Clear Hash type button
    option name Ponder type check default false
    option name MultiPV type spin default 1 min 1 max 500
    option name Move Overhead type spin default 10 min 0 max 5000
    option name Slow Mover type spin default 100 min 10 max 1000
    option name nodestime type spin default 0 min 0 max 10000
    option name UCI_AnalyseMode type check default false
    option name UCI_Chess960 type check default false
    option name SyzygyPath type string default <empty>
    option name SyzygyProbeDepth type spin default 1 min 1 max 100
    option name Syzygy50MoveRule type check default true
    option name SyzygyProbeLimit type spin default 5 min 0 max 5
    option name SyzygyUseDTM type check default true
    option name BookFile type string default <empty>
    option name BookFile2 type string default <empty>
    option name BestBookMove type check default true
    option name BookDepth type spin default 255 min 1 max 255
    option name LargePages type check default true
    uciok
    Pegasos II G4: MorphOS 3.9, Zalman M220W · iMac G5 12,1 17"
    Power Mac G3: OSX 10.3 · PowerBook 5,8: OSX 10.5, MorphOS 3.15
  • »06.04.21 - 23:09
    Profile
  • Just looking around
    Posts: 12 from 2020/8/2
    FANTASTIC!

    I would be happy if you can release it somewhere (MorphOS storage, Aminet...), with sources and makefile.

    Being CFish a derivative of Stockfish, GPL license request the source; but this can also be useful for someone who want to port CFish to other platforms (OS4, AROS).

    Contact me by PM if you need.

    Congratulations, what you made is very important to develop a complete chess program!
  • »07.04.21 - 18:32
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    polluks
    Posts: 665 from 2007/10/23
    From: Gelsenkirchen,...
    Take a look.
    Pegasos II G4: MorphOS 3.9, Zalman M220W · iMac G5 12,1 17"
    Power Mac G3: OSX 10.3 · PowerBook 5,8: OSX 10.5, MorphOS 3.15
  • »11.04.21 - 09:47
    Profile
  • Just looking around
    Posts: 12 from 2020/8/2
    Quote:

    polluks wrote:
    Take a look.


    In this video I don't see Cfish in action, but Predateur (?)

    Is possible to have Cfish executable so I can give it a try?
  • »12.10.21 - 18:02
    Profile