A console-based implementation of a Generalized Non-Transitive Dice Game with HMAC verification. Supports configurable dice, fairness in random number generation, and enhanced usability features like detailed help tables.
A console-based implementation of a Generalized Non-Transitive Dice Game with HMAC verification. This application ensures fairness and transparency in gameplay using secure random number generation and cryptographic HMAC verification.
- Configurable Dice: Specify custom dice face values in any order.
- HMAC Verification: Ensures that the computer's move is securely generated and verifiable.
- Probability Help Table: Displays probabilities of user wins with color-highlighted headers for improved usability.
- Secure Random Generation: Uses cryptographic libraries to generate keys and random values.
- Dynamic Handling: Supports any number of dice configurations with varying face values.
- Node.js (v14 or higher)
- Install required dependencies:
npm install chalk cli-table3
- Launch the game with custom dice configurations:
node game2.js <dice configurations>
- Valid Configurations:
node game2.js 1,2,3,4,5,6 1,2,3,4,5,6 1,2,3,4,5,6 1,2,3,4,5,6 node game2.js 2,2,4,4,9,9 1,1,6,6,8,8 3,3,5,5,7,7
- Invalid Configurations:
- No dice provided
node game2.js
- Less than 3 dice
node game2.js 1,2
- Non-integer values
node game2.js 1,2,3,a,b
- Negative values
node game2.js 1,2,3,4,-5,6
- No dice provided
- The computer generates a random value (x) and a secret key.
- The computer displays the HMAC of its value to ensure fairness.
- The user selects a number (y).
- The computer reveals:
- Its original random value (x).
- The secret key.
- The sum modulo range: (x + y) % range.
- The user can verify the HMAC independently using the provided key and value.
- The program handles invalid inputs gracefully:
- Provides informative error messages for invalid configurations.
- Prevents invalid moves and allows users to retry.