Example #1
0
    def init_rooms(self, frame):
        study = Study(frame)
        study.grid(row=0, column=0)

        hall = Hall(frame)
        hall.grid(row=0, column=9)

        lounge = Lounge(frame)
        lounge.grid(row=0, column=17)

        library = Library(frame)
        library.grid(row=6, column=0)

        stairs = Stairs(frame)
        stairs.grid(row=8, column=9)

        dining_room = DiningRoom(frame)
        dining_room.grid(row=9, column=16)

        billiard_room = BilliardRoom(frame)
        billiard_room.grid(row=12, column=0)

        conservatory = Conservatory(frame)
        conservatory.grid(row=19, column=0)

        ball_room = BallRoom(frame)
        ball_room.grid(row=17, column=8)

        kitchen = Kitchen(frame)
        kitchen.grid(row=18, column=18)
def emit_every_time_interval(json_data, time_interval: int, kitchen: Kitchen):
    for data_object in json_data:
        order = Order(data_object)
        print(order)
        kitchen.cook_order(order)

        time.sleep(time_interval)
    return
    def __init__(self):
        self._running = True
        self._display_surf = None
        self.kitchen = Kitchen()
        self.loading_screen = LoadingScreen()

        # initialize application entities
        fb.__init__()
        sc.__init__()
    def test_write_shopping_list(sefl):

        kitchen1 = Kitchen()
        assert len(kitchen1.pantry) == 0

        # add food to pantry
        food1 = Food('food1', 'category1', 'unit1', quantity_needed_in_stock=2)
        food2 = Food('food2', 'category2', 'unit2', quantity_needed_in_stock=4)
        food3 = Food('food3',
                     'category3',
                     'unit3',
                     quantity_needed_in_stock=10)

        kitchen1.add_to_pantry(food1, quantity=1)  # in list
        kitchen1.add_to_pantry(food2, quantity=7)  # not in list
        kitchen1.add_to_pantry(food3, quantity=4)  # in list

        assert len(kitchen1.pantry) == 3

        kitchen1.make_shopping_list()
        assert len(kitchen1.shopping_list) == 2

        data = Data()
        data.write_shopping_list(kitchen1.shopping_list,
                                 'test/test_write_shopping_list.json')

        with open('test/test_write_shopping_list.json', 'r') as list_reader:
            written_list = json.loads(list_reader.read())
            assert written_list['food1'] == 1
            assert written_list['food3'] == 6
        list_reader.close()
Example #5
0
    def __init__(self):

        # kitchen and data objects
        self.data = Data()
        self.kitchen = Kitchen()
        self.kitchen.pantry = self.data.read_pantry('src/demo/pantry.json')
        self.kitchen.recipies = self.data.read_recipies(
            'src/demo/recipies.json')

        # main screen
        self.stdscr = curses.initscr()
        self.height, self.width = self.stdscr.getmaxyx()

        # windows
        self.menubar = curses.newwin(2, self.width, 0, 0)
        self.menubar.addstr("Kitman")
        self.menubar.refresh()

        self.data_window = curses.newwin(self.height - 5, (self.width // 2), 3,
                                         0)

        self.preview_window = curses.newwin(self.height - 5, self.width // 2,
                                            3, (self.width // 2))

        self.option_window = curses.newwin(2, self.width, self.height - 2, 0)

        # colors
        curses.start_color()
        curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
Example #6
0
    def __init__(self, customer_visiting_period: int):
        billing_period = 5
        cash_desk_num = 1
        cooks_num = 3
        table_quantity = 20

        self.__visiting_period = customer_visiting_period
        self.__table_manager = TableManager(table_quantity)
        self.__kitchen = Kitchen(cooks_num)
        self.__bill_manager = BillManager(billing_period, cash_desk_num)

        self.__number_of_customers = 0
        self.__waiting_customers = []

        self.__food_name = {1: "스테이크", 2: "스파게티", 3: "마카로니", 4: "그라탱"}
        self.__food_eating_time = {1: 30, 2: 20, 3: 15, 4: 10}
        self.__food_cooking_time = {1: 30, 2: 20, 3: 10, 4: 15}
Example #7
0
 def run(self):
     kitchen = Kitchen()
     kitchen.updateConfig({ "node" : self.config })
     
     if 'cookbook_path' in self.config:
         for path in self.config['cookbook_path']:
             #if "." not in path:
             #    path = os.path.join(os.path.dirname(utils.resolvePath(self.options.config)), path)
             kitchen.addCookbookPath(path)
     
     if 'recipes' in self.config:
         for recipe in self.config['recipes']:
             kitchen.includeRecipe(recipe)
     
     kitchen.run()
    def test_write_pantry(self):

        # initialize kitchen with food and recipies
        kitchen = Kitchen()

        food1 = Food(name='food1',
                     unit='unit1',
                     category='category1',
                     quantity_needed_in_stock=10)
        food2 = Food('food2',
                     'category2',
                     'unit2',
                     quantity_needed_in_stock=20)

        kitchen.add_to_pantry(food1, 10)
        kitchen.add_to_pantry(food2, 20)

        data = Data()
        data.write_pantry(kitchen.pantry, 'test/test_write_pantry.json')

        # check file for valid json objects
        with open('test/test_write_pantry.json') as file:
            json_data = json.loads(file.read())

            assert type(json_data[0]) == dict
            assert json_data[0]['_name'] == 'food1'
            assert json_data[0]['_unit'] == 'unit1'
            assert json_data[0]['_category'] == 'category1'
            assert json_data[0]['_quantity_needed_in_stock'] == 10
            assert json_data[0]['_quantity_in_stock'] == 10

            assert type(json_data[1]) == dict
            assert json_data[1]['_name'] == 'food2'
            assert json_data[1]['_unit'] == 'unit2'
            assert json_data[1]['_category'] == 'category2'
            assert json_data[1]['_quantity_needed_in_stock'] == 20
            assert json_data[1]['_quantity_in_stock'] == 20

        file.close()
Example #9
0
def setup_kitchen():
    app = Flask(__name__)
    app.config.from_mapping(LAMBDA=3.25,
                            HOT_SHELF_SIZE=15,
                            COLD_SHELF_SIZE=15,
                            FROZEN_SHELF_SIZE=15,
                            OVERFLOW_SHELF_SIZE=20,
                            JSON_FILE='test_orders.json')
    redis_store = redis.Redis(host='localhost',
                              port=6379,
                              db=0,
                              encoding='utf-8',
                              decode_responses=True)
    kitchen = Kitchen(app, redis_store)
    return kitchen
def main():
    filename = 'orders.json'
    json_data = get_json_data(read_json_file(filename))
    shelf_type_to_capacity_dict = {
        "hot": 10,
        "cold": 10,
        "frozen": 10,
        "overflow": 10
    }

    shelf = Shelf(shelf_type_to_capacity_dict=shelf_type_to_capacity_dict)
    kitchen = Kitchen(shelf=shelf)

    emit_every_time_interval(json_data, 2, kitchen)

    return
Example #11
0
    def explore_main_floor(self):

        print("Which room will you explore?")

        choice = input("> ")

        if "left" in choice or "living room" in choice:
            from living_room import LivingRoom
            LivingRoom().living_room()
        elif "right" in choice or "kitchen" in choice:
            from kitchen import Kitchen
            Kitchen().kitchen()
        elif "stairs" in choice or "up" in choice:
            from explore_upstairs import ExploreUpstairs
            ExploreUpstairs().explore()
        elif "door" in choice or "closed" in choice or "basement" in choice:
            from basement import Basement
            Basement().explore_basement()
        else:
            print("""Are you too afraid to continue? \n
            Try typing 'living room', 'basement', 'kitchen', or 'upstairs'.""")
            ExploreMainFloor().explore_main_floor()
Example #12
0
    gather_ingredients,
)

RECIPES = {
    "cheeseburger": [
        "bun-bottom",
        "lettuce-slice",
        "onion-ring",
        "tomato-slice",
        "grilled-beefpatty",
        "cheese-slice",
        "bun-top",
    ]
}

kitchen = Kitchen()


def make_burger(order):
    recipe = RECIPES[order]
    ingredients_list = ingredients_list_from_recipe(recipe)
    ingredients = gather_ingredients(ingredients_list, kitchen.pantry)
    prepared_ingredients = [
        prepare_ingerdient(ingredient, kitchen) for ingredient in ingredients
    ]
    prepared_ingredients = list(flat_generator(prepared_ingredients))
    return Burger(order, select_ingredients(recipe, prepared_ingredients))


if __name__ == "__main__":
    multiplier = int(sys.argv[2]) if len(sys.argv) > 2 else 1
Example #13
0
                loc = courtyard
            elif new_loc == "lr":
                loc = lr
            elif new_loc == "reactor":
                loc = reactor
            elif new_loc == "workshop":
                loc = workshop
            elif new_loc == "q":
                print("Exit game")
                run = False
                break
            else:
                print(new_loc)
                loc = player.location
            player.location = loc


game = Game()
armory = Armory("armory")
kitchen = Kitchen("kitchen")
entry = EntryWay("entry way")
walls = Walls("walls")
lr = LivingRoom("living room")
barracks = Barracks("barracks")
courtyard = Courtyard("courtyard")
dining = DiningRoom("dining room")
reactor = Reactor("reactor")
workshop = Workshop("workshop")
name = input("Enter name:  \n")
player = Player(name, 25, 10, courtyard)
game.main()
def main():

    print(
        "\n\n" + '\033[1m' +
        "A csipet-csapat megérkezik a Codecoolba és jó szokásukhoz híven, a konyha felé veszik az irányt."
        + '\033[0m' + "\n")

    pakko = Kitchen()
    pakko.who_is_in_the_kitchen()
    print(
        "\n" + pakko.student_in_kitchen +
        " neki áll vedelni a mogyorós kávét liter számra... Csak mert nem ő vette..."
    )
    pakko.coffee_left(3)
    pakko.fridge_space_left(60)
    pakko.pakkos_phrases()

    print(
        "\n\n" + '\033[1m' +
        "És eljött vala az idő, hogy megtekintsük, mikor lesz a következő meeting és, hogy mi lesz a téma!"
        + '\033[0m' + "\n")

    peba = Meeting()
    peba.next_meeting()
    peba.topic_generator()
    print(
        "\n\n" + '\033[1m' +
        "Miután lement a meeting, a mentoroknak eszükbe jutott, hogy fogytán a motiváció.\nMost átgondolják, hogy mikor fogja lehúzni róluk a nadrágot a sok della súlya újra. "
        + '\033[0m' + "\n")

    atesz = Salary(1)
    atesz.days_until_payday()
    atesz.warning_messages()

    print(
        "\n\n" + '\033[1m' +
        "Most, hogy a motiváció a tetőfokára hágott, a kiadandó feladatokat is megbeszélik a mentorok."
        + '\033[0m' + "\n")

    imi = Assignment("Imre")
    imi.grading_assignment("Vajnorák Zsolt")
    imi.making_assignment()
    print("")
    pakko.pakkos_phrases()

    print("\n\n" + '\033[1m' +
          "Itt a móka vége mára, induljunk hát a kocsmába.\n")
Example #15
0

def working_with_help(t):
    if 90 <= t and t <= 210:
        return 3
    if 420 <= t and t <= 540:
        return 3
    return 2


print(f'Corriendo simulacion usando lambda={l}')
times = 1000
results = []
print(f'Realizando {times} simulacion(es) sin ayudante:')
for _ in range(times):
    model = Kitchen(agen, sushitimegen, sandwichtimegen, typegen, 660, 2,
                    working)
    while model.advance():
        # input('Presione entar para continuar...')
        pass
    results.append((model.late_n * 100) / model.Nd)
prom = mean(results)
print(f'2 Empleados {prom}%')

times = 1000
results = []
print(f'Realizando {times} simulacion(es) con ayudante:')
for _ in range(times):
    model = Kitchen(agen, sushitimegen, sandwichtimegen, typegen, 660, 3,
                    working_with_help)
    while model.advance():
        # input('Presione entar para continuar...')
Example #16
0
class Restaurant:
    def __init__(self, customer_visiting_period: int):
        billing_period = 5
        cash_desk_num = 1
        cooks_num = 3
        table_quantity = 20

        self.__visiting_period = customer_visiting_period
        self.__table_manager = TableManager(table_quantity)
        self.__kitchen = Kitchen(cooks_num)
        self.__bill_manager = BillManager(billing_period, cash_desk_num)

        self.__number_of_customers = 0
        self.__waiting_customers = []

        self.__food_name = {1: "스테이크", 2: "스파게티", 3: "마카로니", 4: "그라탱"}
        self.__food_eating_time = {1: 30, 2: 20, 3: 15, 4: 10}
        self.__food_cooking_time = {1: 30, 2: 20, 3: 10, 4: 15}

    def is_possible_to_wait(self, new_customer: Customer) -> bool:

        n = 0
        lower_time_group = []
        higher_time_group = []

        for table in self.__table_manager.get_table_queue():
            remaining_time = table.get_total_time() - (
                table.get_elapsed_waited_time_for_food() +
                table.get_elapsed_eating_time())

            if remaining_time < new_customer.get_maximum_waiting_time():
                n += 1
                lower_time_group.append(remaining_time)
            else:
                higher_time_group.append(remaining_time)

        if self.__waiting_customers:
            if len(self.__waiting_customers) < n:
                new_customer.set_remaining_time_by_new_table(
                    sorted(lower_time_group)[len(self.__waiting_customers)])
                return True

        else:
            if 1 <= n:
                new_customer.set_remaining_time_by_new_table(
                    min(lower_time_group))
                return True

        applicable_index = sorted(higher_time_group)[
            len(self.__waiting_customers) - n]
        new_customer.set_remaining_time_by_new_table(applicable_index)
        return False

    def customer_visiting(self, elapsed_time: int):
        self.__number_of_customers += 1
        new_customer = Customer(self.__number_of_customers, elapsed_time)

        print(
            f"{self.__number_of_customers}번째 손님이 시각 {elapsed_time} 분에 레스토랑에 도착했습니다."
        )
        return new_customer

    def get_time_until_being_allocated_to_cook(self) -> int:
        result = 0
        q = self.__kitchen.get_order_queue()
        if q:
            q = [self.__food_cooking_time[order[0]] for order in q]
            group = self.__kitchen.get_cooks_current_cooking_time()
            q.append(0)

            while q:
                group.sort()
                target = group.pop(0)
                result += target
                group = [i - target for i in group]

                group.append(q.pop(0))
        return result

    def customer_entrance(self, customer: Customer):

        food_num = randrange(1, 5)
        food_eating_time = self.__food_eating_time[food_num]
        food_cooking_time = self.__food_cooking_time[food_num]
        customer.set_attribute((food_num, food_eating_time, food_cooking_time))

        table_num = self.__table_manager.set_customer(customer)
        customer_number = customer.get_customer_number()
        time_until_being_allocated_to_cook = self.get_time_until_being_allocated_to_cook(
        )

        customer.set_total_time(time_until_being_allocated_to_cook +
                                customer.get_food_cooking_time() +
                                customer.get_food_eating_time())

        print(f"{customer_number}번 손님이 {table_num}번 테이블에 앉습니다.")
        print(f"{customer_number}번 손님이 {food_num}번 요리"
              f" ({self.__food_name[food_num]})를 주문합니다.")

        self.__kitchen.get_order_from_new_customer(customer, table_num)

    def receive_customer(self, customer: Customer):
        self.__waiting_customers.append(customer)

    def pop_waiting_queue(self, pop_count: int):

        if pop_count != 0:
            for _ in range(pop_count):
                self.__waiting_customers.pop(0)

    def waiting_update(self):
        if self.__waiting_customers:
            customer_count = 0

            for customer in self.__waiting_customers:
                customer.waiting_update()

            for customer in self.__waiting_customers:

                if customer.get_elapsed_waiting_time(
                ) < customer.get_remaining_time_by_new_table():
                    break

                if customer.get_elapsed_waiting_time(
                ) == customer.get_remaining_time_by_new_table(
                ) and not self.__table_manager.is_table_full():
                    self.customer_entrance(customer)
                    customer_count += 1

            self.pop_waiting_queue(customer_count)

    def run(self):

        elapsed_time = 0

        while elapsed_time < 720:

            elapsed_time += 1

            table_target_customer_queue = self.__table_manager.update()
            for customer in table_target_customer_queue:
                self.__bill_manager.receive_customer(customer)

            self.__bill_manager.update()

            if self.__table_manager.is_exist():
                finished_order_queue = self.__kitchen.update()

                if finished_order_queue:
                    for order in finished_order_queue:
                        self.__table_manager.getting_food(order)

            self.waiting_update()

            if elapsed_time % self.__visiting_period == 0:
                new_customer = self.customer_visiting(elapsed_time)

                if self.__table_manager.is_table_full():
                    if self.is_possible_to_wait(new_customer):

                        self.receive_customer(new_customer)
                    else:
                        print(
                            f"손님이 기다릴 수 없어 돌아갑니다.\n현재 대기 시간 {new_customer.get_elapsed_waiting_time()}분 / 대기 가능 시간 "
                            f"{new_customer.get_remaining_time_by_new_table()}분"
                        )

                else:
                    self.customer_entrance(new_customer)

            self.__kitchen.start_cooking_update()
Example #17
0
        return orders, repeated_kitchens
    else:
        return orders, kitchens[: len(orders)]


def make_burger(order, kitchen):
    recipe = RECIPES[order]
    ingredients_list = ingredients_list_from_recipe(recipe)
    ingredients = gather_ingredients(ingredients_list, kitchen.pantry)
    prepared_ingredients = [prepare_ingerdient(ingredient, kitchen) for ingredient in ingredients]
    prepared_ingredients = list(flat_generator(prepared_ingredients))
    return Burger(order, select_ingredients(recipe, prepared_ingredients))


if __name__ == "__main__":
    multiplier = int(sys.argv[2]) if len(sys.argv) > 2 else 1
    orders = multiplier * sys.argv[1].split(",")

    kitchens = cpu_count() * [Kitchen()]

    start_time = time.time()
    with Pool(len(kitchens)) as pool:
        args = zip(*pair_orders_kitchens(orders, kitchens))
        burgers = pool.starmap(make_burger, args)

    for order, burger in zip(orders, burgers):
        burger.taste(RECIPES[order])
        print(f"You can eat your delicious '{burger}'")

    print(f"Delivered {len(orders)} burgers in {time.time()-start_time}s")
class App:

    won_img = "../imgs/game_won.jpg"
    __DISPLAY_TIME__ = 5
    TOP_LEFT_X = 0
    TOP_LEFT_Y = 0

    def __init__(self):
        self._running = True
        self._display_surf = None
        self.kitchen = Kitchen()
        self.loading_screen = LoadingScreen()

        # initialize application entities
        fb.__init__()
        sc.__init__()

    def on_init(self):
        init()

        # initialize class variables
        self._display_surf = display.set_mode(
            (su.WINDOW_WIDTH, su.WINDOW_HEIGHT), HWSURFACE)
        self.kitchen.on_init()
        self.loading_screen.on_init()
        self._running = True

        fb.on_init()
        sc.on_init()

    def on_event(self, keys, event):
        if keys[K_ESCAPE]:
            self._running = False
        else:
            self.kitchen.on_event(keys)
            sc.on_event(keys, event)

    def on_loop(self):
        self.kitchen.on_loop()
        sc.on_loop()

    def on_render(self):
        # TODO: should kitchen only render once?
        self.kitchen.on_render(self._display_surf)
        sc.on_render(self._display_surf)
        fb.on_render(self._display_surf)
        # update display to register all changes
        display.flip()

    def game_won(self):
        win_screen = image.load(self.won_img)
        self._switch_to_screen(win_screen, self._display_surf)
        sleep(self.__DISPLAY_TIME__)

    def _switch_to_screen(self, screen, surface):
        surface.blit(screen, (self.TOP_LEFT_X, self.TOP_LEFT_Y))
        display.flip()

    def on_cleanup(self):
        quit()

    def on_execute(self):
        global game_state

        if self.on_init() is False:
            self._running = False

        # run and unload loading screen
        su.game_state = su.GameState.LOADING
        self.loading_screen.run(self._display_surf)
        self.loading_screen = None
        # Displays intro message
        fb.show_info_feedback(WELCOME)

        su.game_state = su.GameState.MAIN_LOOP
        while (self._running and su.game_state == su.GameState.MAIN_LOOP):
            event.pump()
            keys = key.get_pressed()

            self.on_event(keys, event)
            self.on_loop()
            self.on_render()

        if su.game_state == su.GameState.WON:
            self.game_won()

        self.on_cleanup()
Example #19
0
    def __init__(self):
        bathroom = Bathroom()
        bedroom = Kitchen()
        pantry = Pantry()

        self.rooms = [bathroom, bedroom, pantry]
Example #20
0
#!/usr/bin/python

import argparse
from kitchen import Kitchen

arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("-of",
                        "--orders_file",
                        help="order json file",
                        required=True)
arg_parser.add_argument(
    "-op",
    "--orders_per_second",
    help="how many orders per second to send to kitchen, default is 2")
args = arg_parser.parse_args()
ORDERS_PER_SECOND = 2

if __name__ == '__main__':
    orders_per_second = ORDERS_PER_SECOND
    if args.orders_per_second:
        orders_per_second = float(args.orders_per_second)
    Kitchen(args.orders_file, orders_per_second).start()
Example #21
0
def stream_orders():
    kitchen = Kitchen(app, redis_store)
    return Response(
        stream_template(app, 'index.html', data=kitchen.stream_orders()))
Example #22
0
def queue_orders():
    kitchen = Kitchen(app, redis_store)
    size = kitchen.queue_orders()

    return str(size) + ' orders queued'
Example #23
0
from office import Office
from thirdBathroom import ThirdBathroom
from hiddenRoom import HiddenRoom
from darkHallway import DarkHallway
from musicRoom import MusicRoom
from library import Library
from servantQuarters import ServantQuarters
from livingRoom import LivingRoom
from hallway import Hallway

# ------------------------------------------------------------+
# First Floor Map -- Pedro's rooms
Entrance = Entrance(0, 0)
TeaRoom = TeaRoom(0, 1)
GuestBathroom = GuestBathroom(1, 0)
Kitchen = Kitchen(1, 1)
Garage = Garage(1, 2)
row1 = [Entrance, TeaRoom]
row2 = [GuestBathroom, Kitchen, Garage]
floor1_map = [row1, row2]
# ------------------------------------------------------------+
# ------------------------------------------------------------+
# Second Floor Map -- Jason's rooms
# row1 = [LivingRoom(0, 0), DarkHallway(0, 1)]
# row2 = [ServantQuarters(1, 0), MusicRoom(1, 1), Library(1, 2)]
LivingRoom = LivingRoom(0, 0)
DarkHallway = DarkHallway(0, 1)
ServantQuarters = ServantQuarters(1, 0)
MusicRoom = MusicRoom(1, 1)
Library = Library(1, 2)
row1 = [LivingRoom, DarkHallway]