Ejemplo n.º 1
0
def find_upgrades(game):
    state = game.game_state
    plans = []
    COST = {  # todo get
        'Caretaker': 3500,
        'SolarPanel': 6800,
        'Insulation': 7200,
        'Playground': 5200,
        'Charger': 3400,
        'Regulator': 1250
    }
    for residence in state.residences:
        if residence.building_name in SETTINGS.UPGRADE.PRIORITY:
            for priority, upgrade_name in enumerate(
                    SETTINGS.UPGRADE.PRIORITY[residence.building_name]):
                if upgrade_name not in residence.effects:
                    if upgrade_name == 'Charger' and SETTINGS.UPGRADE.CHARGER_ONLY_ON_MALL and 'Mall.2' not in residence.effects:
                        continue
                    score = 10.0 - priority
                    plan = Plan(Urgency.UPGRADE, score)
                    if state.funds >= SETTINGS.UPGRADE.FUNDS_THRESHOLD and state.funds >= COST[
                            upgrade_name]:  # never will happen with high threshold
                        plans.append(
                            plan.upgrade((residence.X, residence.Y),
                                         upgrade_name).remember_count(
                                             memory, 'upgrade', upgrade_name))
                    elif SETTINGS.UPGRADE.WAIT_FOR_UPGRADE:
                        plans.append(plan.wait())
    return plans
Ejemplo n.º 2
0
 def find(priorities, urgency):
     if residence.building_name in priorities:
         for priority, upgrade_name in enumerate(
                 priorities[residence.building_name]):
             if upgrade_name not in residence.effects:
                 if upgrade_name in SETTINGS.UPGRADE.DELAY and state.turn < SETTINGS.UPGRADE.DELAY[
                         upgrade_name]:
                     continue
                 score = SCORE_BASE - priority
                 plan = Plan(urgency, score)
                 if upgrade_name == 'Regulator' and residence.temperature > SETTINGS.UPGRADE.REGULATOR_TEMP:
                     plan.urgency = Urgency.MAJOR_ADJUST_ENERGY
                     plan.score = SCORE_BASE + residence.temperature
                 elif upgrade_name == 'Charger' and SETTINGS.UPGRADE.CHARGER_PRIO_ON_MALL and 'Mall.2' in residence.effects:
                     plan.urgency = Urgency.MAJOR_UPGRADE
                     plan.score = SCORE_BASE + residence.current_pop
                 if state.funds >= COST[upgrade_name] and (
                         state.funds >= SETTINGS.UPGRADE.FUNDS_THRESHOLD
                         or len(memory['planned_buildings']) == 0):
                     plans.append(
                         plan.upgrade((residence.X, residence.Y),
                                      upgrade_name).remember_count(
                                          memory, 'upgrade', upgrade_name))
                 elif SETTINGS.UPGRADE.SAVE_FOR_UPGRADE:
                     plans.append(plan.wait())