c# for chess engine

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Sergei S. Markoff
Posts: 224
Joined: Mon Sep 12, 2011 9:27 pm
Location: Moscow, Russia
Contact:

c# for chess engine

Post by Sergei S. Markoff » Tue Sep 13, 2011 5:05 pm

I've just spent a few days to write a simple engine on C#. I was surprised that it's not so slow as I presumed. Bitboard engine (base on de Bruijn numbers) with alpha/beta, w/o move ordering and with eval based on psq/material does 1 200 000 pos/sec. at my notebook (while SmarThink does about 450 knodes/sec). It looks promising, I hope completely rewritten engine will be not more that 10–15% slower than original.
The Force Be With You!

wgarvin
Posts: 838
Joined: Thu Jul 05, 2007 3:03 pm
Location: British Columbia, Canada

Re: c# for chess engine

Post by wgarvin » Tue Sep 13, 2011 6:07 pm

C# assemblies are statically compiled with an AOT compiler. (I don't think desktop .NET even has a bytecode interpreter in it, everything gets compiled). If you avoid using the more dynamic language features, performance should be pretty good. Maybe a little bit less than you can achieve with C or C++, but still pretty good.

Sergei S. Markoff
Posts: 224
Joined: Mon Sep 12, 2011 9:27 pm
Location: Moscow, Russia
Contact:

Re: c# for chess engine

Post by Sergei S. Markoff » Tue Sep 13, 2011 6:11 pm

wgarvin wrote:C# assemblies are statically compiled with an AOT compiler. (I don't think desktop .NET even has a bytecode interpreter in it, everything gets compiled). If you avoid using the more dynamic language features, performance should be pretty good. Maybe a little bit less than you can achieve with C or C++, but still pretty good.
Yes, I think so. Especially if you're using unchecked {} and other possible optimisation options.
The Force Be With You!

User avatar
Steve Maughan
Posts: 1073
Joined: Wed Mar 08, 2006 7:28 pm
Location: Florida, USA
Contact:

Re: c# for chess engine

Post by Steve Maughan » Tue Sep 13, 2011 6:55 pm

Hi Sergei,

Glad you're back!

I don't know if you saw the thread but your name came up recently

http://www.talkchess.com/forum/viewtopic.php?t=40365

So is Smarthink dead? Or will you also call the new engine Smarthink? Why switch from C to C#?

Cheers,

Steve

User avatar
lucasart
Posts: 3080
Joined: Mon May 31, 2010 11:29 am
Full name: lucasart
Contact:

Re: c# for chess engine

Post by lucasart » Tue Sep 13, 2011 7:00 pm

Sergei S. Markoff wrote:I've just spent a few days to write a simple engine on C#. I was surprised that it's not so slow as I presumed. Bitboard engine (base on de Bruijn numbers) with alpha/beta, w/o move ordering and with eval based on psq/material does 1 200 000 pos/sec. at my notebook (while SmarThink does about 450 knodes/sec). It looks promising, I hope completely rewritten engine will be not more that 10–15% slower than original.
that is very fast indeed! probably faster than my C engine...
i wonder how fast a good C engine can go (in nodes/sec) on simple perft calculation (no eval, just generate, play, undo moves)

Sergei S. Markoff
Posts: 224
Joined: Mon Sep 12, 2011 9:27 pm
Location: Moscow, Russia
Contact:

Re: c# for chess engine

Post by Sergei S. Markoff » Tue Sep 13, 2011 7:06 pm

SmarThink is written on plain C. The coding was started in 2000, when I wasn't very experienced. Finally that code is hard to manage now.
I'm planning to write new engine on c#, using SmarThink parts of course.
Now I have some beta, w/o most of neccessary parts.
I don't know how much time I can spent for this project — I need to spent much time to my current busyness, so I'm not sure that I will quickly produce something well-working)
The Force Be With You!

User avatar
Steve Maughan
Posts: 1073
Joined: Wed Mar 08, 2006 7:28 pm
Location: Florida, USA
Contact:

Re: c# for chess engine

Post by Steve Maughan » Tue Sep 13, 2011 7:10 pm

Great - I wish you well.

If the C version of SmarThink has been retired, how about releasing it as Freeware? Just an idea (I'd happily host it).

Steve

Sergei S. Markoff
Posts: 224
Joined: Mon Sep 12, 2011 9:27 pm
Location: Moscow, Russia
Contact:

Re: c# for chess engine

Post by Sergei S. Markoff » Tue Sep 13, 2011 7:25 pm

Steve Maughan wrote:If the C version of SmarThink has been retired, how about releasing it as Freeware? Just an idea (I'd happily host it).
Steve
Let see, may be I will do it. I need to discuss it with Lokasoft of course.
The Force Be With You!

User avatar
Steve Maughan
Posts: 1073
Joined: Wed Mar 08, 2006 7:28 pm
Location: Florida, USA
Contact:

Re: c# for chess engine

Post by Steve Maughan » Tue Sep 13, 2011 7:26 pm

Sure - let me know if you'd like to take me up on the offer of hosting.

Cheers,

Steve

User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 8:05 pm
Location: Italy
Full name: Stefano Gemma
Contact:

Re: c# for chess engine

Post by stegemma » Wed Sep 14, 2011 7:47 am

Sergei S. Markoff wrote:I've just spent a few days to write a simple engine on C#. I was surprised that it's not so slow as I presumed. Bitboard engine (base on de Bruijn numbers) with alpha/beta, w/o move ordering and with eval based on psq/material does 1 200 000 pos/sec. at my notebook (while SmarThink does about 450 knodes/sec). It looks promising, I hope completely rewritten engine will be not more that 10–15% slower than original.
Me too, i've changed from assembly to C++ and the overhead of the language seems to be less important than the advantage to program in an high level language. For me is important to use a good profiling tool (that isn't available for assembly code that i've used before). For sample, with the profiler of XDev i've found that my new engine in C++ was spending 47% of the time just clearing moves list (with memset function). That calling was not necessary so with just few minutes of profiling i've just doubled the engine speed.

Maybe at the end it is important to use the language that you better know...

Post Reply