source: src/main/java/agents/anac/y2011/Gahboninho/Gahboninho.java@ 316

Last change on this file since 316 was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 4.4 KB
Line 
1package agents.anac.y2011.Gahboninho;
2
3import genius.core.Agent;
4import genius.core.Bid;
5import genius.core.actions.Accept;
6import genius.core.actions.Action;
7import genius.core.actions.Offer;
8import genius.core.utility.AdditiveUtilitySpace;
9
10// The agent is similar to a bully.
11// on the first few bids it steadily goes down to 0.9 of utility to make sure that if the opponent is trying to
12// profile me, he could do it more easily.
13// after that, it goes totally selfish and almost giving up no points.
14// more over, the nicer the opponent is (Noise serves as a "niceness" estimation) the more selfish this agent gets.
15// only at the last few seconds the agent panics and gives up his utility.
16// I believe this is an excellent strategy, but sadly we did not have enough manpower and time
17// to calibrate it and make it shine :(
18// an opponent-model would have helped us improving the result on panic stages, and the noise(niceness) calculation is too rough.
19
20public class Gahboninho extends Agent {
21 final int PlayerCount = 8; // if player count is 10, then we
22 // may give 10 points to opponent in order to give 1 point to ourselves
23
24 boolean WereBidsFiltered = false;
25 OpponnentModel OM;
26 IssueManager IM;
27
28 @Override
29 public void init() {
30 super.init();
31 OM = new OpponnentModel((AdditiveUtilitySpace) utilitySpace, timeline);
32 IM = new IssueManager((AdditiveUtilitySpace) utilitySpace, timeline,
33 OM);
34 IM.Noise *= IM.GetDiscountFactor();
35 }
36
37 @Override
38 public String getName() {
39 return "Gahboninho V3";
40 }
41
42 Bid previousBid = null;
43 Bid OpponentBid = null;
44
45 @Override
46 public void ReceiveMessage(Action opponentAction) {
47 this.previousBid = this.OpponentBid;
48
49 if (opponentAction instanceof Offer) {
50 OpponentBid = ((Offer) opponentAction).getBid();
51 if (this.previousBid != null) {
52 try {
53 this.IM.ProcessOpponentBid(this.OpponentBid);
54 OM.UpdateImportance(OpponentBid);
55 } catch (Exception e) {
56 // Too bad
57 }
58 } else {
59 try {
60 this.IM.learnBids(this.OpponentBid);
61
62 } // learn from the first opp. bid
63 catch (Exception e) {
64
65 }
66 }
67 }
68 }
69
70 int RoundCount = 0;
71
72 int FirstActions = 40;
73 int TotalFirstActions = 40;
74
75 @Override
76 public Action chooseAction() {
77 try {
78 // on the first few rounds don't get tempted so fast
79 if (FirstActions > 0 && OpponentBid != null
80 && utilitySpace.getUtility(OpponentBid) > 0.95)
81 return new Accept(this.getAgentID(), OpponentBid);
82
83 double threshold = IM.GetMinimumUtilityToAccept();
84 if (OpponentBid != null
85 && utilitySpace.getUtility(OpponentBid) >= threshold) {
86 return new Accept(this.getAgentID(), OpponentBid);
87 }
88
89 ++RoundCount;
90 if (WereBidsFiltered == false && (timeline
91 .getTime() > IM.GetDiscountFactor() * 0.9
92 || timeline.getTime()
93 + 3 * IM.BidsCreationTime > 1)) /*
94 * we must filter to
95 * make last bids
96 * efficient
97 */
98 {
99 WereBidsFiltered = true;
100
101 int DesiredBidcount = (int) (RoundCount
102 * (1 - timeline.getTime()));
103
104 if (IM.Bids.size() > 200) // if we won't filter many bids
105 // anyway, don't take the chance of
106 // filtering
107 {
108 IM.Bids = OM.FilterBids(IM.Bids, DesiredBidcount);
109 }
110 }
111
112 } catch (Exception e) {
113 e.printStackTrace();
114 }
115
116 // on the first time we act offer max bid
117 if (this.previousBid == null) {
118 try {
119 IM.AddMyBidToStatistics(this.IM.getMaxBid());
120 } catch (Exception e2) {
121 }
122 return new Offer(this.getAgentID(), this.IM.getMaxBid());
123 }
124
125 Bid myBid;
126 if (FirstActions >= 0 && timeline.getTime() < 0.15) {
127 // on first few bids let the opponent learn some more about our
128 // preferences
129
130 double utilDecrease = (1 - 0.925) / TotalFirstActions;
131
132 myBid = IM.GenerateBidWithAtleastUtilityOf(
133 0.925 + utilDecrease * FirstActions);
134 --FirstActions;
135 } else {
136 double threshold = IM.GetNextRecommendedOfferUtility();
137 myBid = IM.GenerateBidWithAtleastUtilityOf(threshold);
138
139 if (IM.InFrenzy == true)
140 myBid = IM.BestEverOpponentBid;
141 }
142
143 try {
144 IM.AddMyBidToStatistics(myBid);
145 } catch (Exception e2) {
146 }
147
148 return new Offer(this.getAgentID(), myBid);
149 }
150
151 @Override
152 public String getDescription() {
153 return "ANAC2011 compatible with non-linear utility spaces";
154 }
155
156}
Note: See TracBrowser for help on using the repository browser.