O'Reilly logo

Raspberry Pi Projects For Dummies by Brock Craft, Jonathan Evans, Mike Cook

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 14

The LEGO Dice Game

In This Chapter

arrow Learning about a dice game that involves skill, not luck

arrow Discovering how to use the color sensor to read a dice

arrow Constructing a LEGO robot to play a game

arrow Commanding the robot from your Raspberry Pi

arrow Integrating LEGO and Raspberry Pi using Python

This project plays a rather unusual dice game — unusual because it involves skill, not luck. Players take turns trying to reduce a heap to exactly nothing. The number removed from the heap each turn is indicated by turning a dice with the required number on the top face. Now, here’s the rub: You can’t use the same number as the previous player, nor can you use the number that the previous player had on the bottom face. The game as described here pits you against the computer, and by the power of LEGO, the computer can actually place the dice with its turn number uppermost. Confused? Don’t worry — we explain the game to you in detail in this chapter.

Introducing the Dice Game

We first saw the dice ...

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