Implements scoring and other code cleanup

Implements the scoring system. The score is tracked, and then it is
displayed to the user. It accounts for the active player in determining
who has won or lost, or if there is a tie. This commit also switches
from using console.log() to process.stdout.write(), thus reserving
console.log() for testing.