public class Kernel
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
KERNEL_LOG_CONTEXT
The log context for kernel log messages.
|
Constructor and Description |
---|
Kernel(Config config,
Perception perception,
CommunicationModel communicationModel,
WorldModel<? extends Entity> worldModel,
EntityIDGenerator idGenerator,
CommandFilter commandFilter,
TerminationCondition termination,
ScoreFunction score,
CommandCollector collector)
Construct a kernel.
|
Modifier and Type | Method and Description |
---|---|
void |
addAgent(AgentProxy agent)
Add an agent to the system.
|
void |
addKernelListener(KernelListener l)
Add a KernelListener.
|
void |
addSimulator(SimulatorProxy sim)
Add a simulator to the system.
|
void |
addViewer(ViewerProxy viewer)
Add a viewer to the system.
|
java.util.Collection<AgentProxy> |
getAllAgents()
Get all agents in the system.
|
java.util.Collection<SimulatorProxy> |
getAllSimulators()
Get all simulators in the system.
|
java.util.Collection<ViewerProxy> |
getAllViewers()
Get all viewers in the system.
|
Config |
getConfig()
Get the kernel's configuration.
|
KernelState |
getState()
Get a snapshot of the kernel's state.
|
int |
getTime()
Get the current time.
|
WorldModel<? extends Entity> |
getWorldModel()
Get the world model.
|
boolean |
hasTerminated()
Find out if the kernel has terminated.
|
void |
removeAgent(AgentProxy agent)
Remove an agent from the system.
|
void |
removeKernelListener(KernelListener l)
Remove a KernelListener.
|
void |
removeSimulator(SimulatorProxy sim)
Remove a simulator from the system.
|
void |
removeViewer(ViewerProxy viewer)
Remove a viewer from the system.
|
void |
shutdown()
Shut down the kernel.
|
void |
timestep()
Run a single timestep.
|
public static final java.lang.String KERNEL_LOG_CONTEXT
public Kernel(Config config, Perception perception, CommunicationModel communicationModel, WorldModel<? extends Entity> worldModel, EntityIDGenerator idGenerator, CommandFilter commandFilter, TerminationCondition termination, ScoreFunction score, CommandCollector collector) throws KernelException
config
- The configuration to use.perception
- A perception calculator.communicationModel
- A communication model.worldModel
- The world model.idGenerator
- An EntityIDGenerator.commandFilter
- An optional command filter. This may be null.termination
- The termination condition.score
- The score function.collector
- The CommandCollector to use.KernelException
- If there is a problem constructing the kernel.public Config getConfig()
public KernelState getState()
public void addAgent(AgentProxy agent)
agent
- The agent to add.public void removeAgent(AgentProxy agent)
agent
- The agent to remove.public java.util.Collection<AgentProxy> getAllAgents()
public void addSimulator(SimulatorProxy sim)
sim
- The simulator to add.public void removeSimulator(SimulatorProxy sim)
sim
- The simulator to remove.public java.util.Collection<SimulatorProxy> getAllSimulators()
public void addViewer(ViewerProxy viewer)
viewer
- The viewer to add.public void removeViewer(ViewerProxy viewer)
viewer
- The viewer to remove.public java.util.Collection<ViewerProxy> getAllViewers()
public void addKernelListener(KernelListener l)
l
- The listener to add.public void removeKernelListener(KernelListener l)
l
- The listener to remove.public int getTime()
public WorldModel<? extends Entity> getWorldModel()
public boolean hasTerminated()
public void timestep() throws java.lang.InterruptedException, KernelException, LogException
java.lang.InterruptedException
- If this thread is interrupted during the timestep.KernelException
- If there is a problem executing the timestep.LogException
- If there is a problem writing the log.public void shutdown()