1 | 9.1.1 Tic Tac Toe Part
board = [" ", " ", " ", " ", " ", " ", " ", " ", " "] This abstraction teaches that the board’s physical layout (3x3) is distinct from its logical storage (a linear list). Mapping index 0 to the top-left corner and index 8 to the bottom-right corner introduces the concept of , a fundamental skill in array manipulation. Part 1 rarely requires drawing graphical lines; instead, it uses text-based representation to print the board as three rows, reinforcing that output is merely a view of the underlying model. The Turn Management System: Introducing State The second pillar of Part 1 is the turn manager . A game without alternating turns is chaos; Part 1 therefore introduces a variable (often called current_player or turn ) that toggles between "X" and "O" . This is the student’s first practical encounter with a state machine, albeit a simple one.
For example, a common initialization in Python looks like this: 9.1.1 tic tac toe part 1
The mechanism is often implemented using a while loop that continues until a winner is declared or the board fills up (though win detection is typically reserved for Part 2 or Part 3). Inside the loop, the program prompts the current player for a move, validates the input (checking if the chosen cell is within range and empty), and then places the mark. After a successful move, the program switches the player: board = [" ", " ", " ",
board = [" " for _ in range(9)] Or, in a simpler, more transparent form: The Turn Management System: Introducing State The second





