source: geniuswebcore/geniusweb/party/Party.py@ 67

Last change on this file since 67 was 67, checked in by Bart Vastenhouw, 3 years ago

Added SAOP and simplerunner to GeniusWebPython. Several minor fixes.

File size: 2.2 KB
Line 
1from abc import ABC, abstractmethod
2from typing import TypeVar, Generic, List
3from geniusweb.connection.Connectable import Connectable
4from geniusweb.party.Capabilities import Capabilities
5from geniusweb.inform.Inform import Inform
6from geniusweb.actions.Action import Action
7
8
9class Party (Connectable[Inform, Action] ):
10 '''
11 This is a interface definition for java-based party implementations that are
12 to be run on the PartiesServer.
13
14 To implement a party to run on the PartiesServer, you must implement this and
15 also have a 0-arg constructor. Also we strongly recommend not to use any
16 static code blocks or do anything serious in the constructor. Instances of
17 your class may also be created only to call the getCapabilities function.
18
19 <h2>Short outline</h2> After the party is created (empty constructor) it is
20 first connected through a call to connect (from the {@link Connectable}
21 interface). The party can subscribe to receive {@link Inform} objects using
22 {@link ConnectionEnd#addListener(tudelft.utilities.listener.Listener)}. The
23 party can also send its actions using {@link ConnectionEnd#send(Object)}.
24
25 The {@link ConnectionEnd} allows the party to receive Inform objects and send
26 action objects.
27
28 Incoming Inform objects (eg "Settings" containing the profile, and
29 "yourturn") are notified to the party throught he notifyChange() call to the
30 party.
31 <p>
32 Outgoing Action objects (eg "Offer") are sent using the send() command.
33
34 Most parties extend {@link DefaultParty} to handle these connection details.
35 <p>
36 Technical details: normally a Party will be spawned inside a PartiesFactory,
37 and incoming/outgoing calls are routed through a websocket there. But in
38 testing the Connectable is often mocked.
39 '''
40
41 @abstractmethod
42 def getCapabilities(self) -> Capabilities:
43 '''
44 @return the capabilities of this party.
45 '''
46
47 @abstractmethod
48 def getDescription(self) -> str:
49 '''
50 @return some useful short description, eg "tit-for-tat with bayesian
51 opponent modeling".
52 '''
53
54 @abstractmethod
55 def terminate(self):
56 '''
57 When this is called, the party should free up its resources and terminate
58 its threads. This call may come in at any time, eg when a negotiation is
59 aborted.
60 '''
61
Note: See TracBrowser for help on using the repository browser.