2020 fall basic implem with best available recipe
This commit is contained in:
parent
a55394ce5d
commit
9edf191bc1
1 changed files with 52 additions and 35 deletions
|
@ -1,44 +1,61 @@
|
||||||
import sys
|
import sys
|
||||||
import math
|
import math
|
||||||
|
|
||||||
# Auto-generated code below aims at helping you parse
|
|
||||||
# the standard input according to the problem statement.
|
def debug(*args, **kwargs):
|
||||||
|
print(*args, file=sys.stderr, flush=True, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
# game loop
|
def is_doable(inventory, recipe_delta):
|
||||||
while True:
|
for inv, rec in zip(inventory, recipe_delta):
|
||||||
action_count = int(input()) # the number of spells and recipes in play
|
if inv + rec < 0:
|
||||||
for i in range(action_count):
|
return False
|
||||||
# action_id: the unique ID of this spell or recipe
|
return True
|
||||||
# action_type: in the first league: BREW; later: CAST, OPPONENT_CAST, LEARN, BREW
|
|
||||||
# delta_0: tier-0 ingredient change
|
|
||||||
# delta_1: tier-1 ingredient change
|
def main():
|
||||||
# delta_2: tier-2 ingredient change
|
# game loop
|
||||||
# delta_3: tier-3 ingredient change
|
while True:
|
||||||
# price: the price in rupees if this is a potion
|
action_count = int(input()) # the number of spells and recipes in play
|
||||||
# tome_index: in the first two leagues: always 0; later: the index in the tome if this is a tome spell, equal to the read-ahead tax
|
recipes = []
|
||||||
# tax_count: in the first two leagues: always 0; later: the amount of taxed tier-0 ingredients you gain from learning this spell
|
for i in range(action_count):
|
||||||
# castable: in the first league: always 0; later: 1 if this is a castable player spell
|
# action_id: the unique ID of this spell or recipe
|
||||||
# repeatable: for the first two leagues: always 0; later: 1 if this is a repeatable player spell
|
# action_type: in the first league: BREW; later: CAST, OPPONENT_CAST, LEARN, BREW
|
||||||
action_id, action_type, delta_0, delta_1, delta_2, delta_3, price, tome_index, tax_count, castable, repeatable = input().split()
|
# delta_0: tier-0 ingredient change
|
||||||
action_id = int(action_id)
|
# delta_1: tier-1 ingredient change
|
||||||
delta_0 = int(delta_0)
|
# delta_2: tier-2 ingredient change
|
||||||
delta_1 = int(delta_1)
|
# delta_3: tier-3 ingredient change
|
||||||
delta_2 = int(delta_2)
|
# price: the price in rupees if this is a potion
|
||||||
delta_3 = int(delta_3)
|
# tome_index: in the first two leagues: always 0; later: the index in the tome if this is a tome spell, equal to the read-ahead tax
|
||||||
price = int(price)
|
# tax_count: in the first two leagues: always 0; later: the amount of taxed tier-0 ingredients you gain from learning this spell
|
||||||
tome_index = int(tome_index)
|
# castable: in the first league: always 0; later: 1 if this is a castable player spell
|
||||||
tax_count = int(tax_count)
|
# repeatable: for the first two leagues: always 0; later: 1 if this is a repeatable player spell
|
||||||
castable = castable != "0"
|
action_id, action_type, delta_0, delta_1, delta_2, delta_3, price, tome_index, tax_count, castable, repeatable = input().split()
|
||||||
repeatable = repeatable != "0"
|
action_id = int(action_id)
|
||||||
for i in range(2):
|
delta = [int(delta_0), int(delta_1), int(delta_2), int(delta_3)]
|
||||||
# inv_0: tier-0 ingredients in inventory
|
price = int(price)
|
||||||
# score: amount of rupees
|
recipes.append({"price": price, "delta": delta, "action_id": action_id, "action_type": action_type})
|
||||||
|
tome_index = int(tome_index)
|
||||||
|
tax_count = int(tax_count)
|
||||||
|
castable = castable != "0"
|
||||||
|
repeatable = repeatable != "0"
|
||||||
|
|
||||||
|
recipes.sort(reverse=True, key=lambda x: x["price"])
|
||||||
|
|
||||||
inv_0, inv_1, inv_2, inv_3, score = [int(j) for j in input().split()]
|
inv_0, inv_1, inv_2, inv_3, score = [int(j) for j in input().split()]
|
||||||
|
my_inventory = [inv_0, inv_1, inv_2, inv_3]
|
||||||
|
my_score = score
|
||||||
|
inv_0, inv_1, inv_2, inv_3, score = [int(j) for j in input().split()]
|
||||||
|
enemy_inventory = [inv_0, inv_1, inv_2, inv_3]
|
||||||
|
enemy_score = score
|
||||||
|
|
||||||
# Write an action using print
|
debug(f"{my_inventory}, {recipes}")
|
||||||
# To debug: print("Debug messages...", file=sys.stderr, flush=True)
|
for recipe in recipes:
|
||||||
|
if is_doable(my_inventory, recipe["delta"]):
|
||||||
|
print(f"BREW {recipe['action_id']}")
|
||||||
|
continue
|
||||||
|
print("WAIT")
|
||||||
|
|
||||||
|
|
||||||
# in the first league: BREW <id> | WAIT; later: BREW <id> | CAST <id> [<times>] | LEARN <id> | REST | WAIT
|
if __name__ == "__main__":
|
||||||
print("BREW 0")
|
main()
|
||||||
|
|
Loading…
Reference in a new issue