Repository: openai/gym

Issue:
[Bug Report] Small bug in blackjack rendering


**Describe the bug**
There is a bug in blackjack rendering where the suit of the displayed card from the dealer is re-randomized on each call to render, and if the dealer's displayed card is a face card, the face card is re-randomized on each call to render. The underlying data structure represents each face card as 10, which means that render has to make up which face card the dealer has drawn. I will be adding an attached PR with a proposed fix, so that the suit/face card remains stable across calls to render. 

**Code example**
````
import time
import gym 

seed = int(time.time())
env = gym.make("Blackjack-v1")
obs = env.reset()
action = 1
for i in range(6):
    env.render()
    input()
    obs, reward, done, info = env.step(action)

````
![face-card](https://user-images.githubusercontent.com/20377292/175170550-700bf2c6-1de5-4c5d-97d5-b04b267a9773.gif)

![non-face-card](https://user-images.githubusercontent.com/20377292/175170560-45f3fde0-4633-45a3-8fa3-307a925c2ebf.gif)


**System Info**
this shouldn't be relevant, but python3.8 on Ubuntu 20.04

**Additional context**


### Checklist

- [x] I have checked that there is no similar [issue](https://github.com/openai/gym/issues) in the repo (**required**)



Discussion:

Resolving patch:
diff --git a/gym/envs/toy_text/blackjack.py b/gym/envs/toy_text/blackjack.py
--- a/gym/envs/toy_text/blackjack.py
+++ b/gym/envs/toy_text/blackjack.py
@@ -175,6 +175,18 @@ def reset(
         self.dealer = draw_hand(self.np_random)
         self.player = draw_hand(self.np_random)
 
+        _, dealer_card_value, _ = self._get_obs()
+
+        suits = ["C", "D", "H", "S"]
+        self.dealer_top_card_suit = self.np_random.choice(suits)
+
+        if dealer_card_value == 1:
+            self.dealer_top_card_value_str = "A"
+        elif dealer_card_value == 10:
+            self.dealer_top_card_value_str = self.np_random.choice(["J", "Q", "K"])
+        else:
+            self.dealer_top_card_value_str = str(dealer_card_value)
+
         self.renderer.reset()
         self.renderer.render_step()
 
@@ -240,22 +252,15 @@ def get_font(path, size):
         )
         dealer_text_rect = self.screen.blit(dealer_text, (spacing, spacing))
 
-        suits = ["C", "D", "H", "S"]
-        dealer_card_suit = self.np_random.choice(suits)
-
-        if dealer_card_value == 1:
-            dealer_card_value_str = "A"
-        elif dealer_card_value == 10:
-            dealer_card_value_str = self.np_random.choice(["J", "Q", "K"])
-        else:
-            dealer_card_value_str = str(dealer_card_value)
-
         def scale_card_img(card_img):
             return pygame.transform.scale(card_img, (card_img_width, card_img_height))
 
         dealer_card_img = scale_card_img(
             get_image(
-                os.path.join("img", dealer_card_suit + dealer_card_value_str + ".png")
+                os.path.join(
+                    "img",
+                    f"{self.dealer_top_card_suit}{self.dealer_top_card_value_str}.png",
+                )
             )
         )
         dealer_card_rect = self.screen.blit(


Test patch: