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 ...

Get Raspberry Pi Projects For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.