Calculating legal moves.