diff --git a/README.md b/README.md index 4d31f75..cf2a06d 100644 --- a/README.md +++ b/README.md @@ -117,5 +117,5 @@ The `ConnectGameEnv` class is designed to simulate a Connect 4-like game environ - **max_steps** (int): The maximum number of steps the game can take before it ends. Default is `100`. - **delay** (int): Time delay (in milliseconds) between moves, primarily used for GUI purposes. Default is `100`. - **square_size** (int): Size of the squares in the GUI. Default is `100`. -- **avatar_player_1** (string): Base64 format avatar image for player 1. This is used in the GUI. -- **avatar_player_2** (string): Base64 format avatar image for player 2. This is used in the GUI. +- **avatar_player_1** (string): Base64/path format avatar image for player 1. This is used in the GUI. +- **avatar_player_2** (string): Base64/path format avatar image for player 2. This is used in the GUI. diff --git a/run_env.py b/demo.py similarity index 96% rename from run_env.py rename to demo.py index 4e0e41a..d25b4b4 100644 --- a/run_env.py +++ b/demo.py @@ -19,6 +19,7 @@ def run_game_env(): env.render(mode='terminal_display') env.render(mode='gui_update_display') + print(f'Observation: {observations}') print(f"Step: {env.current_step}, " f"Move: {move}, " f"Rewards: {rewards}, " diff --git a/gymconnectx/envs/gymconnectxenv.py b/gymconnectx/envs/gymconnectxenv.py index 57d9e57..f280bbf 100644 --- a/gymconnectx/envs/gymconnectxenv.py +++ b/gymconnectx/envs/gymconnectxenv.py @@ -1,11 +1,12 @@ import os import re import urllib +import urllib.request from typing import List import io import gym from gym.spaces import Box, Discrete, Tuple -import base64 +import imgBase64 import pygame import sys import numpy as np @@ -65,16 +66,10 @@ def load_image_from_path(self, path): """Loads an image from a local file path and resizes it.""" return self.process_image(pygame.image.load(path)) - def load_image_from_url(self, url): - """Loads an image from a URL and resizes it.""" - with urllib.request.urlopen(url) as response: - image_data = response.read() - return self.process_image(pygame.image.load(io.BytesIO(image_data))) - def load_avatar(self, avatar_string): """Determines the type of the avatar input and loads the image accordingly.""" - if self.is_url(avatar_string): - return self.load_image_from_url(avatar_string) + if avatar_string is None: + return None elif self.is_base64(avatar_string): return self.load_image_from_base64(avatar_string) elif avatar_string is not None: diff --git a/example_base64.py b/imgBase64.py similarity index 100% rename from example_base64.py rename to imgBase64.py diff --git a/pyproject.toml b/pyproject.toml index 8ae379f..6024b45 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "gymconnectx" -version = "1.0.3" +version = "1.0.4" description = "An OpenAI Gym Environment Connect X Game with GUI. ConnectX is a game for two players that is based on the well-known Connect 4. The goal is to place X coins in a row, column, or diagonal on a board with dimensions M by N." readme = "README.md" authors = [{ name = "Fauzi Sholichin" }] @@ -14,7 +14,7 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", ] -keywords = ["tictactoe", "gym", "pygame"] +keywords = ["connect4", "gym", "pygame", "reinforcement learning"] dependencies = ["gym", "pygame"] requires-python = ">=3.9" diff --git a/setup.py b/setup.py index d8b9be8..03baa9e 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='gymconnectx', - version='1.0.3', + version='1.0.4', description='ConnectX is a game for two players that is based on the well-known Connect 4. The goal is to place X coins in a row, column, or diagonal on a board with dimensions M by N.', url='https://github.com/fauzisho/GymConnectX', author='Fauzi Sholichin',