Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from dataclasses import dataclass, field
- from typing import List
- def idebug(*args):
- return
- print(*args, file=sys.stderr, flush=True)
- def debug(*args):
- # return
- print(*args, file=sys.stderr, flush=True)
- # Cells
- ME = '0'
- PARTNER = '1'
- FLOOR = "." # case de sol
- TABLE = "#" # table de travail
- DISHWASHER = "D" # le lave-vaisselle
- WINDOW = "W" # la fenêtre de clients
- BLUEBERRIES_CRATE = "B" # la corbeille de myrtilles
- ICE_CREAM_CRATE = "I" # la corbeille de crème glacée
- STRAWBERRIES_CRATE = "S" # la corbeille de fraises
- DOUGH_CRATE = "H" # la corbeille de pâte
- CHOPPING_BOARD = "C" # la planche à découper
- OVEN = "O" # le four
- # Items
- NONE = "NONE"
- DISH = "DISH"
- # Desserts de base
- ICE_CREAM = "ICE_CREAM"
- BLUEBERRIES = "BLUEBERRIES"
- STRAWBERRIES = "STRAWBERRIES"
- # Desserts classiques
- CHOPPED_STRAWBERRIES = "CHOPPED_STRAWBERRIES"
- DOUGH = "DOUGH" # Ingrédient
- CROISSANT = "CROISSANT"
- # Dessert avancé
- CHOPPED_DOUGH = "CHOPPED_DOUGH" # Ingrédient
- RAW_TART = "RAW_TART" # Ingrédient
- TART = "TART" # tarte aux myrtilles
- @dataclass
- class Item:
- content: str
- has_plate: bool = field(init=False)
- def __post_init__(self):
- self.has_plate = DISH in self.content
- @dataclass
- class Position:
- x: int
- y: int
- def manhattan(self, pos):
- return (self.x - pos.x) + (self.y - pos.y)
- def __repr__(self):
- return f'{self.x} {self.y}'
- @dataclass
- class Player:
- pos: Position
- item: Item
- def update(self, pos: Position, item: Item):
- self.pos, self.item = pos, item
- @dataclass
- class Table:
- pos: Position
- has_function: bool
- item: Item = field(init=False)
- def __post_init__(self):
- self.item = None
- @dataclass
- class Game:
- Dishwasher: Table
- Window: Table
- Blueberry: Table
- IceCream: Table
- players: List[Player] = field(init=False)
- tables: List[Table] = field(init=False)
- def __post_init__(self):
- self.players, self.tables = [], []
- def init(self):
- # ALL CUSTOMERS INPUT: to ignore until bronze
- num_all_customers = int(input())
- idebug(num_all_customers)
- for i in range(num_all_customers):
- # customer_item: the food the customer is waiting for
- # customer_award: the number of points awarded for delivering the food
- customer_item, customer_award = input().split()
- idebug(customer_item, customer_award)
- for i in range(7):
- kitchen_line = input()
- for x in range(11):
- if kitchen_line[x] == 'W':
- self.Window = Table(pos=Position(x, i), has_function=True)
- elif kitchen_line[x] == 'D':
- self.Dishwasher = Table(pos=Position(x, i), has_function=True)
- elif kitchen_line[x] == 'I':
- self.IceCream = Table(pos=Position(x, i), has_function=True)
- elif kitchen_line[x] == 'B':
- self.Blueberry = Table(pos=Position(x, i), has_function=True)
- elif kitchen_line[x] == '#':
- self.tables.append(Table(pos=Position(x, i), has_function=False))
- def update(self):
- turns_remaining = int(input())
- inputs = input().split()
- player_x = int(inputs[0])
- player_y = int(inputs[1])
- player_item = inputs[2]
- inputs = input().split()
- partner_x = int(inputs[0])
- partner_y = int(inputs[1])
- partner_item = inputs[2]
- self.players.append(Player(pos=Position(player_y, player_x), item=Item(content=player_item)))
- self.players.append(Player(pos=Position(partner_x, partner_y), item=Item(content=partner_item)))
- num_tables_with_items = int(input()) # the number of tables in the kitchen that currently hold an item
- for i in range(num_tables_with_items):
- inputs = input().split()
- table_x = int(inputs[0])
- table_y = int(inputs[1])
- item = inputs[2]
- table: Table = [t for t in self.tables if t.pos == Position(table_x, table_y)][0]
- table.item = Item(content=item)
- inputs = input().split()
- oven_contents = inputs[0] # ignore until wood 1 league
- oven_timer = int(inputs[1])
- num_customers = int(input()) # the number of customers currently waiting for food
- for i in range(num_customers):
- inputs = input().split()
- customer_item = inputs[0]
- customer_award = int(inputs[1])
- def move(self, pos: Position):
- print(f'MOVE {pos}')
- def use(self, pos: Position):
- print(f'USE {pos}')
- def play(self):
- myChef: Player = self.players[0]
- # GAME LOGIC
- # fetch a dish, pick ice cream and drop the dish on an empty table
- if not myChef.item or not myChef.item.has_plate:
- self.use(self.Dishwasher.pos)
- elif ICE_CREAM not in myChef.item.content:
- self.use(self.IceCream.pos)
- else:
- # once ready, put it on the first empty table for now
- table: Table = [t for t in self.tables if not t.item][0]
- self.use(table.pos)
- g: Game = Game(Dishwasher=None, Window=None, Blueberry=None, IceCream=None)
- g.init()
- # game loop
- while True:
- g.update()
- g.play()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement