source: src/test/java/agents/nastyagent/BadBid.java@ 50

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

Initial import : Genius 9.0.0

File size: 1.0 KB
Line 
1package agents.nastyagent;
2
3import java.util.List;
4
5import genius.core.Bid;
6import genius.core.actions.Action;
7import genius.core.actions.Offer;
8import genius.core.issue.Issue;
9import genius.core.issue.IssueDiscrete;
10import genius.core.issue.ValueDiscrete;
11import genius.core.issue.ValueInteger;
12
13/**
14 * returns a deliberately miscrafted bid that contains an integer value where a
15 * discrete is expected, or the other way round. The idea is that the opponent
16 * may call getUtility on it and then cause a class cast exception.
17 *
18 * @author W.Pasman 2nov15
19 *
20 */
21public class BadBid extends NastyAgent {
22 @Override
23 public Action chooseAction(List<Class<? extends Action>> possibleActions) {
24 Bid bid = bids.get(0);
25
26 int randomissue = (int) (Math.random() * bid.getIssues().size());
27 Issue issue = bid.getIssues().get(randomissue);
28 if (issue instanceof IssueDiscrete) {
29 bid.putValue(issue.getNumber(), new ValueInteger(2));
30 } else {
31 bid.putValue(issue.getNumber(), new ValueDiscrete("33"));
32 }
33
34 return new Offer(id, bid);
35 }
36}
Note: See TracBrowser for help on using the repository browser.