Fixed AI

Should be working completely now. And the end game condition seems to be
completely fixed as well.