this code pretty much made every thing clear for me with the exception of :Sven Schüle wrote:Hi Mahmoud,

since I find mixing fail-soft and fail-hard confusing (you can read more about it in the CPW if you want to know the difference) I prefer to write the search based on fail-soft only. A very basic alpha-beta negamax search with quiescence search could look like this:Code: Select all

`int qSearch(int alpha, int beta) { int bestScore = evaluate(); if (bestScore >= beta) return bestScore; generateLegalQSMoves(); for (all moves) { makeMove(move); int score = -qSearch(-beta, -Max(alpha, bestScore)); unmakeMove(move); if (score > bestScore) { bestScore = score; if (bestScore >= beta) break; } } return bestScore; } int search(int alpha, int beta, int depthLeft, int height) { if (depthLeft == 0) return qSearch(alpha, beta); generateLegalMoves(); if (numberOfLegalMoves == 0) return (isInCheck() ? -(INF - height) : 0); int bestScore = -INF; for (all moves) { makeMove(move); int score = -search(-beta, -Max(alpha, bestScore), depthLeft - 1, height + 1); unmakeMove(move); if (score > bestScore) { bestScore = score; if (bestScore >= beta) break; if (height == 0 && bestScore > alpha) { bestRootMove = move; } } } return bestScore; }`

1-Does height mean ply to give higher score for the mat in less moves ,or is it something else?

2-

Code: Select all

` if (numberOfLegalMoves == 0) return (isInCheck() ? -(INF - height) : 0); `

3-if Generate Legal Moves return one move can I return (+INF,-INF) at once for example :

Code: Select all

```
if (numberOfLegalMoves == 0) return (isInCheck() ? -(INF - height) : 0);
else if(numberOfLegalMoves ==1) return (WhiteToMove?+INF:-INF);
```

Code: Select all

```
IterativeDeepining()
{
for (int Depth = 1; (Depth < MaxDepth)&&!(UCI.STOP); ++Depth)
{
for (RootMove:RootMoves)
{
MakeMove(RootMove);
RootMove.Value=search(-INF,+INF,Depth, ply)
UnMakeMove(RootMove);
}
//sort the moves by value, highest comes first
}
return FirstRootMove;
}
```

" ?

I know most if not all of my questions may seem stupid , or imply a lack of effort ,but I really did search and read a lot before asking here and I think I understand alpha/beta concept and some of it's enhancements.