diplomacy.daide.responses

DAIDE Responses - Contains a list of responses sent by the server to the client

class diplomacy.daide.responses.DaideResponse(**kwargs)[source]

Bases: diplomacy.communication.responses._AbstractResponse

Represents a DAIDE response.

__init__(**kwargs)[source]

Constructor

class diplomacy.daide.responses.MapNameResponse(map_name, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a MAP DAIDE response. Sends the name of the current map to the client.

Syntax:

MAP ('name')
__init__(map_name, **kwargs)[source]

Builds the response :param map_name: String. The name of the current map.

class diplomacy.daide.responses.MapDefinitionResponse(map_name, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a MDF DAIDE response. Sends configuration of a map to a client

Syntax:

MDF (powers) (provinces) (adjacencies)

powers syntax:

power power ...

power syntax:

AUS                     # Austria
ENG                     # England
FRA                     # France
GER                     # Germany
ITA                     # Italy
RUS                     # Russia
TUR                     # Turkey

provinces syntax:

(supply_centres) (non_supply_centres)

supply_centres syntax:

(power centre centre ...) (power centre centre ...) ...

supply_centres power syntax:

(power power ...)       # This is currently not supported
AUS                     # Austria
ENG                     # England
FRA                     # France
GER                     # Germany
ITA                     # Italy
RUS                     # Russia
TUR                     # Turkey
UNO                     # Unknown power

non_supply_centres syntax:

province province ...   # List of provinces

adjacencies syntax:

(prov_adjacencies) (prov_adjacencies) ...

prov_adjacencies syntax:

province (unit_type adjacent_prov adjacent_prov ...) (unit_type adjacent_prov adjacent_prov ...) ...

unit_type syntax:

AMY                     # List of provinces an army can move to
FLT                     # List of provinces a fleet can move to
(FLT coast)             # List of provinces a fleet can move to from the given coast

adjacent_prov syntax:

province                # A province which can be moved to
(province coast)        # A coast of a province that can be moved to
__init__(map_name, **kwargs)[source]

Builds the response

Parameters:map_name – The name of the map
class diplomacy.daide.responses.HelloResponse(power_name, passcode, level, deadline, rules, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a HLO DAIDE response. Sends the power to be played by the client with the passcode to rejoin the game and the details of the game.

Syntax:

HLO (power) (passcode) (variant) (variant) ...

Variant syntax:

LVL n           # Level of the syntax accepted
MTL seconds     # Movement time limit
RTL seconds     # Retreat time limit
BTL seconds     # Build time limit
DSD             # Disables the time limit when a client disconects
AOA             # Any orders accepted

LVL 10:

Variant syntax:

PDA             # Accept partial draws
NPR             # No press during retreat phases
NPB             # No press during build phases
PTL seconds     # Press time limit
__init__(power_name, passcode, level, deadline, rules, **kwargs)[source]

Builds the response

Parameters:
  • power_name – The name of the power being played.
  • passcode – Integer. A passcode to rejoin the game.
  • level – Integer. The daide syntax level of the game
  • deadline – Integer. The number of seconds per turn (0 to disable)
  • rules – The list of game rules.
class diplomacy.daide.responses.SupplyCenterResponse(powers_centers, map_name, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a SCO DAIDE response. Sends the current supply centre ownership.

Syntax:

SCO (power centre centre ...) (power centre centre ...) ...
__init__(powers_centers, map_name, **kwargs)[source]

Builds the response

Parameters:
  • powers_centers – A dict of {power_name: centers} objects
  • map_name – The name of the map
class diplomacy.daide.responses.CurrentPositionResponse(phase_name, powers_units, powers_retreats, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a NOW DAIDE response. Sends the current turn, and the current unit positions.

Syntax:

NOW (turn) (unit) (unit) ...

Unit syntax:

power unit_type province
power unit_type province MRT (province province ...)
__init__(phase_name, powers_units, powers_retreats, **kwargs)[source]

Builds the response

Parameters:
  • phase_name – The name of the current phase (e.g. ‘S1901M’)
  • powers – A list of diplomacy.engine.power.Power objects
class diplomacy.daide.responses.ThanksResponse(order_bytes, results, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a THX DAIDE response. Sends the result of an order after submission.

Syntax:

THX (order) (note)

Note syntax:

MBV     # Order is OK.
FAR     # Not adjacent.
NSP     # No such province
NSU     # No such unit
NAS     # Not at sea (for a convoying fleet)
NSF     # No such fleet (in VIA section of CTO or the unit performing a CVY)
NSA     # No such army (for unit being ordered to CTO or for unit being CVYed)
NYU     # Not your unit
NRN     # No retreat needed for this unit
NVR     # Not a valid retreat space
YSC     # Not your supply centre
ESC     # Not an empty supply centre
HSC     # Not a home supply centre
NSC     # Not a supply centre
CST     # No coast specified for fleet build in StP, or an attempt
          to build a fleet inland, or an army at sea.
NMB     # No more builds allowed
NMR     # No more removals allowed
NRS     # Not the right season
__init__(order_bytes, results, **kwargs)[source]

Builds the response

Parameters:
  • order_bytes – The bytes received for the order
  • results – An array containing the error codes.
class diplomacy.daide.responses.MissingOrdersResponse(phase_name, power, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a MIS DAIDE response. Sends the list of unit for which an order is missing or indication about required disbands or builds.

Syntax:

MIS (unit) (unit) ...
MIS (unit MRT (province province ...)) (unit MRT (province province ...)) ...
MIS (number)
__init__(phase_name, power, **kwargs)[source]

Builds the response

Parameters:
  • phase_name – The name of the current phase (e.g. ‘S1901M’)
  • power (diplomacy.engine.power.Power) – The power to check for missing orders
class diplomacy.daide.responses.OrderResultResponse(phase_name, order_bytes, results, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a ORD DAIDE response. Sends the result of an order after the turn has been processed.

Syntax:

ORD (turn) (order) (result)
ORD (turn) (order) (result RET)

Result syntax:

SUC         # Order succeeded (can apply to any order).
BNC         # Move bounced (only for MTO, CTO or RTO orders).
CUT         # Support cut (only for SUP orders).
DSR         # Move via convoy failed due to dislodged convoying fleet (only for CTO orders).
NSO         # No such order (only for SUP, CVY or CTO orders).
RET         # Unit was dislodged and must retreat.
__init__(phase_name, order_bytes, results, **kwargs)[source]

Builds the response

Parameters:
  • phase_name – The name of the current phase (e.g. ‘S1901M’)
  • order_bytes – The bytes received for the order
  • results – An array containing the error codes.
class diplomacy.daide.responses.TimeToDeadlineResponse(seconds, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a TME DAIDE response. Sends the time to the next deadline.

Syntax:

TME (seconds)
__init__(seconds, **kwargs)[source]

Builds the response

Parameters:seconds – Integer. The number of seconds before deadline
class diplomacy.daide.responses.AcceptResponse(request_bytes, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a YES DAIDE request.

Syntax:

YES (TME (seconds))                                 # Accepts to set the time when a
                                                      TME message will be sent
YES (NOT (TME))                                     # Accepts to cancel all requested time messages
YES (NOT (TME (seconds)))                           # Accepts to cancel a specific requested time message
YES (GOF)                                           # Accepts to wait until the deadline before processing
                                                      the orders for the turn
YES (NOT (GOF))                                     # Accepts to cancel to wait until the deadline before
                                                      processing the orders for the turn
YES (DRW)                                           # Accepts to draw
YES (NOT (DRW))                                     # Accepts to cancel a draw request

LVL 10:

YES (DRW (power power ...))                         # Accepts a partial draw
YES (NOT (DRW (power power ...)))                   # Accepts to cancel a partial draw request
                                                      (? not mentinned in the DAIDE doc)
YES (SND (power power ...) (press_message))         # Accepts a press message
YES (SND (turn) (power power ...) (press_message))  # Accepts a press message
__init__(request_bytes, **kwargs)[source]

Builds the response

Parameters:request_bytes – The bytes received for the request
class diplomacy.daide.responses.RejectResponse(request_bytes, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a REJ DAIDE request.

Syntax:

REJ (NME ('name') ('version'))                      # Rejects a client in the game
REJ (IAM (power) (passcode))                        # Rejects a client to rejoin the game
REJ (HLO)                                           # Rejects to send the HLO message
REJ (HST (turn))                                    # Rejects to send a copy of a previous
                                                      ORD, SCO and NOW messages
REJ (SUB (order) (order))                           # Rejects a submition of orders
REJ (SUB (turn) (order) (order))                    # Rejects a submition of orders
REJ (NOT (SUB (order)))                             # Rejects a cancellation of a submitted order
REJ (MIS)                                           # Rejects to send a copy of the current MIS message
REJ (GOF)                                           # Rejects to wait until the deadline before processing
                                                      the orders for the turn
REJ (NOT (GOF))                                     # Rejects to cancel to wait until the deadline before
                                                      processing the orders for the turn
REJ (TME (seconds))                                 # Rejects to set the time when a
                                                      TME message will be sent
REJ (NOT (TME))                                     # Rejects to cancel all requested time messages
REJ (NOT (TME (seconds)))                           # Rejects to cancel a specific requested time message
REJ (ADM ('name') ('message')                       # Rejects the admin message
REJ (DRW)                                           # Rejects to draw
REJ (NOT (DRW))                                     # Rejects to cancel a draw request

LVL 10:

REJ (DRW (power power ...))                         # Rejects to partially draw
REJ (NOT (DRW (power power ...)))                   # Rejects to cancel a partial draw request
REJ (SND (power power ...) (press_message))         # Rejects a press message
REJ (SND (turn) (power power ...) (press_message))  # Rejects a press message
__init__(request_bytes, **kwargs)[source]

Builds the response

Parameters:request_bytes – The bytes received for the request
class diplomacy.daide.responses.NotResponse(response_bytes, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a NOT DAIDE response.

Syntax:

NOT (CCD (power))
__init__(response_bytes, **kwargs)[source]

Builds the response :param response_bytes: The bytes received for the request

class diplomacy.daide.responses.PowerInCivilDisorderResponse(power_name, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a CCD DAIDE response. Sends the name of the power in civil disorder.

Syntax:

CCD (power)
__init__(power_name, **kwargs)[source]

Builds the response

Parameters:power_name – The name of the power being played.
class diplomacy.daide.responses.PowerIsEliminatedResponse(power_name, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a OUT DAIDE response. Sends the name of the power eliminated.

Syntax:

OUT (power)
__init__(power_name, **kwargs)[source]

Builds the response

Parameters:power_name – The name of the power being played.
class diplomacy.daide.responses.ParenthesisErrorResponse(request_bytes, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a PRN DAIDE response.

Syntax:

PRN (message)
__init__(request_bytes, **kwargs)[source]

Builds the response

Parameters:request_bytes – The bytes received for the request
class diplomacy.daide.responses.SyntaxErrorResponse(request_bytes, error_index, **kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents a HUH DAIDE response.

Syntax:

HUH (message)
__init__(request_bytes, error_index, **kwargs)[source]

Builds the response

Parameters:
  • request_bytes – The bytes received for the request
  • error_index – The index of the faulty token
class diplomacy.daide.responses.TurnOffResponse(**kwargs)[source]

Bases: diplomacy.daide.responses.DaideResponse

Represents an OFF DAIDE response. Requests a client to exit

Syntax:

OFF
__init__(**kwargs)[source]

Builds the response

diplomacy.daide.responses.MAP

alias of diplomacy.daide.responses.MapNameResponse

diplomacy.daide.responses.MDF

alias of diplomacy.daide.responses.MapDefinitionResponse

diplomacy.daide.responses.HLO

alias of diplomacy.daide.responses.HelloResponse

diplomacy.daide.responses.SCO

alias of diplomacy.daide.responses.SupplyCenterResponse

diplomacy.daide.responses.NOW

alias of diplomacy.daide.responses.CurrentPositionResponse

diplomacy.daide.responses.THX

alias of diplomacy.daide.responses.ThanksResponse

diplomacy.daide.responses.MIS

alias of diplomacy.daide.responses.MissingOrdersResponse

diplomacy.daide.responses.ORD

alias of diplomacy.daide.responses.OrderResultResponse

diplomacy.daide.responses.TME

alias of diplomacy.daide.responses.TimeToDeadlineResponse

diplomacy.daide.responses.YES

alias of diplomacy.daide.responses.AcceptResponse

diplomacy.daide.responses.REJ

alias of diplomacy.daide.responses.RejectResponse

diplomacy.daide.responses.NOT

alias of diplomacy.daide.responses.NotResponse

diplomacy.daide.responses.CCD

alias of diplomacy.daide.responses.PowerInCivilDisorderResponse

diplomacy.daide.responses.OUT

alias of diplomacy.daide.responses.PowerIsEliminatedResponse

diplomacy.daide.responses.OFF

alias of diplomacy.daide.responses.TurnOffResponse

diplomacy.daide.responses.PRN

alias of diplomacy.daide.responses.ParenthesisErrorResponse

diplomacy.daide.responses.HUH

alias of diplomacy.daide.responses.SyntaxErrorResponse