I'd like to see an implementation of an alpha-beta search (negamax to be more precise) without recursion. I know the basic idea - to use one or more stacks to keep track of the levels, but having a real code would spare me a lot of time.
Having it in Java, C# or Javascript would be perfect, but C/C++ is fine.
Here's the (simplified) recursive code:
function search(crtDepth, alpha, beta)
{
  if (crtDepth == 0)
    return eval(board);
  var moves = generateMoves(board);
  var crtMove;
  var score = 200000;
  var i;
  while (i<moves.length) 
  {
    crtMove = moves.moveList[i++];
    doMove(board, crtMove);    
    score = -search(crtDepth-1, -beta, -alpha);
    undoMove(board, crtMove);
    if (score > alpha) 
    {
      if (score >= beta) 
      return beta;
      alpha = score;
    } 
  }
  return alpha;
}
search(4, -200000, 200000);
 
     
    