Skip to content

goranbyte/dice-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Dice Betting Game (Advanced CLI)

A command line dice betting game written in C with advanced game mechanics, win streak bonuses and session statistics.

The player bets on a number between 1 and 6. A dice is rolled randomly, and rewards depend on accuracy, streak and proximity to the correct number.

Features

  • Random dice rolling (1–6)
  • Player balance system with starting input
  • Minimum bet requirement ($10)
  • Win streak system with bonus multipliers
  • Near-miss bonus (±1 during streak)
  • Maximum balance tracking
  • Session summary and statistics
  • Input validation
  • Smooth CLI experience with dice roll delay

Game Rules

  • Choose a number between 1 and 6
  • Enter a bet (minimum $10)
  • If your number matches the dice:
    • Win 3x your bet
  • If you have a streak of 2+ wins:
    • Win 5x your bet
  • If you're close (±1) during a streak:
    • Get 1.5x bonus
  • Otherwise:
    • Lose your bet

Game Flow

  1. Set your starting balance (max $1000)
  2. Choose a number (1–6) or 0 to quit
  3. Enter your bet amount
  4. Dice rolls with delay
  5. Game result is calculated
  6. Balance updates
  7. Game continues while balance ≥ $10

Technologies

  • C programming language
  • Standard C libraries
  • stdlib.h for random number generation
  • time.h for seeding randomness
  • unistd.h for delay simulation

What I Learned

  • Structuring larger C programs using functions
  • Managing global state (wins, streaks, statistics)
  • Implementing reward systems and game mechanics
  • Using random number generation with rand()
  • Input validation and control flow
  • Tracking and displaying session statistics

Example

WELCOME TO DICE GAME!

Set your starting balance: $200

Enter your chosen dice number: 4
Enter your bet amount: $50

Rolling the dice...
Dice rolled: 4

Congratulations! You won $150.00!

Player balance: $350.00

Session Summary

  • Total rounds played
  • Wins
  • Win percentage
  • Highest balance reached
  • Longest win streak

Author

Software engineering student at ITS

Flowchart generated by Gemini

gemini_flowchart

About

CLI dice betting game written in C with balance system and random outcomes.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages