Page 1 of 2

Revived Engine - Frank Walter 2.2.0 (Java - WB)

Posted: Tue Nov 20, 2018 3:35 pm
by ljgw
Dear all,

Some months ago I found time and interest again to work on my computer chess hobby and I have revived my old engine Frank Walter.

It can be downloaded from http://computer-chess.org/doku.php?id=c ... lter:index

Frank Walter is a Java chess engine with the following features

* Bitboard legal move generator using magic bitboards and kindergarten bitboards
* Principle Variation Search with aspiration window.
* Mostly Piece-Square value based evaluation (tuned using texels tuning method and the zurichess quiet positions set)
* Easy to understand opening-book format (Beowulf format)
* Syzygy Tablebases support (dependant on platform: I have only compiled the native code for linux)

Perhaps the most interesting feature is the ability to use Syzygy Tablebases in a Java engine. To get this to work I've taken the Fathom program from Basil00 with the modifications from Jon Dart and compiled it into a libraby that is accessible from java using JNI. As I have little experience compiling c/c++ I currently only built this library for a linux environment. I would be interested to know if anyone can compile the code (located here https://github.com/ljgw/Fathom) into a DLL and/or a MacOs library.

I want to thank Ron Murawski for hosting the engine for me on computer-chess.org, more acknowledgements are there:-)

At some point I plan to make the source code available via my github account, but the quality is not sufficient yet - most parts come from before 2009 and I'd like to think I can write nicer code now^^.

Re: Revived Engine - Frank Walter 2.2.0 (Java - WB)

Posted: Tue Nov 20, 2018 5:36 pm
by Ratosh
Congrats on your project! Really nice to have Syzygy TB support in Java!

Re: Revived Engine - Frank Walter 2.2.0 (Java - WB)

Posted: Tue Nov 20, 2018 7:57 pm
by Graham Banks
ljgw wrote:
Tue Nov 20, 2018 3:35 pm
Dear all,

Some months ago I found time and interest again to work on my computer chess hobby and I have revived my old engine Frank Walter.

It can be downloaded from http://computer-chess.org/doku.php?id=c ... lter:index

Frank Walter is a Java chess engine with the following features

* Bitboard legal move generator using magic bitboards and kindergarten bitboards
* Principle Variation Search with aspiration window.
* Mostly Piece-Square value based evaluation (tuned using texels tuning method and the zurichess quiet positions set)
* Easy to understand opening-book format (Beowulf format)
* Syzygy Tablebases support (dependant on platform: I have only compiled the native code for linux)

Perhaps the most interesting feature is the ability to use Syzygy Tablebases in a Java engine. To get this to work I've taken the Fathom program from Basil00 with the modifications from Jon Dart and compiled it into a libraby that is accessible from java using JNI. As I have little experience compiling c/c++ I currently only built this library for a linux environment. I would be interested to know if anyone can compile the code (located here https://github.com/ljgw/Fathom) into a DLL and/or a MacOs library.

I want to thank Ron Murawski for hosting the engine for me on computer-chess.org, more acknowledgements are there:-)

At some point I plan to make the source code available via my github account, but the quality is not sufficient yet - most parts come from before 2009 and I'd like to think I can write nicer code now^^.
Good news. :)
Roughly how strong do you estimate the new version to be?

Re: Revived Engine - Frank Walter 2.2.0 (Java - WB)

Posted: Tue Nov 20, 2018 9:07 pm
by ljgw
Hi Graham,

I'd say it should be comparable to OliThink.
This is actually the engine I tested against most - first mostly losing in quick tournaments, so it was nice to see the improvement to being on par with it.
I must add though that this was on linux where
1) I can use the Syzygy tablebases that help my engine to not throw away endgames
2) I'm not sure I used the strongest OliThink Build

--Laurens

Re: Revived Engine - Frank Walter 2.2.0 (Java - WB)

Posted: Tue Nov 20, 2018 9:09 pm
by Graham Banks
ljgw wrote:
Tue Nov 20, 2018 9:07 pm
Hi Graham,

I'd say it should be comparable to OliThink.
This is actually the engine I tested against most - first mostly losing in quick tournaments, so it was nice to see the improvement to being on par with it.
I must add though that this was on linux where
1) I can use the Syzygy tablebases that help my engine to not throw away endgames
2) I'm not sure I used the strongest OliThink Build

