Skip to main content

A sample python code of an AIWolf Contest's agent for Natural Language Division.

Project description

AIWolfNLP-Common

概要

人狼知能大会自然言語部門に参加する方向けのパッケージです。 aiwolf-nlp-serverから送信されるプロトコルからオブジェクトを作成し、返却します。

使い方

サンプルコード

以下のコードでは、ゲームサーバから受け取ったJSON形式の文字列を使用してオブジェクトを生成します。生成されたオブジェクトは、JSONデータ内の値にアクセスできるように設計されており、Keyを指定することでデータを取り出すことができます。 例えば、以下のサンプルでは request や agent の情報にアクセスしています。

from aiwolf_nlp_common.protocol import CommunicationProtocol

recv:str = """{"request":"INITIALIZE","info":{"statusMap":{"Agent[01]":"ALIVE","Agent[02]":"ALIVE","Agent[03]":"ALIVE","Agent[04]":"ALIVE","Agent[05]":"ALIVE"},"roleMap":{"Agent[02]":"SEER"},"remainTalkMap":{},"remainWhisperMap":{},"day":0,"agent":"Agent[02]"},"setting":{"roleNumMap":{"BODYGUARD":0,"MEDIUM":0,"POSSESSED":0,"SEER":1,"VILLAGER":3,"WEREWOLF":1},"maxTalk":3,"maxTalkTurn":15,"maxWhisper":3,"maxWhisperTurn":15,"maxSkip":3,"isEnableNoAttack":true,"isVoteVisible":false,"isTalkOnFirstDay":true,"responseTimeout":90000,"actionTimeout":60000,"maxRevote":1,"maxAttackRevote":1}}"""
protocol = CommunicationProtocol.initialize_from_json(received_str=recv)

print(protocol.request)        # JSON内の "request" の値を取得
print(protocol.info.agent)     # JSON内の "info" の中の "agent" の値を取得

実行結果

INITIALIZE
Agent[02]

詳細については下記のプロトコルの説明やソースコードを参考にしてください。

プロトコルについて: https://github.com/kano-lab/aiwolf-nlp-server/blob/main/doc/protocol.md

手順

$ pip install aiwolf-nlp-common

[!WARNING] pip install aiwolf-nlp-common に失敗する場合は、以下のURLを参照してください。 https://pypi.org/project/aiwolf-nlp-common/0.0.1/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiwolf_nlp_common-0.0.3.tar.gz (86.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiwolf_nlp_common-0.0.3-py3-none-any.whl (36.8 kB view details)

Uploaded Python 3

File details

Details for the file aiwolf_nlp_common-0.0.3.tar.gz.

File metadata

  • Download URL: aiwolf_nlp_common-0.0.3.tar.gz
  • Upload date:
  • Size: 86.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.10

File hashes

Hashes for aiwolf_nlp_common-0.0.3.tar.gz
Algorithm Hash digest
SHA256 2eb994bbf99d8c4ed853b4e4aaa6f1919855f171e61993122cd8a0a625274c7e
MD5 c5269d41a7fd0b20a7da8f069736f854
BLAKE2b-256 b3b9057509af192a7663bc982b8971deeab431a6be4587a35bfdab4be41a2a53

See more details on using hashes here.

File details

Details for the file aiwolf_nlp_common-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for aiwolf_nlp_common-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8a5e52efdf54294ea2de353fe1930841b5bf5a43dd1e9ba7fa4653f364c2ca8c
MD5 420753a497c7f8d596a6a3ce1dd43cc5
BLAKE2b-256 d30900df68e3aebffcec1f5c7b8c408e747ac76ae70efa0fa91dc7051e596dc8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page