Skip to content

Commit

Permalink
Major bug fix.
Browse files Browse the repository at this point in the history
Calculator now includes multiple aces in hand and simulates games correctly.
  • Loading branch information
krisluczka committed Jul 17, 2024
1 parent f1adfcd commit 594f1b0
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ void simulation( uint_fast64_t amount ) {
++stand_wins;
continue;
}

dealer_score = low_dealer_score;
}

Expand Down Expand Up @@ -227,16 +228,19 @@ void simulation( uint_fast64_t amount ) {
if ( low_player_score > 21 )
continue;
player_score = low_player_score;
player_ace = false;
}

// tactic didn't work because of player's overflow
else
continue;
}

// if blackjack - do not take more
if ( player_score == 21 )
// if blackjack - win
if ( player_score == 21 ) {
//++hit_wins;
continue;
}

// dealer starting ace test
dealer_ace = (dealer_card == card_A);
Expand Down Expand Up @@ -271,6 +275,7 @@ void simulation( uint_fast64_t amount ) {
continue;
}
dealer_score = low_dealer_score;
dealer_ace = false;
}

// tactic worked because of dealer's overflow
Expand Down Expand Up @@ -341,8 +346,10 @@ void simulation( uint_fast64_t amount ) {

if ( player_score > 21 ) {
// if overflowed use the ace
if ( player_ace )
if ( player_ace ) {
player_score = low_player_score;
player_ace = false;
}

// tactic didn't work because of player's overflow
else
Expand Down

0 comments on commit 594f1b0

Please sign in to comment.