1 | package negotiator.parties;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 |
|
---|
5 | import genius.core.AgentID;
|
---|
6 | import genius.core.actions.Accept;
|
---|
7 | import genius.core.actions.Action;
|
---|
8 | import genius.core.actions.ActionWithBid;
|
---|
9 | import genius.core.actions.Offer;
|
---|
10 | import 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 | */
|
---|
21 | public 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 | }
|
---|