Chapter 3. Implementing your first Go bot

 

This chapter covers

  • Implementing a Go board by using Python
  • Placing sequences of stones and simulating a game
  • Encoding Go rules for this board to ensure legal moves are played
  • Building a simple bot that can play against a copy of itself
  • Playing a full game against your bot

In this chapter, you’ll build a flexible library that provides data structures to represent Go games and algorithms that enforce the Go rules. As you saw in the preceding chapter, the rules of Go are simple, but in order to implement them on a computer, you have to consider all the edge cases carefully. If you’re a novice to the game of Go or need a refresher of the rules, make sure you’ve read chapter 2. This chapter is technical and requires a good working knowledge of the Go rules to fully appreciate the details.

Representing the Go rules is immensely important, because it’s the foundation for creating smart bots. Your bot needs to understand legal and illegal moves before you can teach it good and bad moves.

At the end of this chapter, you’ll have implemented your first Go bot. This bot is still weak but has all the knowledge about the game of Go it needs to evolve into much stronger versions in the following chapters.

3.1. Representing a game of Go in Python

3.2. Capturing game state and checking for illegal moves

3.3. Ending a game

3.4. Creating your first bot: the weakest Go AI imaginable

3.5. Speeding up game play with Zobrist hashing

3.6. Playing against your bot

3.7. Summary

sitemap