yeagerai / genworlds

A framework for event based autonomous multi-agent systems.
https://genworlds.com/
MIT License
296 stars 35 forks source link

world.lunch() will cause the socket to be opened repeatedly #35

Open BladeY1 opened 6 months ago

BladeY1 commented 6 months ago

genworlds/worlds/abstracts/world.py:

        for obj in self.objects:
            sleep(0.1)
            self.add_object(obj)
        for agent in self.agents:
            sleep(0.1)
            self.add_agent(agent)

Since add_agent and add_objects will add new objects, the loop will not terminate

revise opinion:

        for obj in self.objects:
            sleep(0.1)
            #self.add_object(obj)
            obj.host_world_id = self.id  # Set the overworld ID of the object
            obj.launch_websocket_thread()  # Start the object's WebSocket thread

        for agent in self.agents:
            sleep(0.1)
            #self.add_agent(agent)
            agent.host_world_id = self.id  
            agent.launch()