source: src/main/java/agents/anac/y2017/simpleagent/SimpleAgent.java@ 1

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

Initial import : Genius 9.0.0

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