ChessGame.MoveGenerator.prototype.get = function()
{
  this.retValue = [];
  for (var rank=0; rank<8; ++rank)
    for (var file=0; file<8; ++file)
    {
      var field = 16 * rank + file;
      var piece = this.board[field];
      if (ChessGame.pieceColor(piece) != this.active) continue;
      switch(piece)
      {
        case 'K': case 'k':
          this.kingMoves(field);
          break;
        case 'Q': case 'q':
          this.queenMoves(field);
          break;
        case 'R': case 'r':
          this.rookMoves(field);
          break;
        case 'B': case 'b':
          this.bishopMoves(field);
          break;  
        case 'N': case 'n':
          this.knightMoves(field);
          break; 
        case 'P': 
          this.pawnMoves(field, +16, this.passant);
          break;
        case 'p':
          this.pawnMoves(field, -16, this.passant);
          break;  
      }
    }
  this.castles(); 
  return this.retValue;
}
ChessGame.MoveGenerator.prototype.kingMoves = function(from) 
{ 
  this.lineMoves(from, [1, 15, 16, 17, -1, -15, -16, -17], true); 
}
ChessGame.MoveGenerator.prototype.queenMoves = function(from) 
{ 
  this.lineMoves(from, [1, 15, 16, 17, -1, -15, -16, -17]); 
}
ChessGame.MoveGenerator.prototype.rookMoves = function(from) 
{ 
  this.lineMoves(from, [1, 16, -1, -16]); 
}
ChessGame.MoveGenerator.prototype.bishopMoves = function(from) 
{ 
  this.lineMoves(from, [15, 17, -15, -17]); 
}
ChessGame.MoveGenerator.prototype.knightMoves = function(from) 
{ 
  this.lineMoves(from, [14, 18, 31, 33, -14, -18, -31, -33], true); 
}
ChessGame.MoveGenerator.prototype.lineMoves = function(from, delta, isShort)
{
  for (var i=0; i<delta.length; ++i)
  {
    var to = from;
    for(;;)
    {
      to += delta[i];
      if ((to & 0x88) != 0) break;
      var piece = this.board[to];
      if (ChessGame.pieceColor(piece) == this.active) break;
      this.addMove(from, to, piece != null ? "TAKING" : "MOVE");
      if (isShort) break;
      if (piece != null) break;
    }
  }
}