I rewrote the main parts of LOOPs recursive search engine. Now LOOP is searching iterative in order to implement DTS. But the first tests have shown that the searchspeed decreased about 10% compared to the recursive version.

Both search engines are producing identical searchtrees, therefore I dont think to discover some bugs.

The following piece of code are the main parts of my first simple search without any heuristics or trans tables and so on...

How can I improve the pure search speed? This piece of code is definitely to slow compared to the recursive version

I rewrote the main parts of LOOPs recursive search engine. Now LOOP is searching iterative in order to implement DTS. But the first tests have shown that the searchspeed decreased about 10% compared to the recursive version.

Both search engines are producing identical searchtrees, therefore I dont think to discover some bugs.

The following piece of code are the main parts of my first simple search without any heuristics or trans tables and so on...

How can I improve the pure search speed? This piece of code is definitely to slow compared to the recursive version

Code: Select all

```
////
//// iterative search stack
////
struct stack_c {
sintx phase;
sintx check;
sintx alpha;
sintx beta;
sintx value;
sintx value_best;
sintx move;
sintx move_best;
sintx depth;
undo_c undo;
sort_c sort;
};
////
//// iterative root/tree search
////
void search(sintx depth, sintx ply, sintx check, int phase, int moves) {
stack_c stack[256];
stack_c * current;
int value;
int alpha;
int beta;
////
//// initialize current
////
current=stack;
current->depth=depth;
current->phase=phase;
current->check=check;
current->alpha=-VALUE_MATE;
current->beta=VALUE_MATE;
////
//// start iteration
////
while (1) {
switch (current->phase) {
////
//// PHASE_ROOT_START_W
////
case PHASE_ROOT_START_W:
current->phase=PHASE_ROOT_LOOP_W;
continue;
////
//// PHASE_ROOT_LOOP_W
////
case PHASE_ROOT_LOOP_W:
////
//// search
////
current->phase=PHASE_ROOT_UNDO_W;
depth=current->depth;
alpha=current->alpha;
beta=current->beta;
ply++;
current++;
current->check=check;
current->depth=depth-1;
current->alpha=-beta;
current->beta=-alpha;
current->phase=PHASE_TREE_START_B;
continue;
////
//// PHASE_ROOT_UNDO_W
////
case PHASE_ROOT_UNDO_W:
ply--;
undo_move_w(tree.board, current->undo, current->move);
value=current->value;
current->phase=PHASE_ROOT_LOOP_W;
continue;
////
//// PHASE_TREE_START_W
////
case PHASE_TREE_START_W:
if (current->depth <= 0) {
////
//// return value
////
value=search_q_w()
current--;
current->value=-value;
continue;
}
else {
////
//// initialize
////
current->phase=PHASE_TREE_LOOP_W;
continue;
}
////
//// PHASE_TREE_LOOP_W
////
case PHASE_TREE_LOOP_W:
current->move=sort_move_w(current->sort);
////
//// all moves searched
////
if (current->move == MOVE_NONE) {
////
//// return mate or draw
////
if (current->value_best == VALUE_NONE) {
if (current->check == 1) {
value=value_mate_ply(ply);
current--;
current->value=-value;
continue;
}
else {
current--;
current->value=-VALUE_DRAW;
continue;
}
}
////
//// return value
////
value=current->value_best;
current--;
current->value=-value;
continue;
}
do_move_w(tree.board, current->undo, current->move);
////
//// search
////
current->phase=PHASE_TREE_UNDO_W;
depth=current->depth;
extensions=current->extensions;
alpha=current->alpha;
beta=current->beta;
ply++;
current++;
current->check=check;
current->depth=depth-1;
current->alpha=-beta;
current->beta=-alpha;
current->phase=PHASE_TREE_START_B;
continue;
////
//// PHASE_TREE_UNDO_W
////
case PHASE_TREE_UNDO_W:
ply--;
undo_move_w(tree.board, current->undo, current->move);
value=current->value;
if (value > current->value_best) {
if (value > current->alpha) {
if (value >= current->beta) {
////
//// return value
////
current--;
current->value=-value;
continue;
}
current->alpha=value;
current->move_best=current->move;
}
current->value_best=value;
}
current->phase=PHASE_TREE_LOOP_W;
continue;
}
}
}
```