player index chosing algorithm