课程: AI Algorithms for Game Design with Python

The cat trap game

- [Instructor] In the programming examples of this course, you will see an intelligent agent that plays the "Cat Trap Game." So the first thing I want you to do is to get acquainted with the game. So by all means, Google it and play it. This game works on a hex grid, which is similar to a beehive where you have hexagonal tiles and you play against a cat, taking turns to block his way out. If the cat can't move, you win. If the cat reaches an edge, you lose. Let's take a look at the game. Here, we have one implementation of the "Cat Trap Game." As you can see, it works on an 11 by 11 hex grid, and the cat is always at the center tile. Notice that there are some blocked tiles at the beginning of the game, and these are random. So let me show you a new game and another and one more. So now let me show you how I play against the cat, and I want you to pay attention to the dynamics of the game and how we are taking turns. So it's my turn and I have to block the cat by selecting one tile. Let's say I select this tile right here. The cat has made his move, so I will keep on trying to block the cat and you'll see how clever this cat really is. I think I caught the cat. Yes, the cat is trapped. Now, all I have to do is block him so that he has no way to move. Let me block this tile, and this one, and this one. There you have it, I won. But you may want to try your hand at the "Cat Trap Game" and you'll see that it's not that easy. Let's give it another shot. And right now, I am about to lose. The cat got away. So there you have it. I don't think this implementation of the cat trap is actually using the techniques we'll see in the course. The techniques we will see will guarantee that the agent will play optimally. However, you'll see some difficulties to this approach. Now, here are some additional details about the cat game. First, this is a special type of turn-based game. And I say this because the two players have different rules. As you could see, the cat is trying to escape while I'm trying to trap the cat. In other words, my options for the next move come from the set of free tiles in the grid, while the cat has only at most six possible moves, its neighbor tiles. And like I said, we will make an intelligent agent for the cat. This means that our intelligent agent will try to maximize the utility of the cat, not the utility of the player.

内容