beginning of algorithm for playing