how to evaluate the position inside the search function using PVS Algorithm with Quiet search and zero window search what should the range of the score be (-infinity, infinity ) could it be as small as (-16000,16000) and what should the search return if it's a stalemate or checkmate for me or for the other side ?
I tried reading the source code of different engines but there is too much addition(heuristics and such) that make it too difficult for me to understand anything.

the question in another for given this PVS algorithm how and where should I place checking for chaeck/stale mate and what score should I return ?

int PVS(alfa,beta,depthleft) {
   if( depthleft &lt;= 0 ) return qsearch(alpha, beta);

// using fail soft with negamax:
make first move
bestscore = -PVS(-beta, -alpha, depthleft-1);
unmake first move
if( bestscore &gt; alpha ) {
   if( bestscore &gt;= beta )
      return bestscore;
  alpha = bestscore;
}

for( all remaining moves ) {
  make move
  score = -PVS(-alpha-1, -alpha, depthleft-1); // alphaBeta or zwSearch
  if( score &gt; alpha &amp;&amp; score &lt; beta ) {
     // research with window [alpha;beta]
     score = -PVS(-beta, -alpha, depthleft-1);
     if( score &gt; alpha )
       alpha = score;
  }
  unmake move
  if( score &gt; bestscore ) {
     if( score &gt;= beta )
        return score;
     bestscore = score;
  }
}
return bestscore;
}


I wasn't sure where to post this question here or on stack overflow so please migrate it as you see fit
where should I place checking for chaeck/stale mate


Right before make first move: there is no first move!