Jump to page: 1 2
Thread overview
amoeba, a chess engine written in D
May 20, 2016
Richard Delorme
May 21, 2016
extrawurst
May 21, 2016
Richard Delorme
May 22, 2016
Abdulhaq
May 22, 2016
Richard Delorme
May 21, 2016
Johan Engelen
May 21, 2016
Iain Buclaw
May 21, 2016
Richard Delorme
May 22, 2016
Johan Engelen
May 21, 2016
Johan Engelen
May 22, 2016
John Colvin
May 22, 2016
Richard Delorme
May 22, 2016
David Nadlinger
May 22, 2016
David Nadlinger
May 20, 2016
I am pleased to announce the release of a chess engine written in D:
https://github.com/abulmo/amoeba

I am not aware of any other chess engine written with the D language.

The source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster).

This is my first program using the D language (I am a former C programmer), and I enjoyed it a lot.





May 21, 2016
On Friday, 20 May 2016 at 23:16:01 UTC, Richard Delorme wrote:
> I am pleased to announce the release of a chess engine written in D:
> https://github.com/abulmo/amoeba
>
> I am not aware of any other chess engine written with the D language.
>
> The source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster).
>
> This is my first program using the D language (I am a former C programmer), and I enjoyed it a lot.

That is awesome!

Two questions:
1) If it is using UCI protocol I guess there are other engines that you can compare amoeba with when it comes to performance and other aspects, did you ?

2) It would be awesome if you could write down how it was to use D for that project as someone freshly coming from C. What were the reasons you chose D, what did you like, what did u hate ? That would help you being read on reddit by a hundred blood thursty devs (street cred and all) and us for knowing what we can improve and also get the PR :)

Cheers,
Stephan
May 21, 2016
On Friday, 20 May 2016 at 23:16:01 UTC, Richard Delorme wrote:
>
> The source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster).

Can you give cmdline details and compiler version data for this? (how much faster is gdc relative to ldc?)

Thanks,
  Johan

May 21, 2016
On Friday, 20 May 2016 at 23:16:01 UTC, Richard Delorme wrote:
> I am pleased to announce the release of a chess engine written in D:
> https://github.com/abulmo/amoeba

In the makefile, I see you tried LDC's PGO, awesome! I hope to get (part of) it into LDC master very soon. All feedback is very welcome.

(small typo: better use ldc-profdata instead of llvm-profdata)

cheers,
  Johan

May 21, 2016
On 21 May 2016 at 10:23, Johan Engelen via Digitalmars-d-announce <digitalmars-d-announce@puremagic.com> wrote:
> On Friday, 20 May 2016 at 23:16:01 UTC, Richard Delorme wrote:
>>
>>
>> The source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster).
>
>
> Can you give cmdline details and compiler version data for this? (how much faster is gdc relative to ldc?)
>

I think he meant that ldc or gdc is twice as fast.
May 21, 2016
On Saturday, 21 May 2016 at 00:29:13 UTC, extrawurst wrote:
> Two questions:
> 1) If it is using UCI protocol I guess there are other engines that you can compare amoeba with when it comes to performance and other aspects, did you ?

Yes, It is a strong program, but far from the top programs yet.
In the ccrl scale: http://www.computerchess.org.uk/ccrl/4040/
I guess its rating is close to 2700.
The move generator is pretty fast, though:
$ amoeba-linux-x64-sse4.2 perft -d 7
perft  7 :      3195901860 leaves in     17.920 s    178344094 leaves/s

In comparison, stockfish 7, one of the strongest chess program in C++:
$ stockfish-7
perft 7
[...]
Total time (ms) : 16669
Nodes searched  : 3195901860
Nodes/second    : 191727269

So my implementation of a different algorithm in D is only 7% slower at generating moves, which is negligible in the overall program.

> 2) It would be awesome if you could write down how it was to use D for that project as someone freshly coming from C. What were the reasons you chose D, what did you like, what did u hate ? That would help you being read on reddit by a hundred blood thursty devs (street cred and all) and us for knowing what we can improve and also get the PR :)

