public static final ArrayList<Move> removeIllegal(Position pos,ArrayList<Move> moveList){
  ArrayList<Move> ret=new ArrayList<Move>();
  UndoInfo ui=new UndoInfo();
  int mlSize=moveList.size();
  for (int mi=0; mi < mlSize; mi++) {
    Move m=moveList.get(mi);
    pos.makeMove(m,ui);
    pos.setWhiteMove(!pos.whiteMove);
    if (!inCheck(pos))     ret.add(m);
    pos.setWhiteMove(!pos.whiteMove);
    pos.unMakeMove(m,ui);
  }
  return ret;
}

public static final ArrayList < Move > removeIllegal ( Position pos , ArrayList < Move > moveList ) { ArrayList < Move > ret = new ArrayList < Move > ( ) ; UndoInfo ui = new UndoInfo ( ) ; int mlSize = moveList . size ( ) ; for ( int mi = 0 ; mi < mlSize ; mi ++ ) { Move m = moveList . get ( mi ) ; pos . makeMove ( m , ui ) ; pos . setWhiteMove ( ! pos . whiteMove ) ; if ( ! inCheck ( pos ) ) ret . add ( m ) ; pos . setWhiteMove ( ! pos . whiteMove ) ; pos . unMakeMove ( m , ui ) ; } return ret ; }
remove all illegal moves from movelist . " movelist " is assumed to be a list of pseudo - legal moves . this function removes the moves that don ' t defend from check threats .