--Laurens
Thanks Laurens.
I'll pencil Frank Walter in for my next Amateur Series. :-)

Re: Revived Engine - Frank Walter 2.2.0 (Java - WB)

Posted: Tue Nov 20, 2018 9:13 pm
by ljgw
Nice, thanks!

It will be nice seeing it compete again:-)

Re: Revived Engine - Frank Walter 2.2.0 (Java - WB)

Posted: Sat Nov 24, 2018 6:46 am
by tpoppins
Laurens, I tried compiling JSyzygy.dll under MSYS2/MinGW with GCC 8.2.0 under Win 7 x64 Pro SP1 following your instructions. My CMDline to accommodate the JDK 1.8.0 update 191 path is

Code: Select all

g++ -std=c++14 -O2 -Wall -D TB_USE_ATOMIC -D TB_NO_HW_POP_COUNT -fPIC -I"C:\Program Files\Java\jdk1.8.0_191\include" -I"C:\Program Files\Java\jdk1.8.0_191\include\win32" -shared -o JSyzygy.dll tbprobe.c
The library compiles without errors, with the following warnings:

Code: Select all

tbprobe.c: In function 'unsigned int tb_probe_wdl_impl(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, unsigned int, bool)':
tbprobe.c:1822:5: warning: narrowing conversion of 'ep' from 'unsigned int' to 'uint8_t' {aka 'unsigned char'} inside { } [-Wnarrowing]
     };
     ^
tbprobe.c: In function 'unsigned int tb_probe_root_impl(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, unsigned int, unsigned int, bool, unsigned int*)':
tbprobe.c:1857:5: warning: narrowing conversion of 'rule50' from 'unsigned int' to 'uint8_t' {aka 'unsigned char'} inside { } [-Wnarrowing]
     };
     ^
tbprobe.c:1857:5: warning: narrowing conversion of 'ep' from 'unsigned int' to 'uint8_t' {aka 'unsigned char'} inside { } [-Wnarrowing]
In file included from tbprobe.c:116:
tbcore.c: At global scope:
tbcore.c:42:15: warning: 'TB_MUTEX' defined but not used [-Wunused-variable]
 static LOCK_T TB_MUTEX;
               ^~~~~~~~
The resulting DLL is 598 KB. Running Frank-Walter with this DLL and the java.exe from the Java JRE included in the above-mentioned JDK package results in this error:

Code: Select all

C:\Program Files\ChessBase\Engines.x64\CCRL>"C:\Program Files\Java\jre1.8.0_191\
bin\java.exe" -Xmx1024M -jar frankwalter-220.jar -tt 24 -tb e:\345
#[INFO ] 2018-11-24 01:23:26.765 [MAIN] ZobristHash - Created new ZobristHash
#[INFO ] 2018-11-24 01:23:26.765 [MAIN] ZobristHash - Created new ZobristHash
#[DEBUG] 2018-11-24 01:23:26.775 [MAIN] Board - Assertions are disabled.
#[INFO ] 2018-11-24 01:23:26.785 [MAIN] FrankWalter - Started FrankWalter 2.2.0-
SNAPSHOT
#[DEBUG] 2018-11-24 01:23:26.785 [MAIN] FWConfig - DEBUG : false
#[DEBUG] 2018-11-24 01:23:26.785 [MAIN] FWConfig - TT_SIZE : 24
#[DEBUG] 2018-11-24 01:23:26.785 [MAIN] FWConfig - TB_LOCATION : e:\345
#[INFO ] 2018-11-24 01:23:26.785 [MAIN] SyzygyBridge - looking for JSyzygy.dll a
t location C:\Program Files\ChessBase\Engines.x64\CCRL\JSyzygy.dll
#[INFO ] 2018-11-24 01:23:26.785 [MAIN] SyzygyBridge - loaded JSyzygy.dll
Exception in thread "MAIN" java.lang.UnsatisfiedLinkError: com.winkelhagen.chess
.syzygy.SyzygyBridge.init(Ljava/lang/String;)Z
        at com.winkelhagen.chess.syzygy.SyzygyBridge.init(Native Method)
        at com.winkelhagen.chess.syzygy.SyzygyBridge.load(SyzygyBridge.java:78)
        at com.winkelhagen.chess.frankwalter.FrankWalter.loadTablebases(FrankWalter.java:58)
        at com.winkelhagen.chess.frankwalter.FrankWalter.main(FrankWalter.java:39)
