Beispiel #1
0
 def get_player_by_eid(self, eid) -> Optional["PlayerNode"]:
     r = self._db_read_one("SELECT uuid FROM ReferenceObjects WHERE eid=?",
                           eid)
     if r:
         return PlayerNode(self, r[0])
     else:
         return None
Beispiel #2
0
    def get_player_by_id(self, memid) -> "PlayerNode":
        """Given memid, retrieve PlayerNode

        Args:
            memid (string): memory ID
        """
        return PlayerNode(self, memid)
Beispiel #3
0
 def get_player_by_name(self, name) -> Optional["PlayerNode"]:
     r = self._db_read_one(
         'SELECT uuid FROM ReferenceObjects WHERE ref_type="player" AND name=?',
         name)
     #        r = self._db_read_one("SELECT uuid FROM Players WHERE name=?", name)
     if r:
         return PlayerNode(self, r[0])
     else:
         return None
Beispiel #4
0
 def get_player_by_name(self, name) -> Optional["PlayerNode"]:
     r = self._db_read_one(
         "SELECT Players.uuid FROM Players INNER JOIN Memories as M ON Players.uuid=M.uuid WHERE M.is_snapshot=0 AND name=?",
         name,
     )
     #        r = self._db_read_one("SELECT uuid FROM Players WHERE name=?", name)
     if r:
         return PlayerNode(self, r[0])
     else:
         return None
Beispiel #5
0
    def get_player_by_eid(self, eid) -> Optional["PlayerNode"]:
        """Given eid, retrieve PlayerNode

        Args:
            eid (int): Entity ID
        """
        r = self._db_read_one("SELECT uuid FROM ReferenceObjects WHERE eid=?", eid)
        if r:
            return PlayerNode(self, r[0])
        else:
            return None
Beispiel #6
0
    def get_player_by_name(self, name) -> Optional["PlayerNode"]:
        """Given player name, retrieve PlayerNode

        Args:
            name (string): Player name
        """
        r = self._db_read_one(
            'SELECT uuid FROM ReferenceObjects WHERE ref_type="player" AND name=?', name
        )
        #        r = self._db_read_one("SELECT uuid FROM Players WHERE name=?", name)
        if r:
            return PlayerNode(self, r[0])
        else:
            return None
Beispiel #7
0
    def perceive(self):
        bots = self.agent.world.get_bots()
        for bot in bots:
            #            print(f"[Perception INFO]: Perceived bot [{bot.name}] in the world, update in memory]")
            bot_node = self.agent.memory.get_player_by_eid(bot.entityId)
            if bot_node is None:
                memid = PlayerNode.create(self.agent.memory, bot)
                bot_node = PlayerNode(self.agent.memory, memid)
                self.agent.memory.tag(memid, "bot")
            bot_node.update(self.agent.memory, bot, bot_node.memid)
            print(
                f"[Memory INFO]: update bot [{bot.name}] position: ({bot.pos.x}, {bot.pos.y}, {bot.pos.z})"
            )

        bot_memids = self.agent.memory.get_memids_by_tag("bot")
        bots_in_world = [b.entityId for b in bots]
        for memid in bot_memids:
            bot_eid = self.agent.memory.get_mem_by_id(memid).eid
            if bot_eid not in bots_in_world:
                self.agent.memory.forget(memid)
                print(f"[Memory INFO]: delete bot [{bot_eid}] from memory")
Beispiel #8
0
 def get_player_by_id(self, memid) -> "PlayerNode":
     return PlayerNode(self, memid)