Пример #1
0
    def initialize_person(self, u, idx):

        """
        This function creates and initializes a person with the proper parameters for the Eat Breakfast Trial\
        simulation. This is important because it changes the meal structure towards having only 1 meal per day.

        More specifically, the function does

        #. creates a person
        #. initializes the person's parameters to the respective values in :attr:`params`

        :param universe.Universe u: the universe the person will reside in
        :param int idx: the index of the person's parameters in :attr:`params`

        :return p: the agent to simulate
        :rtype: person.Person
        """

        # initialize the person
        p = super(Eat_Breakfast_Trial, self).initialize_person(u, idx)

        # adjust to have only 1 meal
        p.socio.num_meals = 1

        # get the dinner parameters for this person
        m = self.params.breakfasts[idx]

        # create the meal object
        the_meal = meal.Meal(meal.BREAKFAST, start_mean=m.start_mean, start_std=m.start_std,\
                             dt_mean=m.dt_mean, dt_std=m.dt_std)

        # reset the meals list
        p.socio.meals = [the_meal]

        return p
Пример #2
0
    def __init__(self, age, num_meals=3):

        # child / adult
        self.is_child = None
        self.set_child_flag(age)

        # job info
        self.job = occupation.Occupation()

        # meals
        self.num_meals = num_meals
        self.meals = [meal.Meal() for _ in range(self.num_meals)]

        self.current_meal = None
        self.next_meal = None
        # does the Person ever set an alarm. Currently, there is no real alarm capability
        self.uses_alarm = False

        # this depends on whether a Person uses an alarm and
        # whether the day is a work day
        # Currently, there is no real alarm capability
        self.is_alarm_set = False
        self.t_alarm = 7 * temporal.HOUR_2_MIN

        return
Пример #3
0
    def initialize_person(self, u, idx):
        """
        This function creates and initializes a person with the proper parameters for the Eat Lunch Trial\
        simulation.

        More specifically, the function does

        #. creates a :class:`singleton.Singleton` person
        #. initializes the person's parameters to the respective values in :attr:`params`

        :param universe.Universe u: the universe the person will reside in
        :param int idx: the index of the person's parameters in :attr:`params`

        :return p: the agent to be simulated
        :rtype: person.Person
        """

        # initialize the person
        p = super(Eat_Lunch_Trial, self).initialize_person(u, idx)

        # adjust to have only 1 meal
        p.socio.num_meals = 1

        # get the lunch parameters for this person
        m = self.params.lunches[idx]

        # create the meal object
        the_meal = meal.Meal( meal.LUNCH, start_mean=m.start_mean, start_std=m.start_std, \
                              dt_mean=m.dt_mean, dt_std=m.dt_std )

        # reset the meals list
        p.socio.meals = [the_meal]

        return p
Пример #4
0
def register_meal():
    print("食事記録を登録しましょう。")
    date = datetime.date.today().strftime("%y/%m/%d")
    while True:
        sort = int(input("1.朝食 2.昼食 3.夕食 4.間食 5.戻る"))
        if 1 <= sort <= 4:
            break
        elif sort == 5:
            print("戻ります。")
            return
        else:
            print("1~4で入力してください")
    materials = {}
    while True:
        cuisine = input("料理名を入力してください。終了する場合はqを入力してください")
        if cuisine == "q":
            break
        materials[cuisine] = {}
        while True:
            mate = input("材料を一つずつ入力してください。終了した場合はqを。")
            if mate == "q":
                break

            advance = search(mate)
            if advance:
                d = input("%sが見つかりました。使いますか?y or n" % advance[0])
                if d == "y":
                    while True:
                        print("食材の量を入力してください(%s単位)" %
                              material_class.change_each(advance[1]))
                        amount = int(input())
                        break
                    calory = advance[2] * amount
                    cost = advance[3] * amount
                    materials[cuisine][mate] = [calory, cost]
                    print("カロリー:%dcal 費用:%d円" % (calory, cost))
                    continue

            try:
                calory = int(input("食材のカロリーを入力してください"))
                cost = int(input("金額を入力してください"))
                materials[cuisine][mate] = [calory, cost]
                continue
            except:
                print("数字で入力してください。もう一度初めから。")
                continue

    dish = meal.Meal(sort, date, materials)
    dish.save()
 def prepare_combo_burger():
     orders = meal.Meal()
     orders.add_item(ChickenBurger())
     orders.add_item(VegBurger())
     return orders
 def prepare_non_veg_meal():
     orders = meal.Meal()
     orders.add_item(ChickenBurger())
     orders.add_item(Coke())
     return orders
 def prepare_veg_meal():
     orders = meal.Meal()
     orders.add_item(VegBurger())
     orders.add_item(Pepsi())
     return orders
Пример #8
0
def add_new_order(chat_id, possible_toppings, num_of_states):
    new_meal = meal.Meal(possible_toppings, num_of_states)
    orders[chat_id] = (new_meal, 0, TAKING_ORDER)