Fix for AI to make invalid moves in some cases.