means to design a hole engine, this "idea" cannot easily be
transplanted to other engines.
Look at Fruit. Fruit has fairly clean code. There are functions,
comments, and assertions. This is much better than in most other
source codes. I think that the relative absence of bugs is what made
Fruit strong. Therefore, Fabien has proven that the software
engineering approach works.
However, for me there was still not enough of software engineering in
Fruit. There are no unit tests. There are macros rather then enums,
classes, or inline functions. There are global variables. There is a
longjump. I didn't want to work that way.
My approach included:
- - C++ rather than Fruit's C+
- abstract interfaces
- assertions
- unit tests
- various log files, namely- - an EventLogger for differential tests (dump actions to determine
exactly where search goes differently from the previous version)
- an XML dump of the search tree (usable for small trees only,
viewable in an XML viewer similar to the directory tree in a file
browser)
- statistics on node types and children
- - an EventLogger for differential tests (dump actions to determine
I love structuring and ordering, I love software design. So I enjoyed
my approach.
My approach has proven to work but I cannot calculate how much of
Onno's strength comes from it. However my approach has also proven to
be too slow to keep pace with the rapid improvement of engines. At
least for a single part time programmer.
To emphasize the importance of software engineering, let us have a
look at Toga. Fabian gave a fairly well structured code as a starting
base (Fruit). Thomas made it stronger, but he also introduced several
bugs. With proper software engineering these bugs would have been
detected and Toga would have been stronger.
Bug 1 (in Toga 1.2.1a):
sort.cpp, line 951 computes the index in a wrong way.
Code: Select all
index = PIECE_TO_12(board->square[MOVE_FROM(move)]) * 64
+ SQUARE_TO_64(MOVE_FROM(move)) * 64
+ SQUARE_TO_64(MOVE_TO(move));
This kind of bug would never have passed unit testing.
Impact on playing strength: None at all! I tried fixing the bug, but
the strength is unchanged. This might indicate that the whole
heuristic is not worth much.
Bug 2:
search_full.cpp, line 796
Code: Select all
if (best_value == ValueNone) { // no legal move
if (in_check) {
ASSERT(board_is_mate(board));
return VALUE_MATE(height);
} else {
ASSERT(board_is_stalemate(board));
return ValueDraw;
}
}
longer true. It might be possible that all moves have been pruned. In
this case, it is a very bad idea to return VALUE_MATE or ValueDraw.
If Toga had been run with assertions enabled, this bug would easily
have been uncovered. It seems nobody in the open source community ever
did this! Here you can learn from commercial software developers.
Impact on playing strength: Considerable.
Bugfix: insert
Code: Select all
if (move_found) { // all moves pruned
return full_quiescence(board,old_alpha,beta,0,height,pv);
}
Over the years, things got worse. Too many cooks have spoilt the
broth. Toga is almost not maintainable now.