Python exercise doubt in Kaggle #4
-
Hi there I 'm Soumyadeep from GDSC-TIU , I could not understand this question Could anyone help me out this question . 🌶️ (Optional) The player is dealt two face-up cards. The dealer is dealt one face-up card. For this problem, you'll write a function representing the player's decision-making strategy in this game. We've provided a very unintelligent implementation below: def should_hit(dealer_total, player_total, player_low_aces, player_high_aces):
This very conservative agent always sticks with the hand of two cards that they're dealt. We'll be simulating games between your player agent and our own dealer agent by calling your function. Try running the function below to see an example of a simulated game: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey, I really appreciate your participation! The first thing to note is how the game starts. You are given two cards as the player and the dealer (opponent) has one card at the very start. Now, you(player) have the option to either ask for another card ("HIT") as long as you want. Then once you are done with drawing more cards, the dealer starts drawing cards. They also can choose as many as they want and stop. The one whose sum of cards exceeds 21 first loses the game. (When either Other conditions:
So the goal here is to write a logical function using simple if else-if and else, and this function will be simulated for over 50000 games and your win percentage will be revealed to you. So, try to break the problem in different sub-cases and use conditional statements to design such a function, you can easily get an accuracy of around ~ If you want to improve the accuracy by a very small margin, you could study blackjack and common strategies when players generally quit the game and you can use those checks in your function. Try to design and write some logic for this. Hope this clears things out a little for you! If you are still stuck then let me know. 😃 |
Beta Was this translation helpful? Give feedback.
Hey, I really appreciate your participation!
The first thing to note is how the game starts. You are given two cards as the player and the dealer (opponent) has one card at the very start.
Now, you(player) have the option to either ask for another card ("HIT") as long as you want. Then once you are done with drawing more cards, the dealer starts drawing cards. They also can choose as many as they want and stop.
The one whose sum of cards exceeds 21 first loses the game. (When either
player_total
ordealer_total
exceeds 21)Other conditions:
player_total
under 21.S…