Exercise

Exercise 12

Tic-tac-toe (or noughts and crosses) is a simple strategy game in which two players take turns placing a mark on a 3x3 board, attempting to make a row, column, or diagonal of three with their mark. In this homework, we will use the tools we've covered in the past two weeks to create a tic-tac-toe simulator and evaluate basic winning strategies.

In the previous exercise, we see that when guessing at random, it's better to go first, as expected. Let's see if Player 1 can improve their strategy.

Instructions

100 XP
  • create_board(), random_place(board, player), and evaluate(board) have been created from previous exercises. Create a function play_strategic_game(), where Player 1 always starts with the middle square, and otherwise both players place their markers randomly.
  • Call play_strategic_game once.