/
Environment.java
128 lines (113 loc) · 3.06 KB
/
Environment.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package aima.core.agent;
import java.util.List;
/**
* An abstract description of possible discrete Environments in which Agent(s)
* can perceive and act.
*
* @param <P> Type which is used to represent percepts
* @param <A> Type which is used to represent actions
* @author Ravi Mohan
* @author Ciaran O'Reilly
* @author Mike Stampone
* @author Ruediger Lunde
*/
public interface Environment<P, A> {
/**
* Returns the Agents belonging to this Environment.
*
* @return The Agents belonging to this Environment.
*/
List<Agent<?, ?>> getAgents();
/**
* Add an agent to the Environment.
*
* @param agent
* the agent to be added.
*/
void addAgent(Agent<? super P, ? extends A> agent);
/**
* Remove an agent from the environment.
*
* @param agent
* the agent to be removed.
*/
void removeAgent(Agent<? super P, ? extends A> agent);
/**
* Returns the EnvironmentObjects that exist in this Environment.
*
* @return the EnvironmentObjects that exist in this Environment.
*/
List<EnvironmentObject> getEnvironmentObjects();
/**
* Add an EnvironmentObject to the Environment.
*
* @param eo
* the EnvironmentObject to be added.
*/
void addEnvironmentObject(EnvironmentObject eo);
/**
* Remove an EnvironmentObject from the Environment.
*
* @param eo
* the EnvironmentObject to be removed.
*/
void removeEnvironmentObject(EnvironmentObject eo);
/**
* Move the Environment one time step forward.
*/
void step();
/**
* Move the Environment n time steps forward.
*
* @param n
* the number of time steps to move the Environment forward.
*/
default void step(int n) {
for (int i = 0; i < n; i++)
step();
}
/**
* Step through time steps until the Environment has no more tasks.
*/
default void stepUntilDone() {
while (!isDone())
step();
}
/**
* Returns <code>true</code> if the Environment is finished with its current
* task(s).
*
* @return <code>true</code> if the Environment is finished with its current
* task(s).
*/
boolean isDone();
/**
* Retrieve the performance measure associated with an Agent.
*
* @param agent
* the Agent for which a performance measure is to be retrieved.
* @return the performance measure associated with the Agent.
*/
double getPerformanceMeasure(Agent<?, ?> agent);
/**
* Add a listener which is notified about environment changes.
*
* @param listener
* the listener to be added.
*/
void addEnvironmentListener(EnvironmentListener<? super P, ? super A> listener);
/**
* Remove a listener.
*
* @param listener
* the listener to be removed.
*/
void removeEnvironmentListener(EnvironmentListener<? super P, ? super A> listener);
/**
* Notify all environment listeners of a message.
*
* @param msg
* the message to notify the registered listeners with.
*/
void notify(String msg);
}