Worst advice

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.
Henk
Posts: 5833
Joined: Mon May 27, 2013 8:31 am

Worst advice

Post by Henk » Mon Aug 10, 2015 3:07 pm

When you read all these comments there seems to be many ideas and recommendations to improve your chess engine.

For me worst idea was to use bitboards for move generation. For it was difficult to implement, gave horrible bugs and no speed up.

So question is: What was the worst idea you implemented ?

jdart
Posts: 3837
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: Worst advice

Post by jdart » Mon Aug 10, 2015 3:49 pm

Movegen is not the biggest time consumer for most chess programs. The real bottleneck is the evaluation function, and I think Bob Hyatt observed a long time ago that the real benefit of bitboards is that you can get greater efficiencies in eval. Of course if you didn't start with bitboards that means re-writing your eval, as well as your movegen, etc.

--Jon

Henk
Posts: 5833
Joined: Mon May 27, 2013 8:31 am

Re: Worst advice

Post by Henk » Mon Aug 10, 2015 4:08 pm

I did not know that.

brtzsnr
Posts: 433
Joined: Fri Jan 16, 2015 3:02 pm
Contact:

Re: Worst advice

Post by brtzsnr » Mon Aug 10, 2015 5:02 pm

For young engines the move generation and sorting consume the most amount of time. Two reasons for this: 1) move are generated even if a hash move is already available 2) evaluation is extremely basic, possible just the material and position.

Stronger engines do various tricks to avoid generating or sorting the moves and, additionally, they have very complicated evaluation function. It's curious that a better eval improves the (internal) nps.

mvk
Posts: 589
Joined: Tue Jun 04, 2013 8:15 pm

Re: Worst advice

Post by mvk » Mon Aug 10, 2015 5:15 pm

Henk wrote:So question is: What was the worst idea you implemented
Any speed improvement below 2,000 cycles per node.
[Account deleted]

jdart
Posts: 3837
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: Worst advice

Post by jdart » Mon Aug 10, 2015 5:35 pm

Nobody should be doing 1). If you have a hash table, you probe it first, before movegen. That is not complicated.

--Jon

Robert Pope
Posts: 510
Joined: Sat Mar 25, 2006 7:27 pm

Re: Worst advice

Post by Robert Pope » Mon Aug 10, 2015 6:40 pm

jdart wrote:Nobody should be doing 1). If you have a hash table, you probe it first, before movegen. That is not complicated.

--Jon
But how do you know the probe returned a legal move? Stronger engines will have special validation routines, but younger engines often do a movegen and then see if the probe is in the movelist.

User avatar
cdani
Posts: 2104
Joined: Sat Jan 18, 2014 9:24 am
Location: Andorra
Contact:

Re: Worst advice

Post by cdani » Mon Aug 10, 2015 6:49 pm

Robert Pope wrote:
jdart wrote:Nobody should be doing 1). If you have a hash table, you probe it first, before movegen. That is not complicated.

--Jon
But how do you know the probe returned a legal move? Stronger engines will have special validation routines, but younger engines often do a movegen and then see if the probe is in the movelist.
During a lot of time, Andscacs (and sure a lot of engines) was generating all the legal moves without bitboards with a lot of for loops, and was validating all the moves like the hash one searching in the list of moves generated. Of course this was sloooow, but I had something that was working and I knew sometime I will improve. Now it uses all the tricks one can think about to speed things. Is just a step after another. Make it work, and you will have time to improve it.

Dann Corbit
Posts: 10189
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Worst advice

Post by Dann Corbit » Mon Aug 10, 2015 7:17 pm

Was it the advice that was bad or the implementation of the advice?

Now, bitboards can be quite unnatural when you are not used to them yet.
But in the long run, I think that the advice was very good.
I guess that if you take your time and work through the issues, eventually you will be glad that you switched.

Look at the top ten on this list:
http://www.computerchess.org.uk/ccrl/4040/

Guess which of them are bitboard engines...
Answer:
All of them.

It's not a coincidence.

It is also true that array based engines can be very strong. But for 64 bit CPUs and 64 bit operating systems, bitboards are better.

jdart
Posts: 3837
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: Worst advice

Post by jdart » Mon Aug 10, 2015 7:22 pm

You are only going to store a move in the hash table if it was generated, validated and executed previously for the position. So the only reason you'd get an invalid move would be a hash collision or an overwrite of hash table data while you are reading it (if using lockless hashing). To avoid this you do need to validate.

But I've done this forever .. version 1.0 of Arasan had a hash_move_valid method (not using movegen).

--Jon

Post Reply