Lectures TDDD10 AI Programming Introduction to RoboRescue

advertisement
Lectures
TDDD10AIProgramming
IntroductiontoRoboRescue
CyrilleBerger
1 AIProgramming:Introduction
2 IntroductiontoRoboRescue
3 AgentsandAgentsArchitecture
4 Communication
5 MultiagentDecisionMaking
6 CooperationAndCoordination1
7 CooperationAndCoordination2
8 MachineLearning
9 KnowledgeRepresentation
10PuttingItAllTogether
2/49
Lecturegoals
Lecturecontent
Acquireknowledgeonhowthe
rulesandhowtheRoboRescue
Simulatorworks
Acquireknowledgeonhowto
programtheRoboRescueSimulator
3/49
SimulatorOverview
SimulatorsandFramework
ProgrammingAgents
Communication
VisualisationandLogging
Scenarios
LabsOverview
Competition
4/49
Simulatorarchitecture
SimulatorOverview
6/49
Simulators
SimulationTime
theclearsimulator,responsibleforblockade
removal;
thecollapsesimulator,responsibleformanaging
buildings’structuraldamageandblockade
creation;
theignitionsimulator,responsibleforfiringup
randombuildingsduringthesimulation;
thefiresimulator,responsibleforthefirespread
betweenbuildings;
thetrafficsimulator,responsibleforhumans’
movement;
themiscsimulator,responsibleforhumandamage
andburiedness.
7/49
1
Thekernelupdatesallagents’perception(visualand
communication).
2
Theagentsupdatestheirworldmodelandmaketheir
decisions(1s)
3
Thekernelsendstheagents’commandstothe
simulators.
4
Thesimulatorsprocesstheagents’commandsand
sendthechangessufferedbytheenvironmentback
tothekernel.
5
Thekernelsendstheenvironmentchangestothe
viewers.
6
Thekernelupdatesallagents’perception...
8/49
SimulatorView
Buildings
Fromlefttoright:refuge,ambulancecentre,
firestation,hydrant,policeoffice,gasstation
Listofproperties:brokeness,fieryness,floors,
groundarea,ignite,temperature
9/49
Humans
10/49
Perception
Listofproperties:buriedness,
damage,HP,positionhistory
Typeofagents:
policeforce:canclearblockade
firemen:canextinguishfire
ambulance:candigouthumansandbringthem
tosafety
civilians
11/49
12/49
Scorecomputation
Canonlydecreaseovertime
LegacyScoreFunction:
sqrt(buildingareasaved)
*(civiliansalive+civilian
SimulatorsandFramework
13/49
Modules
Exampleofsimulator:firesimulator
Sourcecodeisin/home/TDDD10/RescueSimulator/
clear:clearsimulator
modules
collapse:collapsesimulator
gis2:worldmodelandscenarios
human:agentthatcanbecontrolledbya
ignition:ignition
kernel
maps:worldmodelandscenarios
misc:humanhealth
misc-new:alternativeimplementationofthemisc
rescuecore2:corelibrary(withinterfacesandabstractclasses)
resq-fire:firesimulator
sample:sourcecodeofthesampleagents
standard:corelibrary(basicimplementationoftheinterfaces)
traffic3:traffic
15/49
16/49
Rescuecore2/standard
rescuecore2:corelibrary(withinterfacesandabstractclasses)
components:baseagents...
config
connection:kerneltosimulator/agents
log
messages:usedforcommunicationwithkernel
misc/registry
scenario
score:ascorecomputationlibrary
view:interfaceforaviewer
worldmodel
ProgrammingAgents
standard:corelibrary(basicimplementationoftheinterfaces)
components:agents...
entities:mapitemsandagents
kernel:classusedbythekernel
messages:commandssentbytheagent
misc
score:implementationoftheLegacyScore
view:implementationoftheviewer
17/49
WorldModel
Everyagenthasa
StandardWorldModel
model
WorldModel:exampleofusegetObjectsInRange
getObjectsInRectangle:listof
objectsinagivenrectangle
getObjectsInRange:listofobjects
nearanotherobject
getEntitiesOfType:listallentities
ofagiventype
getDistance
getEntity
uselistenertomonitorchanges
19/49
List<EntityID>planPathToFire(EntityIDtarget)
{
//TrytogettoanythingwithinmaxDistance
//ofthetarget
Collection<StandardEntity>targets
=model.getObjectsInRange(target,maxDistance);
if(targets.isEmpty()){
returnnull;
}
returnsearch.breadthFirstSearch(
me().getPosition(),objectsToIDs(targets));
}
20/49
Commands
AKClearArea:clearablockade
ListofcommandsandStandardAgentfunction
usedtocreatethem:
AKClearArea/sendClear:usedtoclearablockade(policeforce)
AKExtinguish/sendExtinguish:usedtoextinguishabuilding
(firemen)
AKLoad/sendLoad:usedtoloadacivilian(ambulance)
AKMove/sendMove:usedtomovetheagent(all)
AKRescue/sendRescue:digoutahuman(ambulance)
AKRest/sendRest:forthelazyagents(all)
AKUnload/sendUnload:usedtouloadacivilian(ambulance)
voidsendClear(inttime,intdestX,int
destY)
time:thecurrenttime
destX:ThedestinationXcoordinatetoclear
destY:thedestinationYcoordinatetoclear
Atmostoneofthosecommandspercycle!
nocommandsentmeanstheagentdoes
21/49
22/49
AKMove:moveanagent
voidsendMove(inttime,List<EntityID>
path)
time:thecurrenttime
path:thepathtosend.
Pitfalls
Thefirstentryofthepathmustbeyour
currentposition
Alwayssendmorethantwo
Youneedtosendamovecommandeveryturn
untilyoudecideyouhavereachedyourdestination
23/49
Communication
ChannelCommunicationModel
CommunicationCommands
Multiple"radio"channels
Noisy
Listofcommandsand
StandardAgentfunctionusedto
createthem:
dropouts
corruption
Twotypesof
Voicechannel
Alwaysavailable(limitedrange
Usuallyonemessageof256bytesperagent
Radiochannels
Notalwaysavailable
Usuallynorange
Sharedbandwidthbetweenagent(from256to4000bytesdepending
onconfiguration)
AKSpeak/sendSpeak:usedtosenddataon
achannel
AKSubscribe/sendSubscribe:usedto
subscribetoachannel
25/49
AKSpeak:speak
26/49
AKSubscribe:subscribe
voidsendSpeak(inttime,intchannel,
byte[]data)
time:thecurrenttime
channel:thechanneltospeakon
data:thedatatosend
voidsendSubscribe(inttime,int...channels)
time:thecurrenttime
channels:listofchannels
Pitfalls
Sendinganewcommand,erasewhatwassetinthepast
Insomemaps,limitednumberofchannelsyoucan
Commandsatthebeginningofthesimulationareignored
register
(untilconfig.getIntValue(kernel.KernelConstants.
IGNORE_AGENT_COMMANDS_KEY))
Youdon'thavetoberegisteronachanneltospeakonit,
itisonlyforlistening
eachagentcanhaveasmany
AKSpeakcommandashewants
butdonotclogupyourchannels
27/49
28/49
Receivemessages
voidthink(inttime,ChangeSetchanged,
Collection<Command>heard)
listofmessagesisinheard
VisualisationandLogging
29/49
Importanceofvisualisation
Toknowwhyyouragentsare
doingsomething
Spendingacoupleofhours
onfindingabugislosttime
Spendingacoupleofhoursona
visualisationtoolisnotlosttime
Whattovisualise?
Everything
Graphoflongroad.
Whatyouragentsknow.
Whatdecisiontheytake.
Displaytherankingofpriorities.
...
31/49
32/49
Viewer
Logging(1/2)
Usinglog4j
SampleViewer:workslikeanagent
AnimatedWorldModelVieweralayeredmap
Standardlayers:building,road,areaneighbours,road
blockade,areaicons,humans,commands,positionhistory
ImplementsyourownbysubclassingStandardViewLayer
Logger.info()
Logger.debug()
CollectionT<RenderedObject>render(Graphics2Dg,ScreenTransform
transform,intwidth,intheight);
Remember:youcanuse
AnimatedWorldModelViewertoviewyour
agentmodel
33/49
Logging(2/2)
34/49
Logviewer
OtrosLogViewer(https://code.google.com/
p/otroslogviewer)
35/49
cd~/RescueSimulator/boot
bashlogviewer.shlogs/rescue.log
36/49
Structureofamap
Twofiles:
map.gml:buildingsandroaddefinition
scenario.xml:definesnumberof
agents,initialfires,stations...
Scenarios
38/49
Scenario.xml
Configuration
<?xmlversion="1.0"encoding="UTF-8"?>
<scenario:scenarioxmlns:scenario="urn:roborescue:map:scenario">
<scenario:firestationscenario:location="19100"/>
<scenario:policeofficescenario:location="15738"/>
<scenario:ambulancecentrescenario:location="36012"/>
<scenario:refugescenario:location="20337"/>
<scenario:firescenario:location="10756"/>
<scenario:hydrantscenario:location="8628"/>
<scenario:gasstationscenario:location="12933"/>
<scenario:civilianscenario:location="17175"/>
<scenario:firebrigadescenario:location="20597"/>
<scenario:policeforcescenario:location="31006"/>
<scenario:ambulanceteamscenario:location="317"/>
</scenario:scenario>
39/49
letshavealook
config.getIntValue("...")
40/49
Lab2:PathPlanning
LabsOverview
42/49
Lab3:Communication
Lab4:CooperativeSensingandTeamExploration
Goalistofindallthevictims
Usingthefrontiercellalgorithm
Extinguishingbuilding
UsingContractNettoauction
buildingextinction
43/49
44/49
Lab5:CentralizedTaskAllocation
Lab6:MachineLearning
Thegoalistoimplementafire
stationthatdispatchfirebrigadesto
extinguishfiresusingacentralized
assignmentalgorithm
decisiontreelearningappliedtothe
decisionofwhichbuildingto
45/49
46/49
Competition
Competition
weeklycompetition
Usingthreemaps(/home/TDDD10/
maps/competition/):
Kobe:normalcommunication
Berlin:nocommunication(exceptvoice)
Paris:largemapwithunreliabe
communication
48/49
Summary
Overviewofthe
simulatorarchitecture
Howtoprogramagents,
49/49
Download