writing computer player logic