-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
GYM Connect X | ||
# Connect Game Environment | ||
|
||
This repository contains the implementation of a Connect Game Environment using OpenAI's Gym and Pygame for rendering. The environment supports various game modes like Connect Four and includes features like GUI display, avatar support for players, and different modes of player interaction (human, random). | ||
|
||
## Table of Contents | ||
|
||
- [Description](#description) | ||
- [Installation](#installation) | ||
|
||
## Description | ||
|
||
The Connect Game Environment is a customizable and interactive environment for simulating Connect-style games. It leverages the OpenAI Gym interface for standard reinforcement learning interactions and uses Pygame for graphical rendering. The environment allows for different configurations of the board size and connect length and includes support for different player types, including human players and random agents. | ||
|
||
## Installation | ||
|
||
To use this environment, you need to have Python installed. You can install the necessary packages using `pip`: | ||
|
||
```bash | ||
pip install gymconnectx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import gymconnectx | ||
import gym | ||
|
||
if __name__ == "__main__": | ||
env = gym('gymconnectx/ConnectGameEnv') | ||
env.reset() | ||
|
||
while not env.is_done and env.current_step < env.max_steps: | ||
try: | ||
move = env.set_players(player_1_mode='random', player_2_mode='random') | ||
observations, rewards, done, info = env.step(move) | ||
env.render(mode='terminal_display') | ||
env.render(mode='gui_update_display') | ||
print(f"Step: {env.current_step}, " | ||
f"Move: {move}, " | ||
f"Rewards: {rewards}, " | ||
f"Done: {done}, " | ||
f"Info: {info}") | ||
print(env.get_game_status()) | ||
if done: | ||
break | ||
else: | ||
# Increment the step counter if the game is not finished. | ||
env.current_step += 1 | ||
|
||
except Exception as e: | ||
print(f"An error occurred: {str(e)}") | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from gymconnectx.envs.gymconnectxenv import ConnectGameEnv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters