|
261 | 261 | "This is telling us that there is one (and only one) required abstract method that we need to override called `propose()`. This is the signature of this method:\n", |
262 | 262 | "\n", |
263 | 263 | "```python\n", |
264 | | - "def proposed(self, state: SAOState) -> Outcome:\n", |
| 264 | + "def propose(self, state: SAOState, dest: str | None = None) -> Outcome:\n", |
265 | 265 | " ...\n", |
266 | 266 | "```\n", |
267 | 267 | "\n", |
268 | | - "It receives the negotiation `state` which has all information available to the negotiator about the current state of the negotiation and generates an outcome to *offer* to the opponent. That is it. Moreover, we should know that the negotiator always have access to a `NegotiatorMechanismInterface` object that gives it unchanging information about the negotiation (for example the number of allowed rounds, any real-time limits on the negotiation, the number of partners, etc). This interface is accessible through the `nmi` member of the negotiator. With this knowledge, we can build our first negotiator which will simply offer randomly. " |
| 268 | + "It receives the negotiation `state` which has all information available to the negotiator about the current state of the negotiation and generates an outcome to *offer* to the opponent. The second parameter (which MUST be optional) is the destination of the offer. That is it. Moreover, we should know that the negotiator always have access to a `NegotiatorMechanismInterface` object that gives it unchanging information about the negotiation (for example the number of allowed rounds, any real-time limits on the negotiation, the number of partners, etc). This interface is accessible through the `nmi` member of the negotiator. With this knowledge, we can build our first negotiator which will simply offer randomly. " |
269 | 269 | ] |
270 | 270 | }, |
271 | 271 | { |
|
606 | 606 | }, |
607 | 607 | { |
608 | 608 | "cell_type": "code", |
609 | | - "execution_count": 11, |
| 609 | + "execution_count": 25, |
610 | 610 | "id": "3b66d1c6", |
611 | 611 | "metadata": { |
612 | 612 | "papermill": { |
|
621 | 621 | "outputs": [], |
622 | 622 | "source": [ |
623 | 623 | "class BetterRandomNegotiator(RandomNegotiator):\n", |
624 | | - " def respond(self, state, source: str = \"\"):\n", |
| 624 | + " def respond(self, state, source: str | None = None):\n", |
625 | 625 | " offer = state.current_offer\n", |
626 | 626 | " if self.ufun(offer) > 0.9:\n", |
627 | 627 | " return ResponseType.ACCEPT_OFFER\n", |
|
905 | 905 | " super().__init__(*args, **kwargs)\n", |
906 | 906 | " self._th = acceptance_threshold\n", |
907 | 907 | "\n", |
908 | | - " def respond(self, state, offer, nid: str):\n", |
| 908 | + " def respond(self, state, source: str | None = None):\n", |
| 909 | + " offer = state.current_offer\n", |
909 | 910 | " if self.ufun(offer) > self._th:\n", |
910 | 911 | " return ResponseType.ACCEPT_OFFER\n", |
911 | 912 | " return ResponseType.REJECT_OFFER" |
|
985 | 986 | " # MUST call parent to avoid being called again for no reason\n", |
986 | 987 | " super().on_preferences_changed(changes)\n", |
987 | 988 | "\n", |
988 | | - " def respond(self, state, source: str):\n", |
| 989 | + " def respond(self, state, source: str | None = None):\n", |
989 | 990 | " offer = state.current_offer\n", |
990 | 991 | " if offer is None:\n", |
991 | 992 | " return ResponseType.REJECT_OFFER\n", |
|
0 commit comments