
 [ AI AVALON Protocol ver.0.9.0 ]
                          Copyright (c) 2022 Hidetoshi NAGAI
                          Copyright (c) 2022 Kyutech AI AVALON Team


******* ATTENTION *******
This text is a translation of the Japanese version of the document. In the
event of grammatical errors, ambiguities, or inconsistencies, the content of
the original Japanese document is assumed to be the correct description.

This document describes various formats used in information exchange, but
they specify the information contained in the formats, rather than the
specific format of the text data.

The actual data structures for binary data and text data used in information
exchange are described in another document, so please refer to them when
implementing.


-----------------------------------------------------------------------------
1. Overall Flow of the Game

Except for message exchanges during the <discussion> sub-phase described
later, the overall flow of play and the messages sent and received are as
follows.

Among the messages sent from the server to the players, messages likely to
be referenced in the <discussion> sub-phase are assigned a sequential ID as
identifiers during the play. The initial message ID is 1, and ID number 0
signifies no targeted message.

The messages sent from the server also contain information that should be
obvious to players if they are managing the situation properly. Additionally,
sender information in the messages is evident from the server side and is not
necessary. These elements are included to reduce the effort of confirmation
or referencing previous messages, but they are redundant, so there is a
possibility of removing them in future protocol updates.

Note that the parts enclosed in double quotes and represented as strings will
be encoded with code numbers during the specific implementation phase.


=============================================================================
---< setup >-----------------------------
(1) Set the number of players and the role configuration for the play.

    The number of players in "THE RESISTANCE:AVALON" is set between 5
    to 10 players, but AI AVALON defaults to a standard of 10 players.
    Although there is no rule stipulating this, the system can accommodate
    up to 15 players.

    The basic roles for players in the standard rules are:
      "Justice" side: "Loyal_Servant_of_Arthor", "Merlin"
      "Evil" side: "Minion_of_Mordred", "Assassin"

    Additional roles introduced in optional rules are:
      "Justice" side: "Percival"
      "Evil" side: "Mordred", "Oberon", "Morgana"

    In a 10-player game, there are 6 players on the "Justice" side and
    4 players on the "Evil" side. If all optional rules are adopted:
      "Justice" side: 4 "Loyal_Servant_of_Arthor", "Merlin", "Percival"
      "Evil" side: "Assassin," "Mordred," "Oberon," "Morgana"
    and the general role of "Minion_of_Mordred" is not included on the
    "Evil" side.

    AI AVALON standardizes the adoption of all optional roles.

    For games with other player numbers, the ratio of players is as follows:
      9-player game: 6 "Justice" side, 3 "Evil" side
      8-player game: 5 "Justice" side, 3 "Evil" side
      7-player game: 4 "Justice" side, 3 "Evil" side
      6-player game: 4 "Justice" side, 2 "Evil" side
      5-player game: 3 "Justice" side, 2 "Evil" side

(2) Set the maximum number of utterance turns, initial point of interrupt-
    requests, point increments at the end of regular utterance rights, and
    point conversions from one utterance turn for interrupt-request, in the
    <discussion> sub-phase of the <construction> phase.
    In the <discussion> sub-phase of the <assassinate> phase, set the maximum
    number of utterance turns to half of the set value here (rounded down).
    As it is currently unclear what values are appropriate, set them as
    follows for now:
      Maximum turns:    10 turns
      Request points:    5 points
      Increment points:  1 point
      Conversion points: Same as increment points

    Note that regardless of the settings, the maximum value of request
    points that can be held is 127 points, the maximum value of a signed
    8-bit integer, and any excess will be discarded.

(3) Register participating players, assign player numbers in random order
    starting from 0, and randomly allocate roles.

(4) Based on the assigned roles, each player receives one of the following
    messages:
    --------------------------------------------------------------------------
    ===< Justice side >====
    ("role", player_number, "Loyal_Servant_of_Arthor")

    ("role", player_number, "Merlin", evil_player_number, ... )

    ("role", player_number, "Percival", player_number, player_number )

    ===<"Evil" Side>====
    ("role", player_number, "Minion_of_Mordred", evil_player number, ... )

    ("role", player_number, "Assassin", evil_player_number, ... )

    ("role", player_number, "Mordred", evil_player_number, ... )

    ("role", player_number, "Oberon")

    ("role", player_number, "Morgana", evil_player_number, ... )
    --------------------------------------------------------------------------

    However, the range of evil player numbers included in each role message
    is as follows:
    --------------------------------------------------------------------------
    "Loyal_Servant_of_Arthor":
        None

    "Merlin":
        "Minion_of_Mordred", "Assassin", "Oberon", "Morgana"

    "Percival":
        "Merlin", "Morgana"

    "Minion_of_Mordred":
        Other "Minion_of_Mordred", "Mordred", "Assassin", "Morgana"

    "Assassin":
        "Minions of Mordred", "Mordred", "Morgana"

    "Mordred":
        "Minion_of_Mordred", "Assassin", "Morgana"

    "Oberon":
        None

    "Morgana":
        "Minion_of_Mordred", "Mordred", "Assassin"
    --------------------------------------------------------------------------


(5) Set the quest round to 1 and establish the team size for the first quest.
    The team sizes for each quest from the 1st to the 5th quest are as follows:

                  | 1st | 2nd | 3rd | 4th | 5th
      ------------+-----+-----+-----+-----+------
       10-player  |  3  |  4  |  4  |  5  |  5
        9-player  |  3  |  4  |  4  |  5  |  5 
        8-player  |  3  |  4  |  4  |  5  |  5
        7-player  |  2  |  3  |  3  |  4  |  4
        6-player  |  2  |  3  |  4  |  3  |  4
        5-player  |  2  |  3  |  2  |  3  |  3 

    Initialize the number of successful and failed quests to 0, and the number
    of trials to 1. Then, assign the first leader player to player number 1
    and proceed to step (1) of the <construction> phase.


---< construction >-----------------
(1) Each player receives the following message:
       ("construct", quest_round, team_size, trial_count, leader_player_number)

(2) For the purpose of requesting submission of a team proposal as a trigger
    for discussion, the leader player receives the following message:
       ("require", "team", leader_player_number, team_size)

(3) The leader player sends the following message:
       ("team", leader_player_number, strength,
                                        player_number, player_number, ... )
    However, the number of player_numbers must match the team size to be
    formed. It is not necessary for the leader player's number to be included
    in the player_numbers.
    If the enumerated players exceed the team size, the team will be randomly
    selected from the enumerated list. Conversely, if the enumerated players
    are fewer than the team size, the deficiency will be randomly supplemented
    from the unenumerated players.
    The "strength" indicates the level of persuasiveness (persuasive power) or
    conviction associated with the message, represented by a numerical value.
    A lower value indicates less certainty or persuasiveness in stating "how
    it should be," implying weaker influence in trying to persuade (or demand)
    others. Conversely, a higher value suggests a strong conviction, imparting
    significant persuasiveness.

(4) Execute <discussion> sub-phase.

(5) The leader player receives the following message:
       ("require", "team", leader_player_number, team_size)

(6) As the final team composition, the leader player sends the following
    message:
       ("team", leader player number, strength,
                                        player number, player number, ... )
    However, the number of player_numbers must match the team size to be
    formed. It is not necessary for the leader player's number to be included
    in the player_numbers.
    If the enumerated players exceed the team size, the team will be randomly
    selected from the enumerated list. Conversely, if the enumerated players
    are fewer than the team size, the deficiency will be randomly supplemented
    from the unenumerated players.

(7) Each player receives the following message based on the message in step (6):
       ("ID", ID, "team", quest_round, trial_count, leader_player_number,
                                strength, player_number, player_number, ... )

(8) Each player receives the message
       ("require", "vote", player number, team message ID)
    and sends one of the following messages:
       To accept: ("vote", voting_player_number, team_message ID, "accept")
       To deny:   ("vote", voting_player_number, team_message ID, "deny")

(9) Once all players' vote messages are collected, sort all collected vote
    messages in the order of voting players, assign ID numbers, and send them
    to each player.
       ("ID", ID, "vote", voting_player_number,
                                      team_message_ID, "accept" or "deny")

(10) If the majority accepts, the team proposal is approved (a tie results in
     rejection), and transition to the <quest> phase occurs.
     If rejected, increment the trial count.
     If the trial count > 5, it signifies victory for the "Evil" side,
     receiving the message
        ("victory", "evil")
     and ending the game.
     Otherwise, change the leader player to the next player in player number
     order and transition to step (1) of the <construction> phase.


---< quest >-----------------------------
(1) Each player receives the following message:
       ("quest", quest_round, team_message_ID,
                                    player_number, player_number, ... )

(2) Each player designated for the quest participation receives the message
       ("require", "action", player number, required failure votes)
    and responds with the following message:
       ("action", player number, "success" or "failure")
    However, players on the "Justice" side must always vote "success."
    It is also possible to let the system decide by sending
       ("action", player number, "omit").
    In this case, players on the "Justice" side will vote "success," and
    players on the "Evil" side will vote "failure."

(3) Once all action messages from participating players are collected,
    the server determines the success or failure of the quest.
    As a result, each player receives the following message:
       ("ID", ID, "result", "success" or "failure", number_of_failure_votes,
             quest_round, team_message_ID, player_number, player_number, ... )

(4) If the quest result is "success," increase the quest success count by 1.
    If the quest result is "failure," increase the quest failure count by 1.
    If quest success count >= 3, transition to step (1) of the <assassination>
    phase.
    If quest failure count >= 3, it signifies victory for the "Evil" side,
    receiving the message
       ("victory", "evil")
    and ending the game.

(5) Increment the quest round value by 1 and set the team size for the next
    quest.
    Set trial count to 1, advance the leader player by 1, and transition to
    step (1) of the <construction> phase.


