1 | package agents.anac.y2017.simpleagent;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 |
|
---|
5 | import genius.core.AgentID;
|
---|
6 | import genius.core.Bid;
|
---|
7 | import genius.core.actions.Accept;
|
---|
8 | import genius.core.actions.Action;
|
---|
9 | import genius.core.actions.Offer;
|
---|
10 | import genius.core.parties.AbstractNegotiationParty;
|
---|
11 | import genius.core.parties.NegotiationInfo;
|
---|
12 | import genius.core.persistent.StandardInfoList;
|
---|
13 |
|
---|
14 | public class SimpleAgent extends AbstractNegotiationParty {
|
---|
15 |
|
---|
16 | private Bid currentBid;
|
---|
17 | private Predictor predictor;
|
---|
18 |
|
---|
19 | @Override
|
---|
20 | public void init(NegotiationInfo info) {
|
---|
21 | super.init(info);
|
---|
22 | predictor = new Predictor(getUtilitySpace(), timeline);
|
---|
23 | super.init(info);
|
---|
24 | StandardInfoList history = (StandardInfoList) getData().get();
|
---|
25 | if (history != null && !history.isEmpty()) {
|
---|
26 | System.out.println(
|
---|
27 | "Hist" + history.get(0).getUtilities().get(0).get1());
|
---|
28 | predictor.setHistoryAndUpdateThreshold(history);
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | @Override
|
---|
33 | public Action chooseAction(List<Class<? extends Action>> validActions) {
|
---|
34 | try {
|
---|
35 | Action action = predictor.generateAction(validActions, currentBid,
|
---|
36 | getPartyId());
|
---|
37 | return action;
|
---|
38 |
|
---|
39 | } catch (Exception e) {
|
---|
40 | e.printStackTrace();
|
---|
41 | return new Accept(getPartyId(), currentBid); // Not sure what to put
|
---|
42 | // here... Don't
|
---|
43 | // know what
|
---|
44 | // error I would be hitting.
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|
48 | @Override
|
---|
49 | public String getDescription() {
|
---|
50 | return "ANAC2017";
|
---|
51 | }
|
---|
52 |
|
---|
53 | @Override
|
---|
54 | public void receiveMessage(AgentID sender, Action action) {
|
---|
55 | super.receiveMessage(sender, action);
|
---|
56 |
|
---|
57 | if (action instanceof Offer) {
|
---|
58 | predictor.storeAgentOffer((Offer) action);
|
---|
59 | currentBid = ((Offer) action).getBid();
|
---|
60 | }
|
---|
61 | }
|
---|
62 | } |
---|