source: src/test/java/agents/nastyagent/StoreAndRetrieve.java@ 126

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 
1package agents.nastyagent;
2
3import java.util.HashMap;
4import java.util.HashSet;
5import java.util.Set;
6
7import genius.core.AgentID;
8import genius.core.Bid;
9import 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 */
17public 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.