Last change
on this file was 1, checked in by Wouter Pasman, 6 years ago |
Initial import : Genius 9.0.0
|
File size:
1.0 KB
|
Rev | Line | |
---|
[1] | 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.ValueDiscrete;
|
---|
| 11 | import 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 | */
|
---|
| 21 | public 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.