Skip to content

Conversation

@Marcosg1
Copy link

@Marcosg1 Marcosg1 commented Oct 7, 2025

This pull request introduces a new user-space utility called Casino, which adds three classic gambling games to FogOS:

Craps:
- A simple dice game where players roll two dice and try to hit winning numbers or their “point.”
Blackjack:
- A card game where players compete against the dealer to get as close to 21 as possible without going over. Features include the ability to split pairs and proper dealer behavior (dealer shows one card until the player's turn ends).
Slots:
- A chance-based slot machine game with ASCII art symbols and animated reels for visual effect.

The utility includes input validation to ensure players only make valid moves, proper game logic for splitting hands in blackjack, and a cool animation for the slot machine.

@Maxxzzz
Copy link

Maxxzzz commented Oct 8, 2025

I will code review this

@HenrikanHa
Copy link

HenrikanHa commented Oct 8, 2025

I will code review this implementation

@lbrod20
Copy link

lbrod20 commented Oct 9, 2025

I will also code review this

@lbrod20
Copy link

lbrod20 commented Oct 9, 2025

Verification
This project was meant to add a Casino utility into the operating system. After testing locally i can confirm that there is indeed a casino added to the operating system

Testing
After an initial walkthrough following the directions that are given as you enter the casino. I tested it a bit more to find some issues.

  1. in the readme, you say you type "Casino" when in reality it is "casino"
  2. When betting you can enter a number much more then you have on hand. If you win with said high number, it never adds to your bankroll and doesnt show up in profits/losses
  3. When given "Enter bet amount (0 to quit):" If you enter anything other then a number it quits
  4. There is no specific test file or directions on how to play on the readme, that being said there are directions given when playing through.
  5. when betting very large numbers (above int space i.e. 2,147,483,648+) it causes odd behavior within the terminal window. such as
Enter bet amount (0 to quit): 8,147,483,647

Dealer's hand:
+-----+ +-----+ 
|/////| |6    | 
|/////| |  ♥  | 
|/////| |    6| 
+-----+ +-----+ 

Your hand 1:
+-----+ +-----+ 
|J    | |10   | 
|  ♥  | |  ♠  | 
|    J| |   10| 
+-----+ +-----+ 
Total: 20
Hit or Stand? (h/s): Invalid input. Please enter h or s.
Hit or Stand? (h/s): Invalid input. Please enter h or s.
Hit or Stand? (h/s): Invalid input. Please enter h or s.
Hit or Stand? (h/s): Invalid input. Please enter h or s.
Hit or Stand? (h/s): Invalid input. Please enter h or s.

Code Walkthrough

  1. No documentation present for the changes in mkfs/mkfs.c
  2. in blackjack.c in the "main" I would add some more thorough documentation explaining what is going on as it is a very big function
  3. In the mains for each game you should add an if check to see if the bet is more then bankroll, if so print invalid bet
  4. I see in subtract_bet() you check if theres enough but if theres not it auto refills. This begs the question of what if user inputs number bigger then what can be stored

Formatting
Formatting is consistent I see no issues

Overall
I do like how organized the codebase is. Everything seems thought out and put in place for a reason. The actual utility itself is very fun to play with and waste time with. Very little issues solvable with thorough documentation and one or two more functions.

High Level Checks:

  • PR fully resolves the task/issue
  • Does the PR have tests? (no but not sure it needs it)
  • Does the PR follow project code formatting standards?
  • Does the OS still compile and run?
  • Is documentation included? (yes but more thorough documentation is needed)

Code Checks:

  • Does the code achieve its intended purpose?
  • Were all edge cases considered?
  • Is the code organized and maintainable?
  • Does the code maintain the same level of performance? (no performance regressions)

@HenrikanHa
Copy link

HenrikanHa commented Oct 11, 2025

Verification
The goal of this PR is to add a fully working Casino utility to xv6, with three playable games (Craps, Blackjack, Slots), a shared bankroll system, and a main menu to access them. All three games are implemented and accessible from the casino command. A balance system with wins/losses is included and shown to the user. One limitation is that input validation is minimal (e.g., typing letters instead of numbers acts as a “quit”).

Testing
This PR does not include any automated test cases, so I tested the Craps game manually. The basic gameplay works, but several edge cases are not handled.

  • General Edge Cases Across Games
  1. Empty / invalid input: Typing something like abc or any non-number is treated as 0, which makes the game immediately exit instead of asking again.
  2. Negative bet: Entering -10 is also treated as 0, causing the game to quit instead of rejecting the input.
  3. Massive bet: Very large numbers (like 99999999999999) cause overflow and lead to unrealistic results or force the game to exit.

Craps

  • Edge cases tested:
    Repeated rolls: Multiple Enter presses works, but no input validation if something else is typed before Enter.

Blackjack

  • Edge cases tested:
    Massive bet: Very large values (e.g., 88888888888888) cause the game to instantly exit.
Enter bet amount (0 to quit): 8888888888888888888888
Leaving the blackjack table.
=====================
 Casino Menu
=====================
1. Craps
2. Blackjack
3. Slots
4. Cashout (quit)
Enter your choice: Invalid choice. Try again.
=====================
 Casino Menu
=====================
1. Craps
2. Blackjack
3. Slots
4. Cashout (quit)
Enter your choice: Invalid choice. Try again.
=====================
 Casino Menu
=====================
1. Craps
2. Blackjack
3. Slots
4. Cashout (quit)
Enter your choice: Invalid choice. Try again.
=====================
 Casino Menu
=====================
1. Craps
2. Blackjack
3. Slots
4. Cashout (quit)
Enter your choice: 

Slot

  • Edge cases tested:
    If I types something like:
    abc
    123
    The game still spins normally. It doesn’t check what the user typed. It just reads the input and moves on.

Code Walkthrough
The core structure is clear, with each game separated and a shared money system.
Main logic works, but some important safeguards are missing:

  • Add a safe function to validate bets.
  • Set a maximum bet to prevent overflow and unrealistic bankroll values.
    Rules are explained in documents.

Formatting
Formatting is consistent throughout the codebase, and code is readable. The code structure (separate source files for each game) is clean and organized.

High Level Checks:

  • PR fully resolves the task/issue
  • Does the PR have tests? (No tests are included)
  • Does the PR follow project code formatting standards?
  • Does the OS still compile and run?
  • Is documentation included? (Yes, but partially. Gameplay rules are documented, but there are no instructions on how to build, run, or test the Casino utility. More detailed steps or guidance for testers should be included.)

Code Checks:

  • Does the code achieve its intended purpose?
  • Were all edge cases considered? (Some edge cases were missed: invalid input, max bet overflow, split betting logic)
  • Is the code organized and maintainable?
  • Does the code maintain the same level of performance? (no performance regressions)

@Maxxzzz
Copy link

Maxxzzz commented Oct 11, 2025

Verification: This does indeed create a new user space utility called casino that when run does infact create a casino in our operating system space with games craps, blackjack, and slots.

Testing: There were no clear intructions for exactly how to test your application. I don't believe you need exact tests for your user program casino as there is no exact tests as you can decide between 4 options 3 being games. Also its easy to test and figure out how to play each game due to casino.md in docs as there is step by step instructions on how to play and how you win/lose.

After testing with multiple inputs in each of your games I noticed a few errors

  1. When u start the casino you are given 1000 starting balance but even if u bet more than your starting balance the game allows it and continues onward pretty sure this is unintended.
  2. Don't believe total profit/loss tracks correctly as the only time I see it updated is when you go below 0 and it hard codes -1000 like for example with the picture below

Total profit/loss: -1000
Current bankroll: -294000
Projected cashout: -295000

Enter bet amount (0 to quit): 10000
[Not enough bankroll for bet of 10000. Auto-refilling.]
[Bankroll replenished. -1000 from total]

It auto refills me 1000 since my balance is negative but it still results in a negative bankroll which I dont believe is the intended target.

  1. When I entered large numbers my program sometimes would produce weird terminal output even thought I didn't enter the number 0 to quit.

Welecome to BLACKJACK!!!

========== BALANCE ==========
Total profit/loss: 0
Current bankroll: 1000
Projected cashout: 1000

Enter bet amount (0 to quit): 99999999999999999999

Leaving the blackjack table.

=====================
Casino Menu

  1. Craps
  2. Blackjack
  3. Slots
  4. Cashout (quit)
    Enter your choice: Invalid choice. Try again.

=====================
Casino Menu

  1. Craps
  2. Blackjack
  3. Slots
  4. Cashout (quit)
    Enter your choice: Invalid choice. Try again.

Code Walkthrough: Overall the documentation is pretty good in casino.md as it clearly describes a short summary of what the casino is and the different games involved and rules on how to play each and the different numbers associated with them which is the same as the casino menu.
Some test cases we missed are definitely with betting over your current bankroll as it allows you to bet more than your bankroll. Maybe check to see if bets are bigger than the amount we have.
Also with out total profit/loss it only updates and give the user -1000 when they are below or = 0. As of now we are allowed to bet more than our bankroll meaning if we lose as shown above we are at -295000 but the bank only updated profit/loss to -1000 still leaving us with a negative balance of -294000. This is seen in your ensure_bankroll function in money.c where its hard coded to only give us 1000 everytime we go below or equal 0 in our bankroll. This function could work if we add a check to make sure our bets are not greater than our bankroll as we will never have a negative bankroll so we won't run into this issue.

Formatting: Formatting for the most part seems accurate and consistent with helpful comments and consisteny spacing and indentation.

High Level Checks:

  • PR fully resolves the task/issue
  • Does the PR have tests? (doesn't seem to require tests)
  • Does the PR follow project code formatting standards?
  • Does the OS still compile and run?
  • Is documentation included? (for the most part in casino.md but there is no documentation on how to build and run your casino utility)

Code Checks:

  • Does the code achieve its intended purpose?
  • Were all edge cases considered? (I would just make it so the user can't bet more than their bankroll)
  • Is the code organized and maintainable?
  • Does the code maintain the same level of performance? (no performance regressions)

Thoughts: Honestly great utility thats fun and feels like a real casino with 3 fun functioning games. My favorite is definitely blackjack though as you have an actual decision unlike the other 2 games which are practically luck.

@malensek
Copy link
Contributor

I was hoping this had a feature that detected me playing it and always let me win, but no luck there.

It works great. Animations are good, it's got ASCII art, but yes, the three reviewers are right: you need to check to make sure the player can actually bet the amount they specify. Somehow I won millions, lost billions and went broke, was given $1000, went broke again, and then somehow when I cashed out I was at -$1000.

Overall, great job.

4.75/5
Fix the bank balance issue to get +0.25.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants