update algorithm
restart when game over