"-debug" doesn't throw more light on this, in fact it stops at the "loaded JSyzygy.dll" line.

Also tried compiling under Cygwin. The compiled DLL is around 160 KB (same warnings as with MinGW) and with it Frank-Walter simply exits after the "loaded JSyzygy.dll" line without printing any errors.

Re: Revived Engine - Frank Walter 2.2.0 (Java - WB)

Posted: Sat Nov 24, 2018 9:26 am
by ljgw
Hi Tirsa

Thank you for your efforts to compile a windows version of the library! I have put some effort into compiling it for windows, but I failed. Mostly I had errors loading the library, while your error (the first attempt) seems to be after that phase.

Would it be possible to share your dll with me so that I can analyse it with dependency walker? Perhaps it will bring me closer to creating a working dll:-) if nothing else it will increase my understanding a fraction.

Thank you again,
--Laurens

Re: Revived Engine - Frank Walter 2.2.0 (Java - WB)

Posted: Sat Nov 24, 2018 1:11 pm
by ljgw
Hi Tirsa,

I tried compiling and testing again today (tried MSYS2 this time) and it compiles without warnings with:

Code: Select all

g++ -std=c++14 -O2 -Wall -D TB_USE_ATOMIC -DTB_NO_HW_POP_COUNT -D__int64=int64_t -fPIC -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/win32" -shared -o JSyzygy.dll tbprobe.c
(note the -D__int64=int64_t option needed on my machine)

The resulting dll was about 159k.

Unfortunately I can now also see that Frank Walter crashes after loading the library. I will need to add some debug logging to the library or find a way to debug via JNI in Java. I hope I have some time to experiment with this in the coming time.

I have one important question left though;
Can you confirm that the chess engine works on windows when no library is provided? Of course tablebases would not be used then.

Re: Revived Engine - Frank Walter 2.2.0 (Java - WB)

Posted: Sat Nov 24, 2018 9:54 pm
by ljgw
Hi Tirsa,

I've managed to build a library using mingw. I made it so that I can use gcc for gnu99 (again)
C:\opt\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0>echo off
Microsoft Windows [Version 10.0.17134.407]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\>cd "C:\Users\Laurens Winkelhagen\git\deneb\Fathom\src"

C:\Users\Laurens Winkelhagen\git\deneb\Fathom\src>gcc -std=gnu99 -O2 -Wall -D TB_USE_ATOMIC -DTB_NO_HW_POP_COUNT -fPIC -I"%JAVA_HOME%/include" -I"%JAVA_HOME%/include/win32" -shared -o JSyzygy.dll tbprobe.c
In file included from tbprobe.c:131:
tbcore.c: In function 'unmap_file':
tbcore.c:201:47: warning: format '%d' expects argument of type 'int', but argument 3 has type 'DWORD' {aka 'long unsigned int'} [-Wformat=]
fprintf(stderr, "unmap failed, error code %d", GetLastError());
~^ ~~~~~~~~~~~~~~
%ld
tbcore.c:201:47: warning: format '%d' expects argument of type 'int', but argument 3 has type 'DWORD' {aka 'long unsigned int'} [-Wformat=]
fprintf(stderr, "unmap failed, error code %d", GetLastError());
~^ ~~~~~~~~~~~~~~
%ld
tbcore.c:204:53: warning: format '%d' expects argument of type 'int', but argument 3 has type 'DWORD' {aka 'long unsigned int'} [-Wformat=]
fprintf(stderr, "CloseHandle failed, error code %d", GetLastError());
~^ ~~~~~~~~~~~~~~
%ld
tbcore.c:204:53: warning: format '%d' expects argument of type 'int', but argument 3 has type 'DWORD' {aka 'long unsigned int'} [-Wformat=]
fprintf(stderr, "CloseHandle failed, error code %d", GetLastError());
~^ ~~~~~~~~~~~~~~
%ld

C:\Users\Laurens Winkelhagen\git\deneb\Fathom\src>
I've added to my fork of the Fathom repository on a different branch

https://github.com/ljgw/Fathom/tree/fea ... r/releases

It works on my machine :-) I hope it will work on yours.

--Laurens