21 lines
632 B
Python
21 lines
632 B
Python
import gym
|
|
from gym import spaces
|
|
import numpy as np
|
|
|
|
class ChengduMahjongEnv(gym.Env):
|
|
def __init__(self):
|
|
super(ChengduMahjongEnv, self).__init__()
|
|
self.observation_space = spaces.Box(low=0, high=4, shape=(136,), dtype=np.int32) # 每张牌的状态
|
|
self.action_space = spaces.Discrete(136) # 可选择打出的牌
|
|
|
|
def reset(self):
|
|
# 初始化麻将牌局
|
|
self.state = np.zeros(136)
|
|
return self.state
|
|
|
|
def step(self, action):
|
|
# 模拟玩家动作
|
|
reward = 0 # 根据规则计算得分
|
|
done = False
|
|
return self.state, reward, done, {}
|