Skip to content

Commit

Permalink
up documentation, demo, and version
Browse files Browse the repository at this point in the history
  • Loading branch information
fauzisho committed May 17, 2024
1 parent 5c745be commit 7c9b9ac
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
20 changes: 19 additions & 1 deletion README.md
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
28 changes: 28 additions & 0 deletions demo.py
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
1 change: 1 addition & 0 deletions gymconnectx/envs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from gymconnectx.envs.gymconnectxenv import ConnectGameEnv
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "gymconnectx"
version = "1.0.0"
version = "1.0.1"
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" }]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='gymconnectx',
version='1.0.0',
version='1.0.1',
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',
Expand Down

0 comments on commit 7c9b9ac

Please sign in to comment.