Revived Engine - Frank Walter 2.2.0 (Java - WB)

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
ljgw
Posts: 22
Joined: Fri Nov 16, 2018 9:23 am
Full name: Laurens Winkelhagen

Revived Engine - Frank Walter 2.2.0 (Java - WB)

Post by ljgw » 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^^.
Author of JanWillem (C, WB, inactive) and Frank-Walter (Java, WB, http://computer-chess.org/doku.php?id=c ... lter:index)

Ratosh
Posts: 42
Joined: Mon Apr 16, 2018 4:56 pm

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

Post by Ratosh » Tue Nov 20, 2018 5:36 pm

Congrats on your project! Really nice to have Syzygy TB support in Java!

User avatar
Graham Banks
Posts: 31496
Joined: Sun Feb 26, 2006 9:52 am
Location: Auckland, NZ

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

Post by Graham Banks » Tue Nov 20, 2018 7:57 pm

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?
My email addresses:
gbanksnz at gmail.com
gbanksnz at yahoo.co.nz

ljgw
Posts: 22
Joined: Fri Nov 16, 2018 9:23 am
Full name: Laurens Winkelhagen

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

Post by ljgw » 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
Author of JanWillem (C, WB, inactive) and Frank-Walter (Java, WB, http://computer-chess.org/doku.php?id=c ... lter:index)

User avatar
Graham Banks
Posts: 31496
Joined: Sun Feb 26, 2006 9:52 am
Location: Auckland, NZ

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

Post by Graham Banks » Tue Nov 20, 2018 9:09 pm

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. :-)
My email addresses:
gbanksnz at gmail.com
gbanksnz at yahoo.co.nz

ljgw
Posts: 22
Joined: Fri Nov 16, 2018 9:23 am
Full name: Laurens Winkelhagen

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

Post by ljgw » Tue Nov 20, 2018 9:13 pm

Nice, thanks!

It will be nice seeing it compete again:-)
Author of JanWillem (C, WB, inactive) and Frank-Walter (Java, WB, http://computer-chess.org/doku.php?id=c ... lter:index)

tpoppins
Posts: 773
Joined: Tue Nov 24, 2015 8:11 pm
Location: upstate

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

Post by tpoppins » Sat Nov 24, 2018 6:46 am

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.
Tirsa Poppins
CCRL

ljgw
Posts: 22
Joined: Fri Nov 16, 2018 9:23 am
Full name: Laurens Winkelhagen

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

Post by ljgw » Sat Nov 24, 2018 9:26 am

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
Author of JanWillem (C, WB, inactive) and Frank-Walter (Java, WB, http://computer-chess.org/doku.php?id=c ... lter:index)

ljgw
Posts: 22
Joined: Fri Nov 16, 2018 9:23 am
Full name: Laurens Winkelhagen

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

Post by ljgw » Sat Nov 24, 2018 1:11 pm

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.
Author of JanWillem (C, WB, inactive) and Frank-Walter (Java, WB, http://computer-chess.org/doku.php?id=c ... lter:index)

ljgw
Posts: 22
Joined: Fri Nov 16, 2018 9:23 am
Full name: Laurens Winkelhagen

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

Post by ljgw » Sat Nov 24, 2018 9:54 pm

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
Author of JanWillem (C, WB, inactive) and Frank-Walter (Java, WB, http://computer-chess.org/doku.php?id=c ... lter:index)

Post Reply