Esempio n. 1
0
 def __init__(self, opts=None, spec=None):
     self.bots = []
     for i in range(opts.num_bots):
         x = random.randint(0, WORLD_SIZE - 1)
         y = random.randint(0, WORLD_SIZE - 1)
         eid = i
         botname = "target" + str(i)
         bot = Bot(eid, botname, Pos(x, y, 0), Look(0, 0))
         self.bots.append(bot)
Esempio n. 2
0
 def get_all_players(self):
     """This function is a wrapper around self.cagent.get_other_players and adds a new
     player called "dashboard" if it doesn't already exist."""
     all_players = self.cagent.get_other_players()
     updated_players = all_players
     player_exists = False
     for player in all_players:
         if player.name == "dashboard":
             player_exists = True
     if not player_exists:
         newPlayer = Player(12345678, "dashboard", Pos(0.0, 64.0, 0.0),
                            Look(0.0, 0.0), Item(0, 0))
         updated_players.append(newPlayer)
     return updated_players
Esempio n. 3
0
 def __init__(self, opts, name="Locobot"):
     super(LocobotAgent, self).__init__(opts)
     logging.info("LocobotAgent.__init__ started")
     self.opts = opts
     self.entityId = 0
     self.no_default_behavior = opts.no_default_behavior
     self.last_chat_time = -1000000000000
     self.name = name
     self.player = Player(100, name, Pos(0, 0, 0), Look(0, 0))
     self.pos = Pos(0, 0, 0)
     self.uncaught_error_count = 0
     self.last_task_memid = None
     self.point_targets = []
     self.init_event_handlers()
     # list of (prob, default function) pairs
     self.visible_defaults = [(1.0, default_behaviors.explore)]
Esempio n. 4
0
 def get_look(self):
     return Look(self.pitch, self.base_yaw + self.pan)
Esempio n. 5
0
    def test_triggers(self):
        joe_memid = PlayerNode.create(
            self.memory, Player(10, "joe", Pos(1, 0, 1), Look(0, 0)))
        joe_tag_memid = self.memory.tag(joe_memid, "joe")
        jane_memid = PlayerNode.create(
            self.memory, Player(11, "jane", Pos(-1, 0, 1), Look(0, 0)))

        joe_mems = self.memory.basic_search({
            "base_exact": {
                "name": "joe"
            },
            "triples": []
        })
        jane_mems = self.memory.basic_search({
            "base_exact": {
                "name": "jane"
            },
            "triples": []
        })
        assert len(joe_mems) == 1
        assert len(jane_mems) == 1

        joe_mems_from_tag = self.memory.basic_search({
            "base_exact": {},
            "triples": [{
                "obj_text": "joe",
                "pred_text": "has_tag"
            }]
        })
        jane_mems_from_tag = self.memory.basic_search({
            "base_exact": {},
            "triples": [{
                "obj_text": "jane",
                "pred_text": "has_tag"
            }]
        })
        assert len(joe_mems_from_tag) == 1
        assert len(jane_mems_from_tag) == 0

        self.time.add_tick()
        brother_of_memid = self.memory.add_triple(subj=joe_memid,
                                                  pred_text="brother_of",
                                                  obj=jane_memid)
        sister_of_memid = self.memory.add_triple(subj=jane_memid,
                                                 pred_text="sister_of",
                                                 obj=joe_memid)

        triples = self.memory.get_triples(subj=jane_memid,
                                          pred_text="sister_of")
        assert len(triples) == 1

        self.time.add_tick()
        self.memory.db_write("UPDATE ReferenceObjects SET x=? WHERE uuid=?", 2,
                             joe_memid)
        cmd = "SELECT updated_time FROM Memories WHERE uuid=?"
        joe_t = self.memory._db_read(cmd, joe_memid)[0][0]
        jane_t = self.memory._db_read(cmd, jane_memid)[0][0]
        assert joe_t == 2
        assert jane_t == 0

        self.memory.forget(joe_memid)
        triples = self.memory.get_triples(subj=jane_memid,
                                          pred_text="sister_of")
        assert len(triples) == 0