Ejemplo n.º 1
0
 def solve(m):
     object_, = m.search_last_message(r"How many (\w+)")
     # I don't have anything in the beginning
     m.send(msg.number_to_string(0) + ".")
     m.read()
     article, object_, = m.search_last_message(r"I gave you (\w+) (\w+)")
     # The teacher just gave me somthing
     m.send(msg.number_to_string(1) + ".")
     m.read()
     # Give the object back to the teacher
     m.send("I give you {article} {object}.".format(article=article,
                                                    object=object_))
     m.read()
     # I don't have anything anymore
     m.send(msg.number_to_string(0) + ".")
Ejemplo n.º 2
0
        def solve(m):
            """ I don't have anything in the beginning. The teacher just gave me something Give the object back to the
            teacher. I don't have anything anymore

            :param m:
            :return:
            """
            # FIXME object named object
            object_, = m.search_last_message(r"How many (\w+)")
            m.send(msg.number_to_string(0) + ".")
            m.read()
            article, object_, = m.search_last_message(r"I gave you (\w+) (\w+)")
            m.send(msg.number_to_string(1) + ".")
            m.read()
            m.send("I give you {article} {object}.".format(article=article, object=object_))
            m.read()
            m.send(msg.number_to_string(0) + ".")
    def give_away_answer(self, event):
        # TODO event not used
        """ inform the answer randomly choosing a numeric or alphabetic format.

        :param event:
        :return:
        """
        self.set_message('the right answer is: {answer}.'.format(answer = msg.number_to_string(self.property_count)))
Ejemplo n.º 4
0
    def on_start(self, event):
        # TODO event not used, cur_phrase, n, target  def outside __init__
        """ sample a random phrase.  sample the number of times it has to repeat the phrase (can be expressed in
        letters or numbers).  save the correct answer

        :param event:
        :return:
        """
        self.cur_phrase = random.choice(phrases)
        self.n = random.randint(repeat_min, repeat_max)
        self.set_message("{query_verb} {phrase} {times} times separated " "by and.".format(
                query_verb = random.choice(verbs), phrase = self.cur_phrase, times = msg.number_to_string(self.n),
                context = random.choice(context)))
        self.target = ' and '.join([self.cur_phrase] * self.n)
 def check_response(self, event):
     # check if the answer matches any of the possible ways of expressing
     # the correct number.
     # NB: note that here a longer digit string ending with the currect
     # number will be considered correct (e.g., 321 when the correct answer
     # is 1)
     if any(event.is_message(correct_alt, '.')
            for correct_alt in msg.number_to_strings(self.object_count)):
         self.set_result(1, random.choice(msg.congratulations))
     else:
         feedback = 'the right answer is: {answer}. please try again. '.format(
             answer=msg.number_to_string(self.object_count))
         feedback += self.question
         self.set_message(feedback)
Ejemplo n.º 6
0
 def check_response(self, event):
     # check if the answer matches any of the possible ways of expressing
     # the correct number.
     # NB: note that here a longer digit string ending with the currect
     # number will be considered correct (e.g., 321 when the correct answer
     # is 1)
     if any(
             event.is_message(correct_alt, '.')
             for correct_alt in msg.number_to_strings(self.object_count)):
         self.set_reward(1, random.choice(msg.congratulations))
     else:
         feedback = 'the right answer is: {answer}. please try again. '.format(
             answer=msg.number_to_string(self.object_count))
         feedback += self.question
         self.set_message(feedback)
Ejemplo n.º 7
0
    def on_start(self, event):
        # sample a random phrase
        self.cur_phrase = random.choice(phrases)

        # sample the number of times it has to repeat the phrase
        # (can be expressed in letters or numbers)
        self.n = random.randint(repeat_min, repeat_max)

        self.set_message("{query_verb} {phrase} {times} times separated "
                         "by and.".format(query_verb=random.choice(verbs),
                                          phrase=self.cur_phrase,
                                          times=msg.number_to_string(self.n),
                                          context=random.choice(context)))
        # save the correct answer
        self.target = ' and '.join([self.cur_phrase] * self.n)
    def on_start(self, event):
        # sample a random phrase
        self.cur_phrase = random.choice(phrases)

        # sample the number of times it has to repeat the phrase
        # (can be expressed in letters or numbers)
        self.n = random.randint(repeat_min, repeat_max)

        self.set_message("{query_verb} {phrase} {times} times {context}."
                         .format(
                             query_verb=random.choice(verbs),
                             phrase=self.cur_phrase,
                             times=msg.number_to_string(self.n),
                             context=random.choice(context)
                         ))
        # save the correct answer
        self.target = ' '.join([self.cur_phrase] * self.n)
Ejemplo n.º 9
0
    def on_start(self, event):
        # TODO target_obj, n def outside __init__ event not used
        """ choose a random object.  select a random number of steps.  place the object that number of steps in front
        of the learner.

        :param event:
        :return:
        """
        self.target_obj, = random.sample(objects, 1)
        ws = self.get_world().state
        self.n = random.randint(1, PickUpInFrontTask.max_steps_forward)
        p = ws.learner_pos + self.n * self.get_world().valid_directions[ws.learner_direction]
        self.state.initial_count = ws.learner_inventory[self.target_obj]
        self.get_world().put_entity(p, self.target_obj, True, True)
        self.add_handler(
                on_state_changed(lambda ws, ts: ws.learner_inventory[self.target_obj] == ts.initial_count + 1)
                (self.on_object_picked_up))
        self.set_message("There is {indef_object} {n} steps forward, " "pick up the {object}.".format(
                        indef_object = msg.indef_article(self.target_obj), n = msg.number_to_string(self.n),
                        object = self.target_obj))
    def on_start(self, event):
        # choose a random object
        self.target_obj, = random.sample(objects, 1)
        ws = self.get_world().state
        # select a random number of steps
        self.n = random.randint(1, PickUpInFrontTask.max_steps_forward)
        # place the object that number of steps in front of the learner
        p = ws.learner_pos + self.n * self.get_world().valid_directions[
            ws.learner_direction]
        self.state.initial_count = ws.learner_inventory[self.target_obj]
        self.get_world().put_entity(p, self.target_obj, True, True)

        self.add_handler(
            on_state_changed(lambda ws, ts:
                             ws.learner_inventory[self.target_obj] ==
                             ts.initial_count + 1)
            (self.on_object_picked_up))

        self.set_message("There is {indef_object} {n} steps forward, "
                         "pick up the {object}."
                         .format(
                             indef_object=msg.indef_article(self.target_obj),
                             n=msg.number_to_string(self.n),
                             object=self.target_obj))
Ejemplo n.º 11
0
 def give_away_answer(self, event):
     # inform the answer randomly choosing a numeric or alphabetic format.
     self.set_message(
         'you are too slow. the right answer is: {answer}.'.format(
             answer=msg.number_to_string(self.object_count)))
 def give_away_answer(self, event):
     # inform the answer randomly choosing a numeric or alphabetic format.
     self.set_message('you are too slow. the right answer is: {answer}.'.format(
         answer=msg.number_to_string(self.object_count)
     ))