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

Last change on this file was 160, checked in by Tim Baarslag, 6 years ago

Cleanup of agent names to improve the readability of the party repository

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 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}
Note: See TracBrowser for help on using the repository browser.