O'Reilly logo

Lego Mindstorms NXT-G Programming Guide, Second Edition by James Floyd Kelly

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. Pick a Card, Any Card

Have you ever had someone perform a card trick and ask you to pick a card from the deck? There are 52 cards in a standard deck (the two jokers don't count), and if it's been properly shuffled, you should be able to pick a random card from the deck.

It's the same with rolling a pair of dice. Each die has the potential to roll a number from one to six. When you roll a normal pair of dice, the numbers that appear are random. The odds of rolling a two on one die are the same as rolling a six; they all have the same likelihood of appearing. What allows this to occur is simple randomness.

Your robots also have the ability to generate random numbers. You might want to build a robot that can roll a virtual set of dice or ...

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