Game Development Reference
In-Depth Information
16 - AI Simulation
calls and running the program again.
Welcome to Reversi!
Enter number of games to run: 100
Game #0: X scored 25 points. O scored 39 points.
Game #1: X scored 26 points. O scored 33 points.
...skipped for brevity...
Game #98: X scored 36 points. O scored 25 points.
Game #99: X scored 29 points. O scored 35 points.
X wins 32 games (32.0%), O wins 67 games (67.0%),
ties for 1 games (1.0%) of 100.0 games total.
Yes, it does seem like taking the algorithm that takes the corners when it can does
translate into more wins. While we have found out that going for the sides makes you lose
more often, going for the corners is always a good idea.
Learning New Things by Running Simulation
Experiments
This chapter didn't really cover a game, but it modeled various strategies for Reversi. If
we thought that taking side moves in Reversi was a good idea, we would have to spend
days, even weeks, carefully playing games of Reversi by hand and writing down the results.
But if we know how to program a computer to play Reversi, then we can have the computer
play Reversi using these strategies for us. If you think about it, you will realize that the
computer is executing millions of lines of our Python program in seconds! Your
experiments with the simulation of Reversi can help you learn more about playing Reversi
in real life.
In fact, this chapter would make a good science fair project. Your problem can be which
set of moves leads to the most wins against other sets of moves, and make a hypothesis
about which is the best strategy. After running several simulations, you can determine
which strategy works best. You can make a science fair project out of a simulation of any
board game! And it is all because you know exactly how to instruct the computer to do it,
step by step, line by line. You can speak the computer's language, and get it to do large
amounts of data processing and number crunching for you.
That's all for the text-based games in this topic. Games that only use text can be fun,
even though there simple. But most modern games use graphics, sound, and animation to
make much more exciting looking games. For the rest of the chapters in this topic, we will
learn how to create games with graphics by using a Python module called Pygame.
Search WWH ::




Custom Search