コード例 #1
0
def randomly_fit(race,constraints):
    """
    Returns a random build order that fits the given constraints or fills supply
    Constraints is a frozen set with elements (UNIT, COUNT)
    """
    set_up(constraints, race)
    order = Order(race = race, calc = False)
    order.evaluate()
    while not has_constraints(order.at_time[-1],constraints) and order.at_time[-1].supply < 200:
        choice = random.choice([i for i in order.at_time[-1].all_available() if helps(i,constraints)])
        if events[choice].get_result() == boost:
            pass # caring to allow for chrono boost during random fit would require even more calculation
        else:
            order.append([choice,''],recalc = False,remember = False)
            order.evaluate() # not verified
    return order