Appendix
1. Introduction to Artificial Intelligence
Activity 1.01: Generating All Possible Sequences of Steps in a Tic-Tac-Toe Game
Solution:
The following steps will help you to complete this activity:
- Open a new Jupyter Notebook file.
- Reuse the function codes of Steps 2–9 from the previous, Exercise 1.02, Creating an AI with Random Behavior for the Tic-Tac-Toe Game.
- Create a function that maps the all_moves_from_board_list function to each element of a list of boards. This way, we will have all of the nodes of a decision tree in each depth:
def all_moves_from_board_list(board_list, sign):
move_list = []
for board in board_list:
move_list.extend(all_moves_from_board(board, sign))
return move_list
In the preceding code snippet, ...
Get The Applied Artificial Intelligence Workshop now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.