O'Reilly logo

Hello World! Second Edition: Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required