source: src/main/java/negotiator/parties/AcceptingNegotiationParty.java@ 61

Last change on this file since 61 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 1.6 KB
Line 
1package negotiator.parties;
2
3import java.util.List;
4
5import genius.core.AgentID;
6import genius.core.actions.Accept;
7import genius.core.actions.Action;
8import genius.core.actions.ActionWithBid;
9import genius.core.actions.Offer;
10import genius.core.parties.AbstractNegotiationParty;
11
12/**
13 * Most basic voting agent implementation I could think of: this agent accepts
14 * any offer.
15 * <p/>
16 * The class was created as part of a series of agents used to understand the
17 * api better
18 *
19 * @author David Festen
20 */
21public class AcceptingNegotiationParty extends AbstractNegotiationParty {
22
23 /**
24 * If offer was proposed: Accept offer, otherwise: Propose random offer
25 *
26 * @param possibleActions
27 * List of all actions possible.
28 * @return Accept or Offer action
29 */
30 @Override
31 public Action chooseAction(final List<Class<? extends Action>> possibleActions) {
32
33 System.out.println("getNumberOfParties() = " + getNumberOfParties());
34
35 if (possibleActions.contains(Accept.class)) {
36 return new Accept(getPartyId(), ((ActionWithBid) getLastReceivedAction()).getBid());
37 } else {
38 return new Offer(getPartyId(), generateRandomBid());
39 }
40 }
41
42 /**
43 * We ignore any messages received.
44 *
45 * @param sender
46 * The initiator of the action
47 * @param arguments
48 * The action performed
49 */
50 @Override
51 public void receiveMessage(final AgentID sender, final Action arguments) {
52 super.receiveMessage(sender, arguments);
53 }
54
55 @Override
56 public String getDescription() {
57 return "Always Accepting Party";
58 }
59
60}
Note: See TracBrowser for help on using the repository browser.