---< assassination >---------------------
(1) The "evil" side players (excluding the "Oberon" player) receive the
    following message to initiate and participate in discussions regarding
    assassination:
       ("assassination", player_number, player_number, ... )

    In the rule book of Japanese version of "THE RESISTANCE:AVALON", there
    is no mention of excluding the "Oberon" player in this discussion, but
    considering the situation, this discussion can be assumed to take place
    among those who know they are on the "evil" side, thus excluding the
    "Oberon" player who does not know they are "evil."

(2) Only players participating in the assassination discussion proceed to
    the < discussion > sub-phase.
    However, the maximum number of turns is set to half (rounded down) of
    <construction> phase.

(3) The assassin player receives the following message:
       ("require", "assassinate", assassin_player_number)
    and sends the following message to carry out the assassination:
       ("assassinate", assassin_player_number, target_player_number)
    As a result, each player receives the following message:
       ("ID", ID, "assassinate", assassin_player_number,
                             target_player_number, "success" or "failure")
    If the specified player number is that of the "Merlin" player, it results
    in "success"; otherwise, it results in "failure."
    If the assassination is successful, the "evil" side wins, and
       ("victory", "evil")
    message is received, ending the game.
    If the assassination fails, the "justice" side wins, and
       ("victory", "justice")
    message is received, ending the game.

=============================================================================


-----------------------------------------------------------------------------
2. Utterances in the < discussion > Sub-phase

In AI AVALON, one of the most important subjects of study is the actions
for "persuasion." This involves not only how to effectively express opinions
but also includes the judgment of accepting others' persuasions.

Types of utterances related to persuasive actions are considered as follows:
    <claim>, <request>, <inquiry>, <reason>.

Initially, <agreement> and <refusal> were included as types of utterances, but
these are also a kind of claim, so they are included under the <claim> type.

<inquiry> and <reason> are not direct persuasive actions, but the reasons and
justifications in utterances influence persuasive actions. Therefore, these
utterances, which correspond to requesting or presenting explanations, are
important.

Each type of utterance is named as follows:
    "claim" for <claim>, "request" for <request>,
    "inquiry" for <inquiry>, "reason" for <reason>.
Moreover, when there is no specific utterance (indicating a request to end
the <discussion> sub-phase), the type of utterance is designated as <quit> 
with the type name "quit."

For each utterance, it is crucial to indicate their strength, i.e., "persuasive
power", which signifies how strongly they are being expressed. Additionally,
the strength in <inquiry> refers to how important the information for the
answer to the question is perceived. The strength in <reason> indicates how
strongly the explanation content is believed.

The strength values are initially set as a 5-level scale from 1 to 5.
However, an exception allows assigning a strength of 0 specifically for
<reason>, indicating that there is no specific explanation provided,
i.e., "there is no basis (just intuition) for the target ID."

An image of the strength values is as follows:
   Strength 0: It is not ~
   Strength 1: It cannot be denied that it is ~
   Strength 2: There is a possibility that it is ~
   Strength 3: I think it is ~
   Strength 4: There is a high possibility that it is ~
   Strength 5: I am confident that it is ~

