Chapter 20. Making Dice of Doom More Fun

It’s now time to create a final version of Dice of Doom. Version 4 of our game will be much more fun to play than our earlier versions.

Although you probably were not aware of it, we made some major compromises in the rules for our game to make it easier to program. In this chapter, we will allow more players, add rolling of the dice, and implement a few more changes to make Dice of Doom a much more interesting game.

Increasing the Number of Players

To begin, put all the code from the previous chapter in a file named dice_of_doom_v3.lisp (also available from the companion website), and then execute the following command:

> (load "dice_of_doom_v3.lisp")

The first change we’re going to make is to increase the number of players from two to four. Three of these will be AI opponents, played by the computer. Because of how we’ve written our code so far, this requires very little extra code:

(defparameter *num-players* 4)
(defparameter *die-colors* '((255 63 63) (63 63 255) (63 255 63)
                             (255 63 255)))

First, we simply change our *num-players* variable to 4. Then we need to indicate additional die colors for our new players. The colors for the four players will be red, blue, green, and purple.

It turns out that the AI we’ve created so far already works just fine in a four-player game.

Our AI game engine will use what is called a “paranoid strategy.” This means that the AI players will always assume that every other player (including the human) has no other goal but to—how should I put this?—screw them over personally. This isn’t a bad strategy to use; however, a game with more than two players opens up new possibilities. For instance, losing players could gang up on a winning player to improve their odds. Our game AI isn’t smart enough to form such packs of cooperation, but it’s good enough.

Now that we’ve already tweaked some constants to increase the number of players, let’s tweak a couple more:

(defparameter *max-dice* 5)
(defparameter *ai-level* 2)

Here, we’re increasing the maximum number of dice on a hex tile from three to five, and decreasing the level of our AI from four to two. With the new rules described in this chapter, we’ll need to dumb down our AI a bit to make sure it stays zippy. Since there are now four competing players, the AI actually doesn’t need to be so smart to challenge the human opponent.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.75.70