refactor player_vs_cpu from 607 lines of js to 164 lines