O'Reilly logo

Invent Your Own Computer Games with Python , 4th Edition by Al Sweigart

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

16REVERSEGAM AI SIMULATION

image

The Reversegam AI algorithm from Chapter 15 is simple, but it beats me almost every time I play it. Because the computer can process instructions quickly, it can easily check each possible position on the board and select the highest-scoring move. It would take me a long time to find the best move this way.

The Reversegam program had two functions, getPlayerMove() and getComputerMove(), which both returned the move selected as a two-item list in the format [x, y]. Both functions also had the same parameters, the game board data structure and one type of tile, but the returned moves came from different sources—either ...

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