选自GitHub
强化学习算法没有游戏训练?DeepMind 开源 OpenSpiel 平台了。研究者可在线部署游戏环境,快速开始实验。
项目地址:https://github.com/deepmind/open_spiel
单人或多人博弈;
完美信息或不完美信息博弈;
带有随机性的博弈;
普通的多玩家「一步」或二人玩家的多步博弈;
交替行动(如下棋)或同时行动的游戏;
零和博弈和非零和博弈(如需要合作的博弈等)。
C++11
Python 3
以及一个支持 Swift 语言的缩减版
import random
import pyspiel
game = pyspiel.load_game("kuhn_poker")
state = game.new_initial_state()
while not state.is_terminal():
legal_actions = state.legal_actions()
if state.is_chance_node():
# Sample a chance event outcome.
outcomes_with_probs = state.chance_outcomes()
action_list, prob_list = zip(*outcomes_with_probs)
action = np.random.choice(action_list, p=prob_list)
state.apply_action(action)
else:
# The algorithm can pick an action based on an observation (fully observable
# games) or an information state (information available for that player)
# We arbitrarily select the first available action as an example.
action = legal_actions[0]
state.apply_action(action)
virtualenc -p python3 venv
source venv/bin/activate
pip3 install -r requirements.txt
mkdir build
cd build
CXX=g++ cmake -DPython_TARGET_VERSION=3.6 -DCMAKE_CXX_COMPILER=${CXX} ../open_spiel
make -j$(nproc)
ctest -j$(nproc)
./open_spiel/scripts/build_and_run_tests.sh
export PYTHONPATH=$PYTHONPATH:/<path_to_open_spiel>
export PYTHONPATH=$PYTHONPATH:/<path_to_open_spiel>/build/python