Good idea, I will try to write something clever and constructive within the next days.

--
Richard

May 21, 2016
On Saturday, 21 May 2016 at 08:23:59 UTC, Johan Engelen wrote:
> On Friday, 20 May 2016 at 23:16:01 UTC, Richard Delorme wrote:
>>
>> The source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster).
>
> Can you give cmdline details and compiler version data for this? (how much faster is gdc relative to ldc?)

I used the following compiler versions,

dmd: DMD64 D Compiler v2.071.0
ldc: 0.17.0-beta2 (DMD v2.068.2, LLVM 3.7.1)
gdc: gcc version 5.2.0 (crosstool-NG 203be35 - 20160205-2.066.1-e95a735b97)

to compile, you can use the following commands:
$ DC=ldc2 make amoeba (to compile with ldc)
$ DC=dmd make amoeba (to compile with dmd)
$ DC=gdc make amoeba  (to compile with gdc)
$ make amoeba (use gdc by default)
$ make pgo (for profile guided optimization),
$ make pgo BUILD=popcount (to use the CPU popcnt instruction)
With the above versions & my poor knowledge of the compilers, pgo & BUILD=popcount only worked with gdc. I will try to upgrade to more recent versions to see if things changed.

to test the speed , you can do:
amoeba bench -f bk.epd -d 14

Here is what I get on my computer (an old i7 2600k at 4Ghz):
    dmd: 24 positions  29981105 nodes in 20.000s : 1499024 nps, depth = 13.71
   ldc2: 24 positions  29981105 nodes in 18.340s : 1634711 nps, depth = 13.71
    gdc: 24 positions  29981105 nodes in 12.005s : 2497388 nps, depth = 13.71
gdc+pgo: 24 positions  29981105 nodes in 10.224s : 2932328 nps, depth = 13.71
* gdc used the BUILD=popcount options. without, it is slower, doing the test in 15.4. & 13.6 s., respectively for gdc & gdc + pgo. So gdc benefits a lot from both pgo and using the popcnt instruction.

--
Richard
May 22, 2016
On Saturday, 21 May 2016 at 16:25:27 UTC, Richard Delorme wrote:
>
> With the above versions & my poor knowledge of the compilers, pgo & BUILD=popcount only worked with gdc. I will try to upgrade to more recent versions to see if things changed.

With LDC, you can pass "-mattr=+popcnt" to use the popcount instruction. Or "-mattr=+sse42" to enable SSE4.2 (like you seem to do in the Makefile).
May 22, 2016
On Friday, 20 May 2016 at 23:16:01 UTC, Richard Delorme wrote:
> I am pleased to announce the release of a chess engine written in D:
> https://github.com/abulmo/amoeba
>
> I am not aware of any other chess engine written with the D language.
>
> The source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster).
>
> This is my first program using the D language (I am a former C programmer), and I enjoyed it a lot.

LDC might benefit from copying the _popcnt source from ldc's druntime in to your code as it has a problem inlining it from druntime. You might also see a benefit from the -single-obj flag (enabled by default in ldmd).
May 22, 2016
On Saturday, 21 May 2016 at 10:10:21 UTC, Richard Delorme wrote:
> On Saturday, 21 May 2016 at 00:29:13 UTC, extrawurst wrote:
>> [...]
>
> Yes, It is a strong program, but far from the top programs yet.
> In the ccrl scale: http://www.computerchess.org.uk/ccrl/4040/
> I guess its rating is close to 2700.
> The move generator is pretty fast, though:
> $ amoeba-linux-x64-sse4.2 perft -d 7
> perft  7 :      3195901860 leaves in     17.920 s    178344094 leaves/s
>
> [...]

Congratulations  2700 is great, vastly better than I managed many years ago.
Do you plan to take it further?
« First   ‹ Prev
1 2