Chapter 26. Python Battle

In this book, we’ve covered how to make your own games. One thing we haven’t talked about yet, however, is game artificial intelligence (AI). Almost every game since Pac-Man has had some form of artificial intelligence that attacks the player, and this chapter will show you how to make one yourself.

Python Battle

The AIs we’re going to make in this chapter will be part of a game called Python Battle. Python Battle is a simple game with simple rules. On each turn, you may move forward, turn to face a different direction, or attack. When one bot attacks another, the bot that gets attacked loses one “health point.” The first bot to lose all its health points loses the game. Bots can only attack the square directly in ...

Get Hello World! Second Edition 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.