Last change
on this file since 126 was 1, checked in by Wouter Pasman, 6 years ago |
Initial import : Genius 9.0.0
|
File size:
1.1 KB
|
Line | |
---|
1 | package agents.nastyagent;
|
---|
2 |
|
---|
3 | import java.util.HashMap;
|
---|
4 | import java.util.HashSet;
|
---|
5 | import java.util.Set;
|
---|
6 |
|
---|
7 | import genius.core.AgentID;
|
---|
8 | import genius.core.Bid;
|
---|
9 | import genius.core.actions.Action;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Checks if data is retained. This uses a hack. This agent must be used in only
|
---|
13 | * 1 tournament.
|
---|
14 | *
|
---|
15 | *
|
---|
16 | */
|
---|
17 | public class StoreAndRetrieve extends NastyAgent {
|
---|
18 | private static final String DATA = "data";
|
---|
19 |
|
---|
20 | static Set<String> runBefore = new HashSet<String>();
|
---|
21 |
|
---|
22 | @Override
|
---|
23 | public void receiveMessage(AgentID sender, Action action) {
|
---|
24 | this.lastReceivedAction = action;
|
---|
25 |
|
---|
26 | String utilSpaceName = utilitySpace.getFileName();
|
---|
27 |
|
---|
28 | if (!runBefore.contains(utilSpaceName)) {
|
---|
29 | if (data.get() != null) {
|
---|
30 | throw new IllegalStateException("Not run before but having data!");
|
---|
31 | }
|
---|
32 | data.put(DATA);
|
---|
33 | runBefore.add(utilSpaceName);
|
---|
34 | } else {
|
---|
35 | if (!DATA.equals(data.get())) {
|
---|
36 | throw new IllegalStateException("Data has not been retained!");
|
---|
37 | }
|
---|
38 | }
|
---|
39 |
|
---|
40 | }
|
---|
41 |
|
---|
42 | @Override
|
---|
43 | public HashMap<String, String> negotiationEnded(Bid acceptedBid) {
|
---|
44 | // we actually got here. Report it.
|
---|
45 | super.negotiationEnded(acceptedBid);
|
---|
46 |
|
---|
47 | return null;
|
---|
48 | }
|
---|
49 |
|
---|
50 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.