Here is my
fetch_all_agents method, is which considered to provide all of the agent coordinates, in one shot:
def fetch_all_agents(number_of_agents = None): agentList =  agentConfig = configparser.ConfigParser() agentConfig.readfp(open(r'SwarmSimulator\configFile.txt')) random_option = agentConfig.get('Agent Generation', "random_option") if(random_option == "True"): agentList = agentObj.generate_agents(number_of_agents) elif(random_option == "False"): with open(r"SwarmSimulator\agentListFile.txt") as f: tempList = [list(ast.literal_eval(line)) for line in f] pointObj = Point.Point() for innerList in tempList: pointObj.x = innerList pointObj.y = innerList agentObj = Agent.Agent(pointObj) agentList.append(agentObj) return agentList
I am going to plan the other method, let's name it
fetch_single_agent to read one agent from the list, the one which the right agent held next to the last fetched one. It is reasonably to take a generator into account to hit this mark.
Would you please guiding me to implement an generator-driven version for above method, in which, as I explained, one can fetch an agent from the list in an ordered manner?...