For <reason>, a strength value of 0 is necessary to deny the explanation
target. However, expressing < request > or < inquiry > with a strength of 0
(completely undesirable) is meaningless. In < claim >, it may be necessary
to claim "It is not A," but since the types of claim  components include
both positive and negative types, i.e. "It is A" and "It is not A", it is
sufficient to assert "I am confident that it is not A" (asserting "It is
not A" with a strength of 5).

Players making utterances send messages in the format:
   (type_name, speaking_player_number, strength, content),
and each player receives messages with IDs assigned in the format:
   ("ID", ID, type_name, speaking_player_number, strength, content).


-----------------------------------------------------------------------------
2.1 <quit> mesage

The format of the <quit> message is:
   ("quit", speaking_player_number, strength).
It means that the player desires to quit their utterance (and probably the
discussion as well) with requirement force of the "strength" value.
If a player does not wish to quit their utterance, send:
   ("quit", speaking_player_number, 0).


-----------------------------------------------------------------------------
2.2 <claim> mesage

The format of the <claim> message is:
   ("claim", speaking_player_number, strength, target_ID, content).
The target_ID is specified when there is an action or behavior that serves
as the reason or basis for the claim. If no such action exists beforehand,
target_ID is set to 0.

Similarly, for formats that specify a point in time using an ID, if the time
point is not relevant, the ID should be set to 0.

The relationship between a claim and an explanation, as well as between the
target_ID and the content, can also be referenced in the description of the
<reason> message.

The types of the content in <claim> messages are defined as follows:
=========================================
(a) Assertions regarding agreement or disagreement with a message:
   The components of these assertions include:
     (a1) Agreement with the message
     (a2) Disagreement with the message
   These assertions can also express the degree of belief or doubt in
   a targeted ID using the same format (with strength representing the
   level of belief).

(b) Assertions regarding a player's affiliation:
   The components of these assertions include:
     (b1) Specifying a player as "justice"
     (b2) Specifying a player as "evil"
     (b3) Estimating a player's role

(c) Assertions regarding trust, confidence, or suspicion towards a player:
   Components related to trust in a player's behavior include:
     (c1) Trusting a specific player
     (c2) Distrusting a specific player
   Components related to team composition (whether to include or exclude
   a player) include:
     (c3) Including a specific player to the team
     (c4) Excluding a specific player from the team
   Components related to trusting a player as a leader include:
     (c5) Confidence in the leader (implies continuing with the same leader
          for the next quest)
     (c6) Nonconficence in the leader (implies choosing a new leader for the
          next quest)

(d) Assertions regarding inconsistencies in a player's behavior:
   The components of these assertions include:
     (d1) Two behaviors are consistent
     (d2) Two behaviors are inconsistent

(e) Assertions regarding quest outcomes or game results:
   The components of these assertions include:
     (e1) Quest success
     (e2) Quest failure
     (e3) "Justice" side wins
     (e4) "Justice" side loses

(f) Assertions regarding the number of players affiliated with a certain
    faction within a group:
   The components of these assertions include:
     (f1) Number of "justice" side players in the player set
     (f2) Number of "evil" side players in the player set

(g) Assertions regarding a player's contribution to quests:
   The components of these assertions include:
     (g1) Speculating that a player contributed to the quest (voted "success")
     (g2) Speculating that a player sabotaged the quest (voted "failure")

=========================================

In the structure of assertions, since it may be necessary to combine several
elements, expressions such as logical OR and logical AND are required.
For example:
    "Player 1 and Player 2 are evil and Player 3 is good,
     or Player 1 and Player 2 are good and Player 3 is evil"
  ==> OR(AND(p1==Evil, p2==Evil, p3==Justice),
         AND(p1==Justice, p2==Justice, p3==Evil))

The assertion components deliberately include both negated and non-negated
elements, making explicit negation unnecessary. This decision stems from
the understanding that the degree to which one believes "A" and the degree
to which one believes "not A" are not necessarily constrained to summing
up to a constant value of 1. Therefore, it is necessary to manage "A" and
"not A" separately. Additionally, this approach aims to reduce the complexity
of relationships such as the degree of belief between "NOT(A)" and "not A"
or between "NOT(NOT(A))" and "A" at the protocol level.

Assertions are typically made in response to current situations. However,
there are cases where assertions include a time point, such as "include
a specific player for this quest, but exclude them from the next quest."
As explained later, in the case of <explanation> messages, it is sufficient
to specify a time point with a past message ID since future references
cannot be used as evidence. However, for assertions, future specification
is necessary. The unit of future specification is fundamentally considered
on a "quest" basis. To avoid complications in time management when referencing
messages in later turns, it is advisable to use negative tens values for
quests, such as -10 for the first quest, -20 for the second quest, ..., and
-50 for the fifth quest. If you need to specify a trial, use the ones digit.
For example, the second trial of the third quest would be -32. Furthermore,
to specify the <assassination> phase, use -60. This ensures consistency with
past specification using message IDs. Note that assertions specified with
time point 0 and assertions without specified time points are considered
the same assertion.

The structure of assertions, including logical combinations, is defined as
follows:
   Assertion ::= TemporalAssertion || "omit"
   TemporalAssertion ::= Assertion || AT(time_point, Assertion)
                         || OR(TemporalAssertion, TemporalAssertion [, ...])
                         || AND(TemporalAssertion, TemporalAssertion [, ...])
                         || IF(TemporalAssertion,
                               TemporalAssertion [, TemporalAssertion])
                         || PRESUME(strength, player_number, TemporalAssertion)
   Assertion ::= AssertionElement || OR(Assertion, Assertion [, ...])
                 || AND(Assertion, Assertion [, ...])
                 || IF(Assertion, Assertion [, Assertion])
                 || PRESUME(strength, player_number, Assertion)

Here, PRESUME means "presumed by the player number that the player holds the
TemporalAssertion." The structure of IF is IF(condition, true when condition
is met, false when condition is not met).
However, allowing overly complex explanation structures would be inhumane,
so it may be necessary to limit the depth of hierarchy. For now, there are
no specific limits, but there may be limits introduced in future protocol
updates.

The claim content "omit" is used when not desiring a <claim> in step (2) of
the <discussion> sub-phase, to send an omission claim message as
   ("claim", speaking_player_number, 0, target_ID, "omit").

The format for each claim construction element is as follows:
(a1) ("agree", strength, target_ID)
(a2) ("disagree", strength, target_ID)
(b1) ("justice", strength, player_number)
(b2) ("evil", strength, player_number)
(b3) (role name, strength, player_number)
(c1) ("trust", strength, player_number)
(c2) ("distrust", strength, player_number)
(c3) ("include", strength, player_number)
(c4) ("exclude", strength, player_number)
(c5) ("confidence", strength, player_number)
(c6) ("nonconfidence", strength, player_number)
(d1) ("consistent", strength, target_ID, target_ID)
(d2) ("inconsistent", strength, target_ID, target_ID)
(e1) ("succeed", strength, time_point_ID)
(e2) ("fail", strength, time_point_ID)
(e3) ("win", strength, time_point_ID)
(e4) ("lose", strength, time_point_ID)
(f1) ("servants", strength,
          minimum_number_of_players, maximum_number_of_players,
          player_number, player_number, ...)
(f2) ("minions", strength,
          minimum_number_of_players, maximum_number_of_players,
          player number, player number, ...)
(g1) ("endeavor", strength, player_number, time_point_ID)
(g2) ("obstruct", strength, player_number, time_point_ID)

The image of strength values in the claim construction elements is similar to
strength values in several messages:
  strength 0: It's almost impossible/very unlikely to be ~
  strength 1: It cannot be denied that ~
  strength 2: There is a possibility that ~
  strength 3: I think ~
  strength 4: There is a high possibility that ~
  strength 5: I am convinced that ~
Given that the claim includes both affirmative and negative relations,
strength 0 is interpreted not as complete denial in various messages,
but as a claim that "it's almost 0, but leaves a slight possibility."

We think there are few situations where it is necessary to declare a
completely neutral position, but for example, by combining negations with
an OR using strength 0, as in OR(("agree", 0, ID), ("disagree", 0, ID)),
you can express a situation that allows a slight possibility. Similarly,
it is possible to indicate an acceptable range by adjusting the strength
in an OR combination, as in OR(("agree", 3, ID), ("disagree", 1, ID)).


-----------------------------------------------------------------------------
2.3 <request> message

<request> message is defined as an action that seeks acceptance or rejection
of a claimed message. Therefore, the message format for <request> is based
on the <claim> message as the target ID. For a request for acceptance, the
format is:
   ("request", speaking_player_number, strength, "accept",
                                  target_ID, target_player_number, ... ),
and for a request for denial, the format is:
   ("request", speaking_player_number, strength, "deny",
                                  target_ID, target_player_number, ... ).
Multiple players can be specified as targets at once.

The specified players as targets will receive the message:
   ("require", "claim", target_player_number, target_ID),
which obliges them to express agreement or disagreement through sending
a content type (a) of <claim> message.

In persuasion actions, it is expected that initially, a claim combining
many elements with an AND will be requested for acceptance, and if rejected,
another claim with fewer elements will be made again to seek acceptance.

If not desiring a <request> message in step (3) of the <discussion> sub-phase,
a request omission message is sent as:
   ("request", speaking_player_number, 0, "omit", target_ID).


-----------------------------------------------------------------------------
2.4 <inquiry> message

<inquiry> message is defined as a statement that seeks explanations or
reasons for assertions or actions, or seeks opinions on other players'
assertions or actions.
The format for <inquiry> message is:
   ("inquiry", speaking_player_number, strength,
                    player_number_providing_explanation, target_ID).

If a target ID is provided, the player who made statements or actions
related to that ID can be identified. Therefore, if the explaining player
matches the specified player, it is a "request for explanation" type of
question. If they do not match, it is a "request for opinion on the
player's assertions or actions related to the target ID" type of question.
The player who becomes the subject of the explanation will receive the message:
   ("require", "reason", target_player_number, target_ID),
which obliges them to provide an explanation through a <reason> message.

If not desiring a <inquiry> message in step (1) of the <discussion> sub-phase,
a question omission message is sent as:
   ("inquiry", speaking_player_number, 0, -1, target_ID).
A strength == 0 is the key for question omission, and even if a different
player number providing explanation is specified other than -1, if the
strength is 0, the player number providing explanation is treated as -1.


-----------------------------------------------------------------------------
2.5 <reason> message

<reason> message is defined as a statement that shows the reasons or grounds
for assertions or actions.
The format for <reason> message is:
   ("reason", speaking_player_number, strength, target_ID, explanation_content).
Even when responding to a <inquiry> message, the target_ID is not the ID of
the <inquiry> message but rather the ID of the assertion or action being
explained (which is the same as the target_ID in the <inquiry> message).
The ID of <inquiry> message is used as the target_ID when explaining the
reason for the question act.

In explanations, it is often necessary to specify the point of judgment.
Since judgments are determined as a result of receiving some kind of message,
they are specified by the ID of the message received just before the judgment
point.

The structure of explanation content is:
   ExplanationContent ::= PointedExplanation || "hunch" || "omit"
   PointedExplanation ::= Explanation || AT(point ID, explanation)
                          || OR(PointedExplanation,
                                          PointedExplanation [, ... ])
                          || AND(PointedExplanation,
                                          PointedExplanation [, ... ])
                          || IF(PointedExplanation,
                                   PointedExplanation [, PointedExplanation])
                          || PRESUME(strength, player_number,
                                                   PointedExplanation)
   Explanation ::= Grounds || FACT(target_ID)
                   || OR(Explanation, Explanation [, ... ])
                   || AND(Explanation, Explanation [, ... ])
                   || IF(Explanation, Explanation [, Explanation])
                   || PRESUME(strength, player_number, Explanation)
and the types of grounds are basically the same as the assertion content
in the <claim> message. Therefore, the explanation content in the <reason>
message and the assertion content in the <claim> message, except for FACT
(which explains the fact itself of the target ID) and "hunch" (judgment
based on intuition without specific reasons), are of the same type.

The "omit" as explanation content is used when not desiring an explanation in
step (2) or (3) of the <discussion> sub-phase. The format as an explanation
omission message is:
   ("reason", speaking_player_number, 0, target_ID, "omit")

Explanation (reason) is also a statement of a player's thoughts, so
it's not surprising that explanations and assertions are similar. From
this perspective, an assertion (claim) is an explanation that does not
specifically specify the underlying actions, while an explanation (reason)
is an assertion that explicitly specifies the underlying actions.
In other words, in the <reason> message, it is "because [explanation_content],
[target_ID]", and in the <claim> message, it is "because [target_ID],
[assertion_content]". The difference between explanation and assertion
lies only in direction and the relation of master to servant in terms of
consequences. However, it seems unlikely that the assertion content in
<claim> message is derived as obvious from the target_ID, so there is often
a need in <reason> to supplement why the assertion is made based on how the
target_ID is.


-----------------------------------------------------------------------------
3. Progression of the <discussion> sub-phase

The right of utterance moves among players in order of player numbers.
During the <construction> phase, the first to speak is the leader player,
and, during the <assassination> phase, the player with the smallest number
among evil players excluding "Oberon."
Participation in the <discussion> subphase is limited to players who have
the right of utterance. Specifically, during the <construction> phase, all
players are included, whereas during the <assassination> phase, only evil
players excluding "Oberon" are included.

The completion of the utterance rights cycle for all players through normal
utterance rights progression is referred to as a "utterence turn". In the
<assassination> phase, it is sufficient to simply allocate utterance rights
equally among all target players. However, in the <construction> phase,
utterance should start with the leader player and end with the leader
player's utterance. Therefore, there are differences in the initial setup
of the <discussion> sub-phase between the two phases.

In the <construction> phase, the player who ends the utterance turn becomes
the leader player, and the initial value of the utterance turn number is set
to 0.

In the <assassination> phase, the player who ends the utterance turn is
determined as the player with the highest player number among evil players
excluding "Oberon," and the initial value of the utterance turn number is
set to 1.

This setup means that in the <construction> phase, the utterance starts
with the leader player and ends with the leader player's utterance after
the specified number of utterance turns. In the <assassination> phase,
utterance begins with the player with the lowest player number and ends
with the player with the highest player number after the specified number
of utterance turns.

However, in exceptional cases where a player acquires the utterance right
by consuming the remaining utterance turns during an interruption request,
the player may lose the utterance right before reaching the specified number
of utterance turns. Each player is initially given a number of remaining
utterance turns equal to the specified number of utterance turns. This count
decreases by 1 just before a player's turn moves, whether the player acquire
the utterance right or skip it.

A player with 0 remaining utterance turns is normally skipped during regular
utterance transitions (if remaining the interruption request points, they
can request for utterance by interruption). Due to this skip, the player
also miss the opportunity to accumulate interruption request points.

However, even in such cases, only the leader player in the <construction>
phase is guaranteed to obtain the utterance right through a regular utterance
transition at the end of the <discussion> sub-phase.

Once the setup of the turn-ending player and the initial utterance turn number
is completed, set the initial values for remaining utterance turns for all
players, reset the desired end states, and distribute interrupt request points.
Start the <discussion> sub-phase with granting the utterance right to the
first player to speak.

When the utterance right is confirmed for any player due to their turn or
interrupt request, each player receives a message in the following format:
   ("voice", player_number, desire_to_quit,
             remaining_utterance_turns, interrupt_depth, request_points)
If the player made no utterance during the last turn, the "desire_to_quit"
field is set to 1. It means that the player entered a pending state to
quit the discussion. Otherwise, the field is set to 0. When the player
obtain the utterance right in their turn, the values of "interrupt_depth"
and "request_points" are set to 0.
If the player indicates a desire to gain the utterance right with negative
request points (it means desiring to exchange from their utterance turns
to their request points), the value of "request_points" field is also
negative, but the actual consumed value is its absolute value.


-----------------------------------------------------------------------------
3.1 Actions of the player with the utterance right

Upon obtaining the utterance right, the player performs the following (1) to
(4) actions in sequence, each up to one time maximum:
=============================================================================
(1)(a) The player with the utterance right receives the message:
          ("require", "inquiry", speaking_player_number)
       If desired, the player can send one <inquiry> message.
       To add an explanation to a target_ID at step (1)(b), the player may
       assign themselves as a player obligated to provide an explanation.
       If not wishing to ask a question, send a question omission message.

   (b) The player obligated to provide an explanation due to a question
       receives the message:
          ("require", "reason", target_player_number, target_ID)
       If desired, the player sends one <reason> message.
       (If refuse the explanation, send an explanation omission message.)
       If the target_ID in the <reason> message is different from the
       specified ID in the previous step (2)(a), it is treated as if an
       explanation omission message was sent.

(2)(a) The player with the utterance right receives the message:
          ("require", "claim", speaking_player_number, 0)
       If desired, the player can send one <claim> message.
       If the player does not wish to make a claim, send a claim omission
       message.

   (b) The player with the utterance right receives the message:
          ("require", "reason", speaking_player_number, target_ID)
       If desired, the player sends one <reason> message related to the claim
       message (target_ID) which the player previously sent.
       If the player does not wish to provide an explanation, the player sends
       an explanation omission message.
       If the target_ID in the <reason> message is different from the ID in
       the previous step (2)(a), it is treated as if an explanation omission
       message was sent.

(3)(a) The player with the utterance right receives the message:
          ("require", "request", speaking_player_number)
       If desired, the player can send one <request> message.
       If the player have no request, send a request omission message.

   (b) The player with the utterance right receives the message:
          ("require", "reason", speaking_player_number, target_ID)
       If desired, the player sends one <reason> message related to the
       request message (target_ID) which the player previously sent.
       If the player does not wish to provide an explanation, send an
       explanation omission message.
       If the target_ID in the <reason> message is different from the ID
       in the previous step (3)(a), it is treated as if an explanation
       omission message was sent.

   (c) The player targeted by the request receives the message:
          ("require", "claim", target_player_number, target_ID)
       The player responds with a <claim> message to the request.
       (The player can reject the response with a claim omission message.)
       If the response is not a <claim> message or the target_ID of the
       response is different, it is treated as if a response refusal message
       was sent.

   (d) Additionally, the player targeted by the request receives the message:
          ("require", "reason", target_player_number, target_ID)
       The player can send one <readon> message as the reason for the
       response message sent in step (3)(c).
       (If The player does not wish to provide an explanation, send an
        explanation omission message.)
       If the target_ID in the <reason> message is different from the ID
       in the previous step (3)(c), it is treated as if an explanation
       omission message was sent.

(4) The player with the utterance right receives the message:
       ("require", "quit", speaking_player_number)
    The player sends one <quit> message.
    If the player wants to quit the <discussion> sub-phase, specify a
    strength value of 1 or more in a <quit> message.
    If the player does not wish to quit it, specify a strength value of 0.
    However, if no messages are sent at all sub-step (a) in step (1) to (3)
    (if omission messages are sent for all steps), even if specifying a
    strength of 0 to indicate no desire to quit, the leval of quit state
    will increase and enter a "pending to quit" state.
    When already in the "pending to quit" state and no messages are sent at
    all sub-step (a) in (1) to (3), even if the player sends a <quit> message
    which indicates "does not wish to quit", it will be treated as a <quit>
    message with a strength value of 1 or more which means "wants to quit".
=============================================================================

In steps (3)(c) and (d), there may be multiple players targeted. To avoid the
order of each player's responses affecting the outcome, after all targeted
players' (c) or (d) messages are submitted, they receive all of those messages
at once.

If a player does not wish to speak in sub-step (a) of (1) to (3), the player
must send an omission message. If a player sends an omission message in each
sub-step (a), steps (b) and subsequent steps will not be executed.
Similarly, in steps (1)(b), (2)(b), and (3)(b) to (d), if a player does not
wish to speak, the player must send an omission message.


-----------------------------------------------------------------------------
3.2 Update players' quit state

When the steps (1) to (4) for the player obtaining the utterance right
are completed, the system updates each player's quit state according to
their situations. This process can be considered as part of the process
in step (4).
If a message desiring to quit the discussion (intensity >= 1) is sent in
step (4), the player's quit state will be set to "desire to quit".

When no messages are sent at all during sub-step (a) of steps (1) to (3),
and a "does not wish to quit" message (intensity == 0) is sent in step (4),
the player's quit state set to "pending to quit" even if their quit state
is "does not wish to quit". However, if their quit state is already
"pending to quit", it will be treated as if a "disire to quit" message
(intensity >= 1) has been sent forcefully, and the player's quit state
will be set to "desire to quit".

Otherwise, if at least one message is sent during steps (1) to (3)(a), and
a "does not wish to quit" message (intensity == 0) is sent in step (4), all
players' quit states (not only "pending to quit" but also "desire to quit")
will be reset.

As mentioned later, if all players are in a "desire to quit" state, the
<discussion> sub-phase will conclude. However, when all players except
the player with the utterance right to be in a "desire to quit" state,
and the player with the utterance right switches their quit status to
"desire to quit" after sending messages in their steps, it will be common
that players without the utterance right wish to make a statement, such
as rebutting those messages before finishing the <discussion> sub-phase.
By using "interruption utterance", which is described later, players
can achieve such responses. Additionally, if a player want to continue
the discussion even after processing the "interruption utterance", the
player can clear the state of "finishing the discussion" by sending a
"does not wish to quit" message in step (4) of the "interruption utterance".


-----------------------------------------------------------------------------
3.3 Obtaining the utterance right by requesting "interruption utterance"

Once the steps (1) to (4) (including the update process of the quit state)
where the player with the utterance right has the lead in message sending
concludes, the interruption utterance check described below is conducted
as step (5).

Interruption utterance is an action where a player gains the utterance
right independent of the regular utterance right rotation. The purpose of
it is to avoid impeding persuasion due to progress in arguments that do
not meet one's wishes, or to aim for a stronger persuasive effect by
combining statements before one's claims are refuted.

=============================================================================
(5) Each player receives a message in the format of 
       ("require", "interrupt", player_number, utterance_turn_held,
           request points held, increase_points_by_turn, point_exchange_rate),
    and then sends an interruption utterance request message. The format of
    this message is:
       ("interrupt", requesting_player_number, request_points).
    If a player does not wish to request an interruption utterance, they
    sets the "request_points" to 0. Once all players' interruption utterance
    request messages are gathered, each player receives a message in the
    format of
       ("ID", ID, "interrupt", number_of_players,
           request_points_of_player1, request_point_of_player2, ...)
    containing all players' presented points.
=============================================================================

In a single step (5), only one player who presents the highest request points
can obtain the right to interruption utterance. If there are multiple players
presenting the highest request points, the player with the earliest turn order
in the regular utterance right rotation gains the right to interruption speech.
The player who gains the utterance right consumes the presented request points
and executes steps (1) to (5) similar to the regular utterance right.

The decision on how many points to request for an interruption utterance can
signify information about the player's thoughts, even if they cannot obtain
the right to interruption utterance. In real-life discussions, it is often
possible to infer a player's intentions to some extent from their behavior.
Considering this, we have decided to publicly disclose the number of request
points presented by all players here.

In a single step (5), only one player can make a interruption utterance, but
it's important to note that processing of step (5) is nested. This means that
in step (5) of the flow of the interruption utterance, another player can
obtain the right of interruption utterance before completing the flow of
the interruption. By means of this, multiple players can gain the utterance
rights before the normal transfer of utterance right between players.

A player with the utterance right may request an interruption utterance
during their own step (5). If successful, this is equivalent to gaining
an utterance right multiple times in succession.

Where N is initial distribution of interruption request points set up in the
<setup> phase, each player is allocated N points as their request points at
the start of each <discussion> sub-phase. At each distribution, the points
resets to N points, and any remaining points from previous <discussion>
sub-phases cannot be carried over.

When making an interruption request, any number of points within the available
request point range can be offered. If a value outside this range is offered,
it is treated as offering 0 points (no interruption request).

If a player lacks the desired request points, they may offset the deficit
by consuming their allotted utterance turns. One utterance turn is converted
into the request points by the conversion ratio set during the <setup> phase.
To indicate a desire to consume utterance turns, the offering is represented
as a negative value; -(points to use). If the points offered exceed the
available request points plus the player's remaining utterance turns
multiplied by the conversion ratio, the offering is invalid and treated
as 0 points (no interruption request).

If an interruption request is successful, the offered points, including
the minimum required utterance turns for conversion, are forfeited. If
unsuccessful, neither request points nor utterance turns are consumed.
Additionally, if the conversion points of an utterance turn is two or
more, it's possible for the interruption request points to appear to
increase due to the remainder from the consumption after the utterance
turn conversion.

Interruption request points increase by the increment point number set
at <setup> phase, at the end of the player's regular utterance right.
However, the maximum limit for interruption request points that can be
held is 127 points, which is the maximum value for a signed 8-bit integer.
Any excess points are discarded. As the player's utterance steps obtained
by successful interruction are not their own utterance turn, there is
no increase in request points. Furthermore, since the timing of points
increase is after step (5), it's not possible to request an interruption
using points acquired during one's own turn.

The utterance right transfers to the player who have not set their quit
state to "desire to quit" and whose rotating order of utterance right is
earliest. Therefore, players with the "desire to quit" state is skipped
the regular transfer of the utterance right, and their interruption request
points do not increase. However, even if the player's quit state is
"desire to quit", requesting an interruption utterance by usiing remaining
request points is still possible. If multiple players offer the same number
of request points, the player in the "does not wish to quit" state has
highest priority, in the "pending to quit" has next, and in the "desire
to quit" has last.

Note that players with the "desire to quit" status can reset the status
themselves by sending a "does not wish to quit" message in step (4) when
they acquire the utterance right by interruption request.


-----------------------------------------------------------------------------
3.4 Termination of an utterance right

If there are no players sending an interruption request or if the nested
process of the utterance right given by an interruption request has concluded,
Step (5) will terminate. Once Step (5) has concluded, the termination process
for the current utterance right will be executed.

If all players' quit states are set to "desire to quit", the <discussion>
sub-phase will conclude, and each player will receive the following message:
   ("finish", quest_round, trial_count, leader_player_number).

If each player's quit state does not meet the conditions for terminating the
<discussion> sub-phase, and the terminated utterance right is the one obtaind
by the interruption request, the nested structure of interruption utterances
is exited by one level.

If the terminated utterance right is a regular utterance right, first check
whether the current player is the ending player of an utterance turn. If they
is, increase the utterance turn number by 1. If the utterance turn number
exceeds the maximum utterance turn count, the <discussion> sub-phase will
conclude, and each player will receive a message of the form:
   ("finish", quest_round, trial_count, leader_player_number).

If the <discussion> sub-phase does not conclude based on the condition of the
utterance turn count, after increasing the interruption request points of the
current player by the specified increment amount, the utterance right will
transfer to the player whose utterance order is earliest among players who
have not set their quit state to "desire to quit".

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