Hi,
My program is written using FreePascal for LINUX.
I am about the furthest thing away from a C programmer and do not want to start a religious wars thread so....
Would a simple minded conversion to C provide any benefit, or do you need to change "style" to take advantage of
any C benefits ?
I could do a conversion but it would essentially be a Pascal program with C syntax.
Thanks
Laurie.
Speed up your engine Part 3
Moderators: hgm, Rebel, chrisw
-
- Posts: 7218
- Joined: Mon May 27, 2013 10:31 am
Re: Speed up your engine Part 3
Maybe start with (magic) bitboards. Don't even know if Pascal has bit operations. Usually evaluation makes a program slow. For instance my program slowed down by a factor seven when I tried to implement a normal evaluation. Pawn table did not help much either.
-
- Posts: 27795
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Speed up your engine Part 3
Beware that speed contributes almost nothing to the strength of your program, unless poor programming techniques make you waste orders of magnitude. Doing things like bitboards is a complete waste of time when the search and eval are not good enough to reach 2700 Elo.
-
- Posts: 2555
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: Speed up your engine Part 3
reminds me of Embla (C++), searching ~150kn/shgm wrote:unless poor programming techniques make you waste orders of magnitude.
-
- Posts: 2204
- Joined: Sat Jan 18, 2014 10:24 am
- Location: Andorra
Re: Speed up your engine Part 3
I started Andscacs in Lazarus pascal. When it already was playing (bad) I translated it to C at it was clearly faster, but I dont remember the details. I sticked to C.lauriet wrote:Hi,
My program is written using FreePascal for LINUX.
I am about the furthest thing away from a C programmer and do not want to start a religious wars thread so....
Would a simple minded conversion to C provide any benefit, or do you need to change "style" to take advantage of
any C benefits ?
I could do a conversion but it would essentially be a Pascal program with C syntax.
Thanks
Laurie.
Daniel José - http://www.andscacs.com
-
- Posts: 7218
- Joined: Mon May 27, 2013 10:31 am
Re: Speed up your engine Part 3
Skipper running now 300kn/sec. That's 2-3 times slower than fairy-max on my computer. I get normal speed if it does not do much more than counting material incrementally.mar wrote:reminds me of Embla (C++), searching ~150kn/shgm wrote:unless poor programming techniques make you waste orders of magnitude.
-
- Posts: 2555
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: Speed up your engine Part 3
Yes, nps depends on a lot of factors.Henk wrote:Skipper running now 300kn/sec. That's 2-3 times slower than fairy-max on my computer. I get normal speed if it does not do much more than counting material incrementally.
Here Fairy-max runs at 1mn/sec.
But since there's no consensus on how to count nodes, perhaps Folkert doesn't count qs nodes (in my case, nps decreases to ~25% counting this way; in startposition)
EDIT: with other words, the only fair comparison is using same compiler on same hardware and most importantly counting nodes the same way
-
- Posts: 1334
- Joined: Sun Jul 17, 2011 11:14 am
Re: Speed up your engine Part 3
I am ashamed to admit I fell into that trap. I spent the better part of two weeks converting Dorpsgek from an attack table based program to a 16x12 array based program.hgm wrote:Beware that speed contributes almost nothing to the strength of your program, unless poor programming techniques make you waste orders of magnitude. Doing things like bitboards is a complete waste of time when the search and eval are not good enough to reach 2700 Elo.
Perft-wise, I'm 3.5x faster. Search wise, I am 1.5x faster.
But the old code still beats the new code hands down.
Some believe in the almighty dollar.
I believe in the almighty printf statement.
I believe in the almighty printf statement.
Re: Speed up your engine Part 3
That's not because of bad programming - the algorithm used is implemented very efficiently. It's only the algorithm which lacks a bit (e.g. no bitboard).
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: Speed up your engine Part 3
It depends on your goals.lauriet wrote:My program is written using FreePascal for LINUX.
I am about the furthest thing away from a C programmer and do not want to start a religious wars thread so....
Would a simple minded conversion to C provide any benefit, or do you need to change "style" to take advantage of
any C benefits ?
I could do a conversion but it would essentially be a Pascal program with C syntax.
If you want to keep the "same" program but you want it to run faster then perhaps you might want to translate it from Pascal into C/C++. But beware: you will probably introduce new bugs, and you will get program code in a language that you are not familiar with, so initially it will be harder for you to maintain it.
If you want to learn C/C++ then there are several ways to achieve that. At least working through a good book is one of these ways. Another way could be to translate your program into C/C++, or even better: to rewrite it in C/C++. That will take some time, but if learning is the goal then you might be willing to invest time.
If you want to become familiar with bitboards in the context of chess programming then it might be a good idea to do that in C/C++, although Pascal has some bit operations as well as far as I know - but I would not do that with your first C/C++ program, so having rewritten your program in C/C++ would be the first step.
If you want to improve your existing program step by step and do not care much about optimal speed or about learning another language then it is certainly better to stick with your Pascal code. Most programmers successfully use those languages and tools they are most familiar with, so why not Pascal if that is the language you are "speaking"?