
 [ AI AVALON Connect Operation ]
                          Copyright (c) 2022 Hidetoshi NAGAI
                          Copyright (c) 2022 Kyutech AI AVALON Team

Protocol Version Support: 0.8.3 and above


This document defines the protocol for establishing connection between the
server and client.

The procedure is as follows. Note that "<LF>" represents a line feed (0x0a).
Additionally, a timeout is set for responses from the client to the server.
If no response is received within the specified time, the server will send
"TIMEOUT<LF>" and disconnect.
The timeout duration used is twice the timeout set for sending.

---< Establish TCP Connection >---

step-1. server -> client
# Send server version.
AI_AVALON Server <version><LF>

step-2. client -> server
# Reply with client version.
AI_AVALON Client <version><LF>

step-3. server -> client
# Verify version; if correct, proceed.
READY<LF>
# If there's an issue, send the following and disconnect:
DENY <err_msg><LF>
# However, <err_msg> is defined as follows:
#   MSG: Incorrect response data structure
#   FMT: Abnormal version string
#   VER: Version mismatch

step-4. client -> server
# Reply with whether the agent is AI or HM (human), along with the agent's
# name for logging purposes.
# The agent's name can be used to confirm the correspondence between player
# numbers and agents.
AGENT <AI|HM> <name><LF>

step-5. server -> client
# Send the registered agent name for logging, timeout duration for each
# message send-out, and the composition list of each role.
OK <logname> <timeout> <roles><LF>
# The registered name (logname) shall be formed by appending ":0" through
# ":9" to the specified agent name.
# The composition list consists of the following roles in order:
#    SERVANT, MERLIN, PERCIVAL, MINION, ASSASSIN, MORDRED, MORGANA, OBERON
# listed with commas (no spaces) separating the numbers.
# These pieces of information can be passed to the agent program as
# configuration data at the time of agent program startup.
# If there's an issue, send the following and disconnect:
DENY <err_msg><LF>
# However, <err_msg> is defined as follows:
#   MSG: Incorrect response data structure
#   MOD: Incorrect specification of AI or HM
#   NAM: Invalid name string (includes whitespace)


---< Player Registration >---

Upon successful completion of the connection process, the server side
generates a single player object and enters a waiting state. Meanwhile,
on the client side, the agent initialization should be promptly completed.
Once the required number of players has gathered, the player object is
registered, the server process is started, and the gameplay is initiated.


-----------------------------------------------------------------------------
end of document
-----------------------------------------------------------------------------
