これは、「PokéLLMon: A Human-Parity Agent for Pokémon battles with Large Language Models(ポケモンバトルのための人間と同等レベルのエージェント、PokéLLMon)」という論文の実装です。
python >= 3.8
openai >= 1.7.2
- Node.js v10以上をインストールします。
- ポケモンショーダウンのリポジトリをクローンしてセットアップします:
git clone https://github.com/smogon/pokemon-showdown.git
cd pokemon-showdown
npm install
cp config/config-example.js config/config.js
node pokemon-showdown start --no-security
ブラウザで "http://localhost:8000/" にアクセスします。
GPT-4 APIを https://platform.openai.com/account/api-keys から取得します。
https://play.pokemonshowdown.com/ でアカウントに登録し、パスワードを取得します。
アカウント登録方法はこちら👇 https://aoi428.hatenablog.com/entry/2017/04/25/055853
from poke_env import AccountConfiguration
# ローカルサーバーでは認証は不要です
my_account_config = AccountConfiguration("your_username", "your_password")
player = Player(account_configuration=my_account_config)
# 公式のショーダウンサーバーでは認証が必要です
from poke_env import AccountConfiguration, ShowdownServerConfiguration
my_account_config = AccountConfiguration("your_username", "your_password")
player = Player(account_configuration=my_account_config, server_configuration=ShowdownServerConfiguration)
docker-compose up --build
で起動
C:\Prj\PokeLLMon>docker-compose up --build
[+] Building 0.0s (0/0) docker:default
[+] Building 748.1s (14/14)
...
showdown 0.0s
[+] Running 1/1
✔ Container pokellmon-pokemon-showdown-1 Recreated 2.1s
Attaching to pokemon-showdown-1
pokemon-showdown-1 | RESTORE CHATROOM: lobby
pokemon-showdown-1 | RESTORE CHATROOM: staff
pokemon-showdown-1 | Worker 1 now listening on 0.0.0.0:8000
pokemon-showdown-1 | Test your server at http://localhost:8000
docker-compose exec pokemon-showdown /bin/bash
でコンテナ内って移動する
C:\Prj\PokeLLMon>docker-compose exec pokemon-showdown /bin/bash
root@0efdf8c76f75:/usr/src/app/pokemon-showdown# cd ../PokeLLMon/
root@0efdf8c76f75:/usr/src/app/PokeLLMon#
python vs_bot.py # PokéLLMonのためにあなたのユーザー名とパスワードを入力します
まず、ローカルサーバー上で別のアカウントに手動でログインし、"[Gen 8] Random Battle"を選択します。
python vs_local_player.py # PokéLLMonのためにあなたのユーザー名とパスワードを入力します
https://play.pokemonshowdown.com/ で開いてログインします。
python vs_ladder_player.py # ローカルサーバーを設定する必要はありません。PokéLLMonのためにあなたのユーザー名とパスワードを入力します。
この環境は Poke Env に基づいて実装されています。