Skip to content
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

Bugfixes for RLCard environments: render fps, black screen flashing #1103

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pettingzoo/classic/rlcard_envs/gin_rummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ def draw_borders(x, y, width, height, bw, color):
if self.screen is None:
pygame.init()

if self.render_mode == "human":
self.screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Gin Rummy")
else:
self.screen = pygame.Surface((screen_width, screen_height))
if self.render_mode == "human":
self.screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Gin Rummy")
else:
self.screen = pygame.Surface((screen_width, screen_height))

# Setup dimensions for card size and setup for colors
tile_size = screen_height * 2 / 10
Expand Down
10 changes: 5 additions & 5 deletions pettingzoo/classic/rlcard_envs/leduc_holdem.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ def calculate_height(screen_height, divisor, multiplier, tile_size, offset):
if self.screen is None:
pygame.init()

if self.render_mode == "human":
self.screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Leduc Hold'em")
else:
self.screen = pygame.Surface((screen_width, screen_height))
if self.render_mode == "human":
self.screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Leduc Hold'em")
else:
self.screen = pygame.Surface((screen_width, screen_height))

# Setup dimensions for card size and setup for colors
tile_size = screen_height * 2 / 10
Expand Down
11 changes: 6 additions & 5 deletions pettingzoo/classic/rlcard_envs/texas_holdem.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ def calculate_height(screen_height, divisor, multiplier, tile_size, offset):
if self.screen is None:
pygame.init()

if self.render_mode == "human":
self.screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Texas Hold'em")
else:
self.screen = pygame.Surface((screen_width, screen_height))
if self.render_mode == "human":
self.screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Texas Hold'em")
else:
self.screen = pygame.Surface((screen_width, screen_height))

# Setup dimensions for card size and setup for colors
tile_size = screen_height * 2 / 10
Expand Down Expand Up @@ -422,6 +422,7 @@ def calculate_height(screen_height, divisor, multiplier, tile_size, offset):

if self.render_mode == "human":
pygame.display.update()
self.clock.tick(self.metadata["render_fps"])

observation = np.array(pygame.surfarray.pixels3d(self.screen))

Expand Down
11 changes: 6 additions & 5 deletions pettingzoo/classic/rlcard_envs/texas_holdem_no_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ def calculate_height(screen_height, divisor, multiplier, tile_size, offset):
if self.screen is None:
pygame.init()

if self.render_mode == "human":
self.screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Texas Hold'em No Limit")
else:
self.screen = pygame.Surface((screen_width, screen_height))
if self.render_mode == "human":
self.screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Texas Hold'em No Limit")
else:
self.screen = pygame.Surface((screen_width, screen_height))

# Setup dimensions for card size and setup for colors
tile_size = screen_height * 2 / 10
Expand Down Expand Up @@ -460,6 +460,7 @@ def calculate_height(screen_height, divisor, multiplier, tile_size, offset):

if self.render_mode == "human":
pygame.display.update()
self.clock.tick(self.metadata["render_fps"])

observation = np.array(pygame.surfarray.pixels3d(self.screen))

Expand Down