13 Smart Games: Adding Intelligence

In the one-player version of Connect Four we built in Chapter 11, the computer always randomly selects a move. This allowed us to focus on the game’s speech recognition and text-to-speech aspects.

However, once you play against the random computer for a few games, you start to wonder if there’s a way to make our Connect Four game more challenging. The answer is yes, and in this chapter, you’ll learn to make an intelligent Connect Four opponent.

In one approach, we’ll ask the script to think three steps ahead, as people do when playing a game: two moves by the computer and one by the player.

In the first ...

Get Make Python Talk 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.