Made minor updation in BlackjackGame.py #334
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
###Minor issues in the code are as follows:
Incorrect use of
dealerinrefreshPlayerCard:dealerinstead ofself.dealerwhen resetting the dealer's cards in therefreshPlayerCardmethod, leading to a potentialNameErrorbecausedealerisn't defined in the method's scope.No shuffling of the card deck:
genDeckmethod, while generating the deck, the cards were not shuffled. Without shuffling, cards would be drawn in the same predictable order, affecting randomness.Ace value adjustment issue:
getScoremethod. When the total score exceeded 21, the value of Ace should be adjusted to 1. However, this was not implemented until after calculating the score. The logic was also missing in the main loop.Betting issues:
Game logic errors in
playRound3:elifblocks that didn't adequately cover all possible scenarios.Duplicate result outputs:
playRound3method led to duplicate results being printed, especially in cases where both the dealer and the player went bust (score > 21).Missing
adjustAceValuemethod call:Changes made:
Fixed the
refreshPlayerCardmethod: Now usingself.dealerinstead ofdealerto clear the dealer's cards.Modified
getScoreto calladjustAceValue: This ensures Ace values are adjusted properly if the score exceeds 21.Added
random.shuffleingenDeck: This shuffles the deck after generation to randomize card draws.Revised
removeLossers: Changed to filter the player list using a list comprehension, removing players with no money.