c# for chess engine
Moderators: hgm, Rebel, chrisw
-
- Posts: 227
- Joined: Mon Sep 12, 2011 11:27 pm
- Location: Moscow, Russia
c# for chess engine
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!
-
- Posts: 838
- Joined: Thu Jul 05, 2007 5:03 pm
- Location: British Columbia, Canada
Re: c# for chess engine
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.
-
- Posts: 227
- Joined: Mon Sep 12, 2011 11:27 pm
- Location: Moscow, Russia
Re: c# for chess engine
Yes, I think so. Especially if you're using unchecked {} and other possible optimisation options.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.
The Force Be With You!
-
- Posts: 1221
- Joined: Wed Mar 08, 2006 8:28 pm
- Location: Florida, USA
Re: c# for chess engine
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
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
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: c# for chess engine
that is very fast indeed! probably faster than my C engine...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.
i wonder how fast a good C engine can go (in nodes/sec) on simple perft calculation (no eval, just generate, play, undo moves)
-
- Posts: 227
- Joined: Mon Sep 12, 2011 11:27 pm
- Location: Moscow, Russia
Re: c# for chess engine
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)
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!
-
- Posts: 1221
- Joined: Wed Mar 08, 2006 8:28 pm
- Location: Florida, USA
Re: c# for chess engine
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
If the C version of SmarThink has been retired, how about releasing it as Freeware? Just an idea (I'd happily host it).
Steve
-
- Posts: 227
- Joined: Mon Sep 12, 2011 11:27 pm
- Location: Moscow, Russia
Re: c# for chess engine
Let see, may be I will do it. I need to discuss it with Lokasoft of course.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
The Force Be With You!
-
- Posts: 1221
- Joined: Wed Mar 08, 2006 8:28 pm
- Location: Florida, USA
Re: c# for chess engine
Sure - let me know if you'd like to take me up on the offer of hosting.
Cheers,
Steve
Cheers,
Steve
-
- Posts: 859
- Joined: Mon Aug 10, 2009 10:05 pm
- Location: Italy
- Full name: Stefano Gemma
Re: c# for chess engine
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.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.
Maybe at the end it is important to use the language that you better know...