user6937: 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 <= 0 ) return qsearch(alpha, beta);

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

for( all remaining moves ) {
  make move
  score = -PVS(-alpha-1, -alpha, depthleft-1); // alphaBeta or zwSearch
  if( score > alpha && score < beta ) {
     // research with window [alpha;beta]
     score = -PVS(-beta, -alpha, depthleft-1);
     if( score > alpha )
       alpha = score;
  }
  unmake move
  if( score > bestscore ) {
     if( score >= 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 

user3774: 
where should I place checking for chaeck/stale mate

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

6937: <p>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.</p>

<p>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 ?</p>

<pre><code>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;
}
</code></pre>

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

<p>Right before <code>make first move</code>: there is no first move!</p>
