Policy based design in chess
Posted: Thu Aug 07, 2014 3:51 am
What do you think of policy based design for a chess engine or library? The techniques put forth in Modern C++ Design and after seem very powerful. But is a chess engine too small or specific to benefit significantly from PBD?
One benefit I see as desirable is easily modifiable code that is also very concise, your own meta-library that is very expressive and provides a lot of bang for the buck per line of code. I like to write the first version that can initially use a simple-and-correct algorithm, which has the option to be changed to a more efficient implementation later on. For instance, generating an attack bitboard would first be a basic for loop. Later on it can be upgraded to magic bitboards or whatever. A move list can just be a vector, and it gets changed to something more efficient later. However, this can easily be achieved by wrapping code in functions and classes. So is policy based design worth the effort for chess?
I suspect it might not be universally useful in a chess engine, but may only be useful in some areas of a chess engine. If so, which areas would be the best candidates?
One benefit I see as desirable is easily modifiable code that is also very concise, your own meta-library that is very expressive and provides a lot of bang for the buck per line of code. I like to write the first version that can initially use a simple-and-correct algorithm, which has the option to be changed to a more efficient implementation later on. For instance, generating an attack bitboard would first be a basic for loop. Later on it can be upgraded to magic bitboards or whatever. A move list can just be a vector, and it gets changed to something more efficient later. However, this can easily be achieved by wrapping code in functions and classes. So is policy based design worth the effort for chess?
I suspect it might not be universally useful in a chess engine, but may only be useful in some areas of a chess engine. If so, which areas would be the best candidates?