Problem of the Day: Tic-Tac-Toe (update)

Whew. TicTacToe is quite the time suck. I made a new TicTacToe class to handle creating a board, adding moves, checking for a winner, and printing the results. The board is still pretty dumb; each move attempt is started by getting a random integer [0-3), checking that it’s a legal move, then making the move and switching players. The entire board is always filled up but only prints out if there is a winner. Because “X” gets to go first every time it also wins a large percentage of the time, I check for “X” winning first to avoid a board having two win-conditions.

I did re-learn the ternary operation and figuring out how to teach a computer to play TicTacToe was a useful thought exercise. I might spend some time making the board smarter as far as choosing positions and checking for wins. Maybe.