source: src/main/java/parties/in4010/q12015/group10/AcceptanceStrategy.java@ 127

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

Initial import : Genius 9.0.0

File size: 1.9 KB
Line 
1package parties.in4010.q12015.group10;
2
3import java.util.List;
4
5import genius.core.AgentID;
6import genius.core.actions.Accept;
7import genius.core.actions.Action;
8import genius.core.actions.Offer;
9import genius.core.bidding.BidDetails;
10
11public class AcceptanceStrategy {
12 /**
13 * support function to create action
14 *
15 * @param validActions
16 * @param detailsOfPotentialBid
17 * @param detailsOfLatestBidOnTable
18 * @param agent
19 * the agent ID, needed to create the actions on behalf of this
20 * agent.
21 * @return
22 */
23 static Action getAction(List<Class<? extends Action>> validActions,
24 BidDetails detailsOfPotentialBid,
25 BidDetails detailsOfLatestBidOnTable, AgentID agent) {
26 // Check if we are allowed to accept. We're not allowed to do this when
27 // we are the first party to make a bid.
28 boolean acceptingIsAllowed = validActions.contains(Accept.class);
29
30 double minUtilityAlwaysAccept = 0.95;
31
32 if (acceptingIsAllowed) {
33 // We're not the first: So we can accept, offer, or deny.
34 double offeredUtilVal = detailsOfLatestBidOnTable
35 .getMyUndiscountedUtil();
36 double PotentialUtilVal = detailsOfPotentialBid
37 .getMyUndiscountedUtil();
38
39 // If the value we are getting by accepting is higher than what we
40 // would get using our own new offer, we accept.
41 // We also accept if the utility is higher than our value that we
42 // also accept
43 if (offeredUtilVal >= PotentialUtilVal
44 || offeredUtilVal >= minUtilityAlwaysAccept) {
45 return new Accept(agent, detailsOfPotentialBid.getBid());
46 } else {
47 detailsOfLatestBidOnTable = detailsOfPotentialBid;
48 return new Offer(agent, detailsOfPotentialBid.getBid());
49 }
50 } else {
51 // We are not allowed to accept. We can still offer or deny. Right
52 // now only offering is implemented.
53 detailsOfLatestBidOnTable = detailsOfPotentialBid;
54 return new Offer(agent, detailsOfPotentialBid.getBid());
55 }
56 }
57}
Note: See TracBrowser for help on using the repository browser.