View Javadoc

1   package cz.cuni.amis.pogamut.ut2004.analyzer;
2   
3   import cz.cuni.amis.pogamut.base.agent.IAgentId;
4   import cz.cuni.amis.pogamut.base.agent.params.IAgentParameters;
5   import cz.cuni.amis.pogamut.base.communication.connection.IWorldConnectionAddress;
6   import cz.cuni.amis.pogamut.ut2004.agent.params.UT2004AgentParameters;
7   
8   public class UT2004AnalyzerObserverParameters extends UT2004AgentParameters {
9   
10  	private String observedAgentId;
11  	
12  	private Boolean waitForMatchRestart = null;
13  	
14  	private String outputPath = null;
15  	
16  	/**
17  	 * FileName to be used for the output. Must end with some file extension (e.g., .csv).
18  	 */
19  	private String fileName;
20  	
21  	public UT2004AnalyzerObserverParameters() {
22  		super();
23  	}
24  
25  	/**
26  	 * Returns ID of the player that should be observed.
27  	 * @return
28  	 */
29  	public String getObservedAgentId() {
30  		return observedAgentId;
31  	}
32  
33  	/**
34  	 * Sets 'id' (usually taken from the {@link UnrealId} that is present for instance in {@link Self#getId()}) 
35  	 * of the bot that is going to be observed by newly created observer.
36  	 * <p><p>
37  	 * WARNING: Note that you should not mess with 'setters' in different threads as they
38  	 * are non-thread-safe and may interrupt horrible agent instantiations with such behavior.
39  	 * @param address
40  	 * @return this instance
41  	 */
42  	public UT2004AnalyzerObserverParameters setObservedAgentId(String observedAgentId) {
43  		this.observedAgentId = observedAgentId;
44  		return this;
45  	}
46  	
47  	@Override
48  	public UT2004AnalyzerObserverParameters setAgentId(IAgentId agentId) {
49  		super.setAgentId(agentId);
50  		return this;
51  	}
52  	
53  	@Override
54  	public UT2004AnalyzerObserverParameters setWorldAddress(IWorldConnectionAddress address) {
55  		super.setWorldAddress(address);
56  		return this;
57  	}
58  	
59  	/**
60  	 * Contains path to directory where the observer should output its results. MUST POINT TO DIR!
61  	 * @return
62  	 */
63  	public String getOutputPath() {
64  		return outputPath;
65  	}
66  
67  	/**
68  	 * Sets  path to directory where the observer should output its results. MUST POINT TO DIR!
69  	 * @param outputPath
70  	 */
71  	public UT2004AnalyzerObserverParameters setOutputPath(String outputPath) {
72  		this.outputPath = outputPath;
73  		return this;
74  	}
75  
76  	/**
77  	 * Whether the observer should wait for match-restart before it starts to collect data.
78  	 * @return
79  	 */
80  	public boolean isWaitForMatchRestart() {
81  		return waitForMatchRestart == null ? false : waitForMatchRestart;
82  	}
83  
84  	/**
85  	 * Sets whether the observer should wait for match-restart before it starts to collect data.
86  	 * @param waitForMatchRestart
87  	 */
88  	public UT2004AnalyzerObserverParameters setWaitForMatchRestart(boolean waitForMatchRestart) {
89  		this.waitForMatchRestart = waitForMatchRestart;
90  		return this;
91  	}	
92  	
93  	/**
94  	 * Returns file name that should be used for outputting data (just file name, must be combined with {@link UT2004AnalyzerObserver#getOutputFilePath()}.
95  	 * @return
96  	 */
97  	public String getFileName() {
98  		return fileName;
99  	}
100 
101 	/**
102 	 * Sets FileName to be used for the output. Must end with some file extension (e.g., .csv). (Just file name, will be combined with {@link UT2004AnalyzerObserver#getOutputFilePath()}.
103 	 * @param fileName
104 	 */
105 	public UT2004AnalyzerObserverParameters setFileName(String fileName) {
106 		this.fileName = fileName;
107 		return this;
108 	}
109 
110 	@Override
111 	public void assignDefaults(IAgentParameters defaults) {
112 		super.assignDefaults(defaults);
113 		if (defaults instanceof UT2004AnalyzerParameters) {
114 			if (waitForMatchRestart == null && ((UT2004AnalyzerObserverParameters)defaults).waitForMatchRestart != null)
115 				waitForMatchRestart = ((UT2004AnalyzerObserverParameters)defaults).waitForMatchRestart;
116 			if (outputPath == null) outputPath = ((UT2004AnalyzerObserverParameters)defaults).getOutputPath();
117 			if (fileName == null) fileName = ((UT2004AnalyzerObserverParameters)defaults).getFileName();
118 		}
119 	}
120 
121 	
122 
123 	
124 	
125 }