rescuecore a java development kit for robocup rescue
Post on 18-Dec-2015
222 Views
Preview:
TRANSCRIPT
The World
• Rescue simulation defines several object types– Road– Node– Building– Civilian– Fire Brigade– ...
The World (continued)
• We want to have the same types available for our agents
• Each object in the simulation is wrapped in a Java class
• Objects have get/set methods for fields
Class Heirarchy
C ivilian F ire B rigade
Police Force Am bulance Team
H um anoid
R efuge F ire S tation
Am bulance C enter Police O ffice
Build ing R oad
N ode R iver
R ivernode W orld
R escueO bject
M em ory
Sam ple F ire S tation
Sam ple Police O ffice
Sam ple Am bulance C enter
C enter Agent
Sam ple F ire B rigade
Sam ple Police Force
Sam ple Am bulance Team
Platoon Agent
Agent
Memory
• The Memory object holds all our information about the world
• Can look up objects by ID or type
• Can find common properties of objects– Position– Distance between two objects
RescueObject
• Base class for all objects in rescue environment
• Data is stored as name-value pairs (sort of)– Actually a map from property id to value
• Subclasses provide access to data in a nice way
Example: Road
• Has get methods for all data– getWidth()– getBlock()– getLength()– ...
• Set method for altering blockedness– boolean setBlock(int block, int timestamp)
Talking to the kernel
• Communication protocol is fairly complex and poorly documented
• Rescuecore hides all the details
• Agents talk to the kernel with Commands– AK_EXTINGUISH– AK_MOVE– ...
Agents
• A base Agent class is provided
• Provides mechanisms for:– sending commands– receiving hear/sense messages– automatic updates of Memory from kernel
• Subclasses only need to implement a couple of methods
The AgentSystem
• Launches Agents and connects them to the kernel
• Passes messages from the kernel to the target Agent
• Does the actual sending of Commands
A Simple Agent
• Only need to implement two methods– void sense()– boolean hear(int from, byte[] message)
• Can implement initialise if needed– void initialise(AgentSystem, int id,
RescueObject[] knowledge, RescueObject self)
A Simple Agent (continued)
protected boolean hear(int from, byte[] data) {return false;
}protected void sense() {
Building target = findCloseFieryBuilding();
appendCommand(Command.AK_EXTINGUISH(id,target.getID());
}
Using the Memory
private Building findCloseFieryBuilding() {RescueObject[] all =
memory.getObjectsOfType(TYPE_BUILDING)for (int i=0;i<all.length;++i) {
if (((Building)all[i]).isOnFire() && memory.getDistance(me(),all[i]) < MAX_EXTINGUISH_DISTANCE)
return all[i];}return null;
}
Memory Functions
• RescueObject[] getAllObjects()
• RescueObject[] getObjectsOfType(int type)
• RescueObject lookup(int id)
• int[] getXY(RescueObject o)
• double getDistance(RescueObject o1, RescueObject o2)
Agent Functions
• RescueObject me()
• void appendCommand(Command c)
• void flushCommands()
• void say(byte[] message)
• void tell(byte[] message)
PlatoonAgent Functions
• void move(int[] ids)
• void clear(Road target)
• void extinguish(Building target)
• void load(Humanoid target)
• void unload()
• RescueObject getLocation()
• int getPosition()
MemoryListeners
• Event mechanism for memory model
• void objectAdded(RescueObject o, int time)
• void objectChanged(RescueObject o, int property, int time)
• Memory class has methods for adding/removing MemoryListeners
PropertyListeners
• Can also listen for individual property changes on an object
• void propertyChanged(RescueObject o, int property, int time)
• RescueObject has methods for adding/removing PropertyListeners
Debugging
• Not well implemented yet
• Agent class has a logging method– void log(String message)– Writes to a file called agent.log
• More functionality will be added later
Tools
• RandomConfig– Generates random placements of agents and
fires
• MapGenerator– Generates random maps
• Quake– Generates earthquake data– Not written yet – any volunteers?
Writing Clever Agents
• Suppose we want to use fuzzy logic for deciding which roads to take
• Implement a Memory called FuzzyMemory• Whenever a Road gets added to the
FuzzyMemory it replaces the Road with a FuzzyRoad
• If an agent calls lookup() then it gets returned a FuzzyRoad
top related