Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
DeepGeGe a6e3f5489d | 2 years ago | |
---|---|---|
.. | ||
gym_go | 2 years ago | |
screenshots | 2 years ago | |
.gitignore | 2 years ago | |
README.md | 2 years ago | |
demo.py | 2 years ago | |
setup.py | 2 years ago |
An environment for the board game Go. It is implemented using OpenAI's Gym API.
It is also optimized to be as efficient as possible in order to efficiently train ML models.
# In the root directory
pip install -e .
# In the root directory
python3 demo.py
import gym
go_env = gym.make('gym_go:go-v0', size=7, komi=0, reward_method='real')
first_action = (2,5)
second_action = (5,2)
state, reward, done, info = go_env.step(first_action)
go_env.render('terminal')
0 1 2 3 4 5 6
-----------------------------
0 | | | | | | | |
-----------------------------
1 | | | | | | | |
-----------------------------
2 | | | | | | B | |
-----------------------------
3 | | | | | | | |
-----------------------------
4 | | | | | | | |
-----------------------------
5 | | | | | | | |
-----------------------------
6 | | | | | | | |
-----------------------------
Turn: WHITE, Last Turn Passed: False, Game Over: False
Black Area: 49, White Area: 0, Reward: 0
state, reward, done, info = go_env.step(second_action)
go_env.render('terminal')
0 1 2 3 4 5 6
-----------------------------
0 | | | | | | | |
-----------------------------
1 | | | | | | | |
-----------------------------
2 | | | | | | B | |
-----------------------------
3 | | | | | | | |
-----------------------------
4 | | | | | | | |
-----------------------------
5 | | | W | | | | |
-----------------------------
6 | | | | | | | |
-----------------------------
Turn: BLACK, Last Turn Passed: False, Game Over: False
Black Area: 1, White Area: 1, Reward: 0
GoEnv defines the Gym environment for Go.
It contains the highest level API for basic Go usage.
GoGame is the set of low-level functions that defines all the game logic of Go.
GoEnv
's high level API is built on GoGame
.
These sets of functions are intended for a more detailed and finetuned
usage of Go.
We use Trump Taylor scoring, a simple area scoring, to determine the winner. A player's area is defined as the number of empty points a
player's pieces surround plus the number of player's pieces on the board. The winner is the player with the larger
area (a game is tied if both players have an equal amount of area on the board).
There is also support for komi
, a bias score constant to balance the advantage of black going first.
By default komi
is set to 0.
A game ends when both players pass consecutively
Reward methods are in black's perspective
-1
- White won0
- Game is tied1
- Black won0
- Otherwiseblack area - white area
.BOARD_SIZE**2
.-BOARD_SIZE**2
.0
.The state
object that is returned by the reset
and step
functions of the environment is a
6 x BOARD_SIZE x BOARD_SIZE
numpy array. All values in the array are either 0
or 1
The step
function takes in the action to execute and can be in the following forms:
None
for passingNo Description
Python other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》