11. The Random and Math Packages
When one of the authors was little, he didn’t like to spend a lot of time on arithmetic, because, he argued, someday everyone was going have computers to do all the arithmetic in the world. He was partly right. Arithmetic can still be useful, but the world is heavily computerized. Bar codes and cash registers do all you need, and you can always reach for your cell phone with its built-in calculator function.
But number crunching still matters. This chapter concerns not mundane arithmetic, but higher math functions, along with
random, which is useful in game programs and simulations. For the most sophisticated 3-D games, you’ll need to find even more advanced packages, but for simple games,
math suffice. ...