I've been getting some weird pvs from my search function. Would any of you be able to tell what I'm doing wrong? Here's the code:

I'm using Bruce Moreland's method of collecting the pv:

Code: Select all

```
class LINE
{
public:
int cmove = 0;// Number of moves in the line.
Move argmove[20]; // The line for pvs of up to 20 moves long.
int score = 0;
};
int Search::AlphaBeta(int alpha, int beta, int depth, LINE * pline, bool donullmove)
{
if(depth <= 1)
{
++Nodes;
pline->cmove = 0;
return QuiescenceSearch(alpha, beta, depth + 1);
}
LINE line;
//Null move pruning
if((Search::Is_Mate() != -10000) && (donullmove) && (depth > 3))
{
Search::Current_Turn ^= 1;
int Temp_Move = AlphaBeta(-beta, -beta + 1, depth - 3, &line, false);
if(Temp_Move >= beta)
{
Search::Current_Turn ^= 1;
return beta;
}
}
Search::Current_Turn ^= 1;
Generate_Moves(false);
Move move;
if(MoveStack.length() == 0)
{
alpha = Is_Mate();
pline->score = alpha;
pline->cmove = 0;
return alpha;
}
TTEntry* tt = TT.probe(Get_Current_Hash_Key());
if(tt!= NULL)
{
if(tt->nodetype == Alpha) if(tt->score <= alpha) return alpha;
if(tt->nodetype == Beta) if(tt->score >= beta) return beta;
if(tt->nodetype == Exact)
{
if(tt->depth > depth)
{
delete tt;
return tt->score;
}
}
delete tt;
}
for(int i = 0; i < MoveStack.length(); i++)
{
Nodes++;
move.From = MoveStack[i].From;
move.To = MoveStack[i].To;
move.Move_Type = MoveStack[i].Move_Type;
Make_Move(MoveStack[i])
int Score = -AlphaBeta(-beta, -alpha, depth - 1, &line, (donullmove ? false : true));
move.Undo_Move();
if(Score >= beta)
{
return beta;
}
if(Score > alpha)
{
pline->argmove[0] = move;
pline->score = Score;
memcpy(pline->argmove + 1, line.argmove, line.cmove * sizeof(Move));
pline->cmove = line.cmove + 1;
alpha = Score;
NodeType node = Exact;
TT.save(depth, Score, move, node, Get_Current_Hash_Key());
}
}
NodeType node = Alpha;
TT.save(depth, move.Score, move, node, Get_Current_Hash_Key());
return alpha;
}
```

LINE line;

int rootscore = AlphaBeta(alpha, beta, depth, &line, true);

I'm getting output like this:

Code: Select all

```
position startpos
go wtime 5000 btime 5000
info depth 1
info multipv 1 depth 1 seldepth 3 score cp 15 hashfull 0 pv g1f3 time 44 nodes
7012 nps 378000
info depth 2
info multipv 1 depth 2 seldepth 4 score cp -5 hashfull 0 pv a2a4 time 48 nodes
7072 nps 348000
info depth 3
info multipv 1 depth 3 seldepth 5 score cp 60 hashfull 0 pv e2e4 b8a6 b8a6 time
53 nodes 17932 nps 332000
info depth 4
info multipv 1 depth 4 seldepth 6 score cp 30 hashfull 0 pv e2e4 b8a6 b1a3 b8a6
b1a3 time 60 nodes 18599 nps 304000
info depth 5
info multipv 1 depth 5 seldepth 7 score cp 60 hashfull 2 pv e2e4 b8a6 b1a3 g8h6
b8a6 b1a3 g8h6 time 81 nodes 27465 nps 334000
info depth 6
info multipv 1 depth 6 seldepth 9 score cp 30 hashfull 4 pv e2e4 b8a6 b1a3 g8h6
g1h3 b8a6 b1a3 g8h6 g1h3 time 98 nodes 34267 nps 346000
info depth 7
bestmove e2e4
```

Your comments are greatly appreciated!

David Cimbalista