source: src/main/java/agents/anac/y2018/agent33/etc/NegoHistory.java

Last change on this file was 343, checked in by Tim Baarslag, 4 years ago

Fixed all errors in all 2018 agents

File size: 2.8 KB
Line 
1package agents.anac.y2018.agent33.etc;
2
3import java.util.HashMap;
4import java.util.Map;
5
6import genius.core.list.Tuple;
7import genius.core.parties.NegotiationInfo;
8import genius.core.persistent.PersistentDataContainer;
9import genius.core.persistent.PersistentDataType;
10import genius.core.persistent.StandardInfo;
11import genius.core.persistent.StandardInfoList;
12
13
14
15public class NegoHistory {
16 private NegotiationInfo info;
17 private StandardInfoList history;
18 private boolean historyAnalyzed = false;
19
20 private boolean isPrinting = false; // デバッグ用
21 private boolean isPrinting_History = false;
22
23 /**
24 * @param info
25 * @param isPrinting
26 * @param pData public PersistentDataContainer getData(): persistent data
27 */
28 public NegoHistory(NegotiationInfo info, boolean isPrinting, PersistentDataContainer pData) {
29 this.info = info;
30 this.isPrinting = isPrinting;
31
32 // PersistentDataType が Standard の場合
33 if (pData.getPersistentDataType() == PersistentDataType.STANDARD) {
34 history = (StandardInfoList) pData.get();
35
36 if (!history.isEmpty()) {
37 // example of using the history. Compute for each party the maximum
38 // utility of the bids in last session.
39 Map<String, Double> maxutils = new HashMap<String, Double>();
40 StandardInfo lastinfo = history.get(history.size() - 1);
41 for (Tuple<String, Double> offered : lastinfo.getUtilities()) {
42 String party = offered.get1();
43 Double util = offered.get2();
44 maxutils.put(party, maxutils.containsKey(party) ? Math.max(maxutils.get(party), util) : util);
45 }
46 System.out.println(maxutils); // notice tournament suppresses all
47 // output.
48 }
49 }
50
51 if(this.isPrinting){
52 System.out.println("[isPrinting] NegoHistory: success");
53 }
54
55 }
56
57 public void analyzeHistory() {
58 historyAnalyzed = true;
59
60 // from recent to older history records
61 for (int h = history.size() - 1; h >= 0; h--) {
62
63 System.out.println("History index: " + h);
64
65 StandardInfo lastinfo = history.get(h);
66
67 int counter = 0;
68 for (Tuple<String, Double> offered : lastinfo.getUtilities()) {
69 counter++;
70
71 String party = offered.get1(); // get partyID -> example: ConcederParty@15
72 Double util = offered.get2(); // get the offer utility
73
74 System.out.println("PartyID: " + party + " utilityForMe: " + util);
75 System.out.println();
76 //just print first 3 bids, not the whole history
77 if (counter == 3)
78 break;
79 }
80
81 System.out.println("\n");
82
83 }
84
85 }
86}
Note: See TracBrowser for help on using the repository browser.