Skip to content

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.

Notifications You must be signed in to change notification settings

Mrtimu139/non-transitive-dice-game-hmac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

non-transitive-dice-game-hmac

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.

Non-Transitive Dice Game with HMAC Verification

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.

Features

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

Requirements

  • Node.js (v14 or higher)
  • Install required dependencies:
    npm install chalk cli-table3
    

Run the Game

  • Launch the game with custom dice configurations:
    node game2.js <dice configurations>

Examples

  • 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
      

Gameplay

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

Error Handling

  • The program handles invalid inputs gracefully:
    • Provides informative error messages for invalid configurations.
    • Prevents invalid moves and allows users to retry.

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published