Fixed an issue with AI making invalid moves