-
-
Notifications
You must be signed in to change notification settings - Fork 748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug Report] Calculating rewards for Blackjack toy-text env #1011
Comments
I'm surprised that no one has noticed this issue with the reward function though admittedly on edge cases What is your suggested changes to the reward in terms of code? |
For case 1: player 21 vs Dealer BJ and vice versa. Currently, the returned reward is 0 (draw) Ex code to test for player = BJ + dealer = 21
Ex code to test for player = 21 & dealer = BJ
For case 2: when both busted: I've rechecked and actually the current codes could handle this. |
Could you make a PR with the suggested changes and tests for the relative rules |
and i am also confused about natural, why here should be sorted? |
on this line: |
I think both cases are handled correctly according to standard rules.
This should also be the case if both player and dealer hit 21 (without either of them having a blackjack) but haven't found this stated explicitly on Wikipedia.
If the player busts, then the dealer does not need to play as indicated by "immediately lose". So the second case should never happen. |
because a natural does not depend on the order, you can either have an Ace + something worth a 10 or have it the other way round. So by sorting first the check is independent of order. As for your other question:
This should not be possible when I look at the current implementation. Can you write code that reproduces this? I would suspect that you did not call |
I believe that @CloseChoice is correct however if @peterhungh3 or @frischzenger disagree, please provide an example case where you believe an issue occurs |
@pseudo-rnd-thoughts @CloseChoice I think what @CloseChoice said is correct, and if that's what gets implemented. Again, my recommendation is just to make the reward calculation function more explicit, because the reward depends on the state of the game, not just what's calculated in score() func I cited above. Back to the case:
If the user has a BJ, the action will be stand. But the step() function won't check if the user has a BJ or not, but will add cards to the dealer until the sum is above 17. As a result, the dealer may get to 21 with say 3 cards. Then the comp() func will return a reward of 0, instead of 1 or 1.5 for users (users always win when having BJ, unless dealer also has BJ). Again, this is a small point. My recommendation is just to make the reward calculation func taking into consideration the state of the game, not just the score of the hand. |
Describe the bug
In blackjack.py: reward = cmp(score(self.player), score(self.dealer))
Current rewards seem wrong for 2 edge cases:
Code example
System info
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: