コード例 #1
0
def simulate_n_customers(n):
    '''
    Simulate n customers that start together in the store.
    No new customers are added over time.
    The simulation ends once all are checked out.
    '''
    background = np.zeros((700, 1000, 3), np.uint8)
    market = SupermarketMap(MARKET, TILES)
    supermarket = Supermarket(market=market)
    for _ in range(n):
        supermarket.add_new_customers()
    frame = background.copy()

    while len(supermarket.customers) > 0:
        if supermarket.customers_to_move:
            move_between_minutes(market, supermarket, frame)
        else:
            go_to_next_minute(market, supermarket, frame)
        cv2.imshow("frame", frame)

        key = chr(cv2.waitKey(1) & 0xFF)
        if key == 'q':
            break
    cv2.destroyAllWindows()
    market.write_image("./graphics/supermarket.png")
コード例 #2
0
def simulate_n_customers(n):
    '''
  Simulate n customers that start together in the store.
  No new customers are added over time.
  The simulation ends once all are checked out.
  '''
    supermarket = Supermarket()
    for _ in range(n):
        supermarket.add_new_customers()

    while len(supermarket.customers) > 0:
        go_to_next_minute(supermarket)