from abc import ABC, abstractmethod from typing import TypeVar, Generic, List from geniusweb.connection.Connectable import Connectable from geniusweb.party.Capabilities import Capabilities from geniusweb.inform.Inform import Inform from geniusweb.actions.Action import Action class Party (Connectable[Inform, Action] ): ''' This is a interface definition for java-based party implementations that are to be run on the PartiesServer. To implement a party to run on the PartiesServer, you must implement this and also have a 0-arg constructor. Also we strongly recommend not to use any static code blocks or do anything serious in the constructor. Instances of your class may also be created only to call the getCapabilities function.
Outgoing Action objects (eg "Offer") are sent using the send() command. Most parties extend {@link DefaultParty} to handle these connection details.
Technical details: normally a Party will be spawned inside a PartiesFactory, and incoming/outgoing calls are routed through a websocket there. But in testing the Connectable is often mocked. ''' @abstractmethod def getCapabilities(self) -> Capabilities: ''' @return the capabilities of this party. ''' @abstractmethod def getDescription(self) -> str: ''' @return some useful short description, eg "tit-for-tat with bayesian opponent modeling". ''' @abstractmethod def terminate(self): ''' When this is called, the party should free up its resources and terminate its threads. This call may come in at any time, eg when a negotiation is aborted. '''