กลับไปหน้ารวมไฟล์
liars-dice-assistant-701fe9-en.md

This is a device to assist in making the best plays in Liar’s Dice.

If you’re unfamiliar with Liar’s Dice, watch Pirates of the Caribbean: Dead Man’s Chest — that’ll cover most of the rules. Alternatively, you can read the rules here: Liar's Dice Rules. Essentially, it’s a bluffing game where each player has a set of dice hidden under a cup, and players take turns bidding on what they believe is under everyone’s cups collectively. Remembering the total number of dice on the table and tracking each player’s dice is a great advantage.

This project uses a matrix keypad and an LCD display to help make smarter calls during gameplay. The device prompts the user to input the total number of dice on the table (or your best guess), the quantity being called (for example, if someone says “seven 6s,” you input 7), the number of dice under your own cup, and the number of dice you have that match the face being called. Using this information, it calculates and displays two percentages: the probability that the bid is true (meaning there are at least that many matching dice on the table), and the probability that the total is exactly that amount.

All input is handled through the keypad, and results are shown directly on the LCD. The LCD used in this build does not have I2C, so wiring may be simpler in some cases, depending on your setup.

Perfecting the Random Seed

For dice games, true randomness is critical. A standard Arduino random(1, 7) call will generate the exact same sequence of numbers every time the board is turned on.

  • The Fix: In the setup(), you must write randomSeed(analogRead(A0));
  • Leaving analog pin A0 completely unplugged acts like an antenna. It picks up fluctuating invisible electromagnetic noise in the room, feeding a truly random seed number into the generator, ensuring every game is unique!

Managing the Dice Array

  1. The "Roll": When the user presses the main button, the code populates an array: int myDice[5]. It fills slots 0 through 4 with the random numbers.
  2. The Display: Using a library like Adafruit_GFX on an OLED screen, you can draw squares with specific dot placements mimicking the face of actual dice, rather than just printing digits.
  3. The Concealment: A second button (the "Cup") can be programmed to clear the screen entirely, so the player can keep their roll a secret from the other players while they make their bluff.

Recommended Components

  • Arduino Nano or Pro Mini: Small enough to fit in the palm of your hand.
  • 1.3" or 0.96" I2C OLED Display.
  • Arcade Push Buttons (x2 or x3).
  • Compact Battery Source (like a 9V or LiPo).

This is a brilliant exercise in creating a standalone digital toy that requires no external computers to function. There are endless possibilities with matrix keypads and LCDs, from calculators to locking mechanisms and beyond. Have fun, and good luck bluffing!

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
author: "krisa98"
category: "Gadgets, Games & Toys"
components:
  - "1x Matrix Keypad 4x4"
  - "1x 10kOhm potentiometer"
  - "1x Arduino Uno R3"
  - "1x LCD 16x2"
  - "1x Breadboard 100x160"
description: "Game theory on a microcontroller! Program a handheld system to generate, hide, and calculate probabilities for the classic pub game of Liar's Dice."
difficulty: "Intermediate"
documentationLinks: []
downloadableFiles:
  - "https://app.arduino.cc/sketches/432f24b0-8dd1-4f85-b225-8453164fdbd1?nav=Examples&view-mode=preview"
encryptedPayload: "U2FsdGVkX19kkJpC/iR98K4BVE4mvcjqlAmqGF2t2ZFDyQj5NIIol5QqeyVuzqz3kdqwupODX/9NoZjwWSXlRbSUJkRrNgkQ5yTnyS79ItE="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/liars-dice-assistant-701fe9_cover.jpg"
lang: "en"
likes: 1
passwordHash: "df72ef039f3a443e357df79761b78339844a52b2d5bb79ceb1e6ac81ecf2816d"
price: 1120
seoDescription: "Enhance your Liars Dice game with this Probability calculating device built using Arduino and Sensors."
tags:
  - "Games"
title: "Liars Dice Assistant"
tools: []
videoLinks: []
views: 1280