コード例 #1
0
    #define a candidatePathList
    path1 = path('path1',['P1','P2','P3','P4','EXIT'])
    path2 = path('path2',['P1','P7','P6','P5','EXIT'])
    existingPathList = [path1,path2]
    
    # add these paths to the graph
    graph.add_path(path1)
    graph.add_path(path2)

    # give the conditions extracted from fire warden's command.
    condition = "AVOID P6"

    # get the candidatePathList
    # type candidatePathList: set() 
    candidatePathList = graph.filterPath(condition)

    # give the agent current position (encounter position)
    startNode = 'P7'

    #get the connecting node for agent, and target path to link
    node_and_pathList = graph.findConnectingNode(candidatePathList,startNode)
    connectingNode = node_and_pathList['vertex']
    targetPathList = node_and_pathList['pathList']

    # draw connectingPath
    connectingPath = graph.find_path(startNode, connectingNode)

    # Find the best result from the available path
    # if no path returned, draw a full new path
    if len(targetPathList) == 0: