Last change
on this file since 1 was 1, checked in by Wouter Pasman, 6 years ago |
Initial import : Genius 9.0.0
|
File size:
1.2 KB
|
Line | |
---|
1 | package agents.nastyagent;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 |
|
---|
5 | import genius.core.Bid;
|
---|
6 | import genius.core.actions.Action;
|
---|
7 | import genius.core.actions.Offer;
|
---|
8 | import genius.core.issue.Issue;
|
---|
9 | import genius.core.issue.IssueDiscrete;
|
---|
10 | import genius.core.issue.Value;
|
---|
11 | import genius.core.issue.ValueDiscrete;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * returns a deliberately miscrafted bid that contains an slightly altered value
|
---|
15 | * that is not in the domain description. It only works if it finds an
|
---|
16 | * issueDiscrete.
|
---|
17 | *
|
---|
18 | * @author W.Pasman 2nov15
|
---|
19 | *
|
---|
20 | */
|
---|
21 | public class UnknownValue extends NastyAgent {
|
---|
22 | @Override
|
---|
23 | public Action chooseAction(List<Class<? extends Action>> possibleActions) {
|
---|
24 | Bid bid = bids.get(0);
|
---|
25 |
|
---|
26 | int issuenr = -1;
|
---|
27 | for (Issue issue : bid.getIssues()) {
|
---|
28 | if (issue instanceof IssueDiscrete) {
|
---|
29 | issuenr = issue.getNumber();
|
---|
30 | break;
|
---|
31 | }
|
---|
32 | }
|
---|
33 | if (issuenr >= 0) {
|
---|
34 | // found an issue Discrete, modify it.
|
---|
35 | Value value;
|
---|
36 | try {
|
---|
37 | value = bid.getValue(issuenr);
|
---|
38 | } catch (Exception e) {
|
---|
39 | throw new IllegalStateException(e);
|
---|
40 | }
|
---|
41 |
|
---|
42 | bid = bid.putValue(issuenr, new ValueDiscrete("new" + ((ValueDiscrete) value).getValue()));
|
---|
43 | } else {
|
---|
44 | throw new IllegalArgumentException("UnknownValue agent needs an IssueDiscrete");
|
---|
45 | }
|
---|
46 |
|
---|
47 | return new Offer(id, bid);
|
---|
48 | }
|
---|
49 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.