Skip to content

Conversation

@GboyeStack-Robotics-ML-Engineer

Add Connect4 Environment and Supporting Models to OpenEnv

Summary

This pull request introduces a new Connect4 Environment to the OpenEnv framework, expanding its suite of interactive learning environments.
The Connect4 environment follows OpenEnv’s modular design and integrates seamlessly with the existing Environment, Action, and Observation interfaces.


🔑 Key Features

  • 🧠 New Environment

    • Implements full Connect4 game logic: move validation, piece placement, win/draw detection.
    • Compatible with OpenEnv’s standard reset and step lifecycle.
    • Supports unique episode management with uuid.
  • ⚙️ Model Additions

    • Connect4Action – Defines valid column selections as agent actions.
    • Connect4State – Represents board state, active player, and step count.
    • Connect4Observation – Encapsulates board view, legal actions, reward signal, and done status.
  • 🎮 Gameplay Logic

    • Detects 4-in-a-row in four directions (vertical, horizontal, diagonal-down, diagonal-up).
    • Prevents invalid moves (full columns or out-of-range actions).
    • Alternates between players automatically.
    • Tracks rewards and termination conditions for RL agents.
  • 🧩 Visualization Support

    • Optional rendering enhancements to display step count and reward during play.
    • Board updates compatible with existing OpenEnv visualization tools.

Testing out the env
To test out the environment, open two terminals

On terminal 1:
Run the following from root dir (OpenEnv/)

  • cd src
    Then start the server:
    - python -m envs.connect4_env.server.app

On the terminal 2:
Run python examples/connect4.py from root directory (OpenEnv/)

This is an example of the output:
image

image

@meta-cla
Copy link

meta-cla bot commented Oct 27, 2025

Hi @GboyeStack-Robotics-ML-Engineer!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@meta-cla
Copy link

meta-cla bot commented Oct 27, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant