def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') logging.info('building tree') snipe_plan = Sequence(name='Snipe Strategy') snipe_available_check = Check(snipe_available) snipe_attack = Action(snipe_boi) snipe_plan.child_nodes = [snipe_available_check, snipe_attack] offensive_plan = Sequence(name='Offensive Strategy') largest_fleet_check = Check(have_largest_fleet) attack = Action(attack_weakest_enemy_planet) offensive_plan.child_nodes = [largest_fleet_check, attack] spread_sequence = Sequence(name='Spread Strategy') neutral_planet_check = Check(if_neutral_planet_available) spread_action = Action(spread_to_best_neutral) spread_sequence.child_nodes = [neutral_planet_check, spread_action] defense_plan = Sequence(name='Defensive Strategy') defend_boi_check = Check(defend_boi_available) defend_action = Action(defend_boi) defense_plan.child_nodes = [defend_boi_check, defend_action] ''' snipe_plan, ''' root.child_nodes = [ defense_plan, snipe_plan, offensive_plan, spread_sequence, attack.copy() ] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') defensive_plan = Sequence(name='Defensive Strategy') planet_number_check = Check(have_more_planets) defend_action = Action(defend) defensive_plan.child_nodes = [planet_number_check, defend_action] offensive_plan = Sequence(name='Offensive Strategy') largest_fleet_check = Check(have_largest_fleet) attack = Action(attack_weakest_enemy_planet) offensive_plan.child_nodes = [largest_fleet_check, attack] spread_sequence = Sequence(name='Spread Strategy') neutral_planet_check = Check(if_neutral_planet_available) spread_action = Action(spread) spread_sequence.child_nodes = [neutral_planet_check, spread_action] increase_planet_growth = Sequence(name='Must construct additional pylons') growth_check = Check(need_growth) grow = Action(grow_planet) growth_plan.child_nodes = [growth_check, grow] root.child_nodes = [ defensive_plan, offensive_plan, spread_sequence, attack.copy() ] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') offensive_plan = Sequence(name='Offensive Strategy') largest_fleet_check = Check(have_largest_fleet) attack_choice = Selector(name='Attack Method') attack_growth = Action(attack_highest_growth) attack_closest = Action(attack_nearest_enemy_planet) attack_weakest = Action(attack_weakest_enemy_planet) attack_choice.child_nodes = [attack_growth, attack_closest, attack_weakest] offensive_plan.child_nodes = [largest_fleet_check, attack_choice] spread_sequence = Sequence(name='Spread Strategy') neutral_planet_check = Check(if_neutral_planet_available) spread_action = Action(spread_to_nearest_neutral_planet) spread_sequence.child_nodes = [neutral_planet_check, spread_action] defense_sequence = Sequence(name='Defense Strategy') multiple_planet_check = Check(if_have_multiple_planets) redistribute_action = Action(strongest_to_weakest) defense_sequence.child_nodes = [multiple_planet_check, redistribute_action] root.child_nodes = [ offensive_plan, spread_sequence, defense_sequence, attack_closest.copy() ] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') defensive_plan = Sequence(name='Defensive Strategy') attacked_check = Check(is_being_attacked) defend = Action(defend_planet_attack) defensive_plan.child_nodes = [attacked_check, defend] spread_sequence = Sequence(name='Spread Strategy') neutral_planet_check = Check(if_neutral_planet_available) spread_action = Action(spread_to_closest_neutral_planet) spread_sequence.child_nodes = [neutral_planet_check, spread_action] offensive_plan = Sequence(name="Offensive Strategy") largest_fleet_check = Check(have_largest_fleet) attack = Action(attack_weakest_enemy_planet) offensive_plan.child_nodes = [largest_fleet_check, attack] root.child_nodes = [ offensive_plan, defensive_plan, spread_sequence, attack.copy() ] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') offensive_plan = Sequence(name='Offensive Strategy') largest_fleet_check = Check(have_largest_fleet) attack_action = Action(attack) offensive_plan.child_nodes = [largest_fleet_check, attack_action] spread_sequence = Sequence(name='Spread Strategy') neutral_planet_check = Check(if_neutral_planet_available) spread_action = Action(spread) spread_sequence.child_nodes = [neutral_planet_check, spread_action] defense_plan = Sequence(name='Defense Strategy') defense_check = Check(have_weak_planets) defense_action = Action(defend) defense_plan.child_nodes = [defense_check, defense_action] desperado_plan = Sequence(name='Desperado Strategy') under_attack_check = Check(planet_under_attack) attack_desperado_action = Action(desperado_attack) desperado_plan.child_nodes = [under_attack_check, attack_desperado_action] root.child_nodes = [ offensive_plan, defense_plan, spread_sequence, attack_action.copy() ] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') # Define available actions to take. colonize = Action(take_defenseless_territory) invade = Action(attack_with_no_mercy) reinforce = Action(reinforce_with_vengeance) retaliate = Action(retaliate_with_fury) # *** Begin preliminary suprise invasion over the galaxy. *** imperial_ambition = Sequence(name='Expansion Strategy: Manifest Destiny') imperial_ambition.child_nodes = [colonize, invade] # *** Consolidate and retaliate if under attack by hostiles. *** imperial_shield = Sequence(name='Security Strategy: Cereberus') danger_check = Check(if_under_attack) imperial_shield.child_nodes = [danger_check, reinforce, retaliate] # *** If the advantage is ours, attack with full force. *** imperial_aggression = Sequence(name='Aggressive Strategy: Crush All Remaining Resistance') largest_fleet_check = Check(have_largest_fleet) imperial_aggression.child_nodes = [largest_fleet_check, invade] # Begin selecting strategies. root.child_nodes = [imperial_ambition, imperial_aggression, imperial_shield, invade.copy()] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') spread_out_plan = Sequence(name='Spread Out Strategy') spread_out_attack = Action(wide_spread) spread_out_plan.child_nodes = [spread_out_attack] defense = Action(defend) close_enemy_planet_attack = Action(attack_close_enemy_planet) close_neutral_planet_attack = Action(attack_close_neutral_planet) offensive_plan = Sequence(name='Offensive Strategy') largest_fleet_check = Check(have_largest_fleet) attack = Action(attack_weakest_enemy_planet) offensive_plan.child_nodes = [largest_fleet_check, attack] spread_sequence = Sequence(name='Spread Strategy') neutral_planet_check = Check(if_neutral_planet_available) spread_action = Action(spread_to_weakest_neutral_planet) spread_sequence.child_nodes = [neutral_planet_check, spread_action] root.child_nodes = [ defense, spread_out_plan, close_enemy_planet_attack, close_neutral_planet_attack, offensive_plan, spread_sequence, attack.copy() ] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') oppression = Sequence(name="Oppression") alpha_check = Check(apex) plan_alpha = Action(order_alpha) oppression.child_nodes = [alpha_check, plan_alpha] offensive_plan = Sequence(name='Offensive Strategy') largest_fleet_check = Check(have_largest_fleet) attack = Action(attack_plan) offensive_plan.child_nodes = [largest_fleet_check, attack] deny_sequence = Sequence(name='Deny Strategy') neutral_planet_check = Check(if_neutral_planet_available) deny_plan = Action(deny_enemy_fleet) s_plan = Action(spread_plan) deny_sequence.child_nodes = [neutral_planet_check, deny_plan] root.child_nodes = [offensive_plan, deny_sequence, oppression, attack.copy()] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): logging.debug("setting up tree") # Top-down construction of behavior tree root = Sequence(name='Defensive and Origional Root') root2 = Selector(name='High Level Ordering of Strategies') logging.debug("roots are set up") defensive_plan = Sequence(name='Defensive Strategy') logging.debug("defensive plan is created") has_planets = Check(has_multiple_planets) #logging.debug("defensive plan is created") defend = Action(defend_planets) #logging.debug("defensive plan is created") defensive_plan.child_nodes = [has_planets, defend] #logging.debug("defensive plan is created") offensive_plan = Sequence(name='Offensive Strategy') largest_fleet_check = Check(have_largest_fleet) attack = Action(attack_strongest_enemy_planet) offensive_plan.child_nodes = [largest_fleet_check, attack] logging.debug("offensive plan is created") spread_sequence = Sequence(name='Spread Strategy') neutral_planet_check = Check(if_neutral_planet_available) spread_action = Action(spread_to_highest_producer) spread_sequence.child_nodes = [neutral_planet_check, spread_action] logging.debug("spread plan is created") root2.child_nodes = [offensive_plan, spread_sequence, attack.copy()] root.child_nodes = [root2, defensive_plan] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') # Checks largest_fleet_check = Check(have_largest_fleet) enemy_planet_check = Check(if_enemy_planet_available) neutral_planet_check = Check(if_neutral_planet_available) # Spread to weakest neutral spread_orig = Sequence(name='Spread Original') # spread_orig = Selector(name='Spread Original') spread_orig_action = Action(spread_to_weakest_neutral_planet) spread_orig.child_nodes = [spread_orig_action] # Spread vanilla spread_vanilla_plan = Sequence(name='Spread Vanilla') # spread_vanilla_plan = Selector(name='Spread Vanilla') spread_vanilla_action = Action(spread_vanilla) spread_vanilla_plan.child_nodes = [spread_vanilla_action] # Spread to high growth rate spread_hgr_plan = Sequence(name='Spread High Growth Rate') # spread_hgr_plan = Selector(name='Spread High Growth Rate') spread_hgr_action = Action(spread_to_highest_growth_rate) spread_hgr_plan.child_nodes = [spread_hgr_action] # Spread default spread_def_plan = Sequence(name='Spread Default') # spread_def_plan = Selector(name='Spread Default') spread_def_action = Action(spread_default) spread_def_plan.child_nodes = [spread_def_action] # Attack Vanilla attack_plan = Sequence(name='Attack Vanilla') # attack_plan = Selector(name='Attack Vanilla') attack_action = Action(attack_vanilla) attack_plan.child_nodes = [attack_action] # Attack high growth rate attack_hgr_plan = Sequence(name='Attack High Growth Rate') # attack_hgr_plan = Selector(name='Attack High Growth Rate') attack_hgr_action = Action(attack_high_growth) attack_hgr_plan.child_nodes = [attack_hgr_action] # Attack-full attack_full = Sequence(name='Attack Full Sequence') attack_full.child_nodes = [largest_fleet_check, enemy_planet_check, attack_plan, attack_hgr_plan] # Spread-full spread_full = Sequence(name='Spread Full Sequence') spread_full.child_nodes = [neutral_planet_check, spread_def_plan, spread_hgr_plan, spread_vanilla_plan, spread_orig] root.child_nodes = [attack_full, spread_full, attack_action.copy(), attack_hgr_action.copy(), spread_vanilla_action.copy(), spread_orig_action.copy(), spread_def_action.copy(), spread_hgr_action.copy()] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): logging.info('Setting Up Behavior Tree') # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') logging.info('Root Defined') play_offensively = Sequence(name='Offensive Tactics') winning_check = Check(have_most_planets) play_defensively = Sequence(name='Defensive Tactics') losing_check = Check(have_least_planets) logging.info('Offensive - Defensive Check Defined') early_occupy = Sequence(name='Early Occupation of Neutrals') owned_planets_check = Check(low_planets_check) occupy = Action(occupy_nearest_neutral_planet) early_occupy.child_nodes = [owned_planets_check, occupy] logging.info('Occupation Strategy Defined') offensive_plan = Sequence(name='Offensive Strategy') largest_fleet_check = Check(have_largest_fleet) attack = Action(attack_weakest_enemy_planet) offensive_plan.child_nodes = [largest_fleet_check, attack] logging.info('Offensive Strategy Defined') spread_sequence = Sequence(name='Spread Strategy') neutral_planet_check = Check(if_neutral_planet_available) spread_action = Action(spread_to_weakest_neutral_planet) spread_sequence.child_nodes = [neutral_planet_check, spread_action] logging.info('Spread Sequence Defined') defensive_plan = Sequence(name='Defensive Strategy') smallest_fleet_check = Check(have_smallest_fleet) reinforce = Action(reinforce_weakest_planet) defensive_plan.child_nodes = [smallest_fleet_check, reinforce] logging.info('Defensive Strategy Defined') play_offensively.child_nodes = [ winning_check, early_occupy, offensive_plan, spread_sequence ] play_defensively.child_nodes = [ losing_check, early_occupy, defensive_plan, spread_sequence ] root.child_nodes = [play_offensively, play_defensively, occupy.copy()] logging.info('Children Assigned') logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') offensive_plan = Sequence(name='Offensive Strategy') largest_fleet_check = Check(have_largest_fleet) attack = Action(attack_highest_priority_planet) offensive_plan.child_nodes = [largest_fleet_check, attack] spread_sequence = Sequence(name='Spread Strategy') neutral_planet_check = Check(if_neutral_planet_available) spread_action = Action(spread_to_highest_priority_all_planet) spread_sequence.child_nodes = [neutral_planet_check, spread_action] root.child_nodes = [offensive_plan, spread_sequence, attack.copy()] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') #attack_beneficial beneficial_plan = Sequence(name='beneficial Strategy') #check_neutrals = Check(benefit_check) benefit = Action(attack_beneficial) beneficial_plan.child_nodes = [benefit] #[check_neutrals, benefit] speedy_spread_spree_plan = Sequence(name='speedy quick Strategy') check_neutrals = Check(quicky_check) quick = Action(attack_quickest) speedy_spread_spree_plan.child_nodes = [check_neutrals, quick] fat_spread_plan = Sequence(name='Fat Spread Strategy') largest_fleet_check = Check(have_largest_fleet) #checky_check = Check(checky_check) spread = Action(spread_to_fattest_neutral_planet) #_weakest_enemy_planet fat_spread_plan.child_nodes = [largest_fleet_check, spread] offensive_plan = Sequence(name='Offensive Strategy') largest_fleet_check = Check(have_largest_fleet) attack = Action(aggressive_attack) #_weakest_enemy_planet offensive_plan.child_nodes = [largest_fleet_check, attack] #spread_sequence = Sequence(name='Spread Strategy') #neutral_planet_check = Check(if_neutral_planet_available) #spread_action = Action(spread_to_weakest_neutral_planet) #spread_sequence.child_nodes = [neutral_planet_check, spread_action] root.child_nodes = [ speedy_spread_spree_plan, offensive_plan, beneficial_plan, attack.copy() ] #root.child_nodes = [offensive_plan, spread_sequence, attack.copy()] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') #attack plan invert_att = Inverter() succeed_att = Succeeder() offensive_plan = Sequence(name='Offensive Strategy') enough_planets_check = Check(has_enough_planets) attack = Action(attack_weakest_enemy_planet) invert_att.child_node = succeed_att succeed_att.child_node = offensive_plan offensive_plan.child_nodes = [enough_planets_check, attack] #defense plan invert_def = Inverter() succeed_def = Succeeder() defense = Action(defend_weakest_ally) succeed_def.child_node = defense invert_def.child_node = succeed_def #reinforce plan #invert_reinforce = Inverter() #succeed_reinforce = Succeeder() #reinforce = Action(reinforce_new_planet) #succeed_reinforce.child_node = reinforce #invert_reinforce.child_node = succeed_reinforce #spread plan spread_sequence = Sequence(name='Spread Strategy') neutral_planet_check = Check(if_neutral_planet_available) spread_action = Action(spread_to_weakest_neutral_planet) spread_sequence.child_nodes = [neutral_planet_check, spread_action] root.child_nodes = [invert_att, invert_def, spread_sequence, attack.copy()] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') # sequence = Sequence(name) # check(s) = Check(name_of_check) - takes boolean # action = Action(name_of_behavior) - do something # sequence.child_nodes = [check(s), action(s)] #spread_sequence = Sequence(name='Spread Strategy') #neutral_planet_check = Check(if_neutral_planet_available) #spread_action = Action(spread_to_weakest_neutral_planet) #spread_sequence.child_nodes = [neutral_planet_check, spread_action] spread_production_sequence = Sequence(name='Spread Production Strategy') neutral_planet_check = Check(if_neutral_planet_available) spread_production_sequence_action = Action(spread_production) spread_production_sequence.child_nodes = [neutral_planet_check, spread_production_sequence_action] defend_sequence = Sequence(name='Defend Strategy') enemy_attacks_check = Check(enemy_attacks) defend_action = Action(defend2) defend_sequence.child_nodes = [enemy_attacks_check, defend_action] offensive_plan = Sequence(name='Offensive Strategy') largest_fleet_check = Check(have_largest_fleet) attack = Action(attack_weakest_enemy_planet) offensive_plan.child_nodes = [largest_fleet_check, attack] # root.child_nodes = [spread_production_sequence, offensive_plan, attack.copy()] #root.child_nodes = [spread_sequence, spread_production_sequence, offensive_plan, attack.copy()] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') offensive_plan = Sequence(name='Offensive Strategy') largest_fleet_check = Check(have_largest_fleet) attack = Action(attack_weakest_enemy_planet) offensive_plan.child_nodes = [largest_fleet_check, attack] spread_sequence = Sequence(name='Spread Strategy') neutral_planet_check = Check(if_neutral_planet_available) spread_action = Action(spread_to_weakest_neutral_planet) spread_sequence.child_nodes = [neutral_planet_check, spread_action] reinforcements = Sequence(name='Send Reinforcements') invaded_check = Check(invaded_maybe) send_backup = Action(send_aid_to_invaded_planet) reinforcements.child_nodes = [invaded_check, send_backup] multi_plan = Sequence(name='Multi Attack') have_planets = Check(min_planets) multi_action = Action(multi_attack) multi_plan.child_nodes = [largest_fleet_check, have_planets, multi_action] mul_spread = Sequence(name='Multi Spread') have_planets = Check(min_planets) is_neutral = Check(if_neutral_planet_available) multi_spread_action = Action(multi_spread) mul_spread.child_nodes = [have_planets, is_neutral, multi_spread_action] strong_plan = Sequence(name='Offensive Strategy') largest_fleet_check = Check(have_largest_fleet) strongest_attack = Action(strong_attack) strong_plan.child_nodes = [largest_fleet_check, strongest_attack] finish_plan = Sequence(name='Finish Plan') largest_fleet_check = Check(have_largest_fleet) have_planets = Check(min_planets) finish_action = Action(barrage) finish_plan.child_nodes = [largest_fleet_check, have_planets, finish_action] pinpoint_plan = Sequence(name='Pinpoint') largest_fleet_check = Check(have_largest_fleet) have_planets = Check(min_planets) pinpoint_action = Action(pinpoint) pinpoint_plan.child_nodes = [largest_fleet_check, have_planets, pinpoint_action] root.child_nodes = [offensive_plan, spread_sequence, reinforcements, mul_spread, multi_plan, finish_plan, attack.copy()] logging.info('\n' + root.tree_to_string()) return root
def setup_behavior_tree(): # Top-down construction of behavior tree root = Selector(name='High Level Ordering of Strategies') steal_plan = Sequence(name='Steal Strategy') enemy_just_conquered_check = Check(enemy_just_conquered) steal = Action(attack_recent_lost_neutral_planet) steal_plan.child_nodes = [enemy_just_conquered_check, steal] offensive_plan = Sequence(name='Offensive Strategy') #largest_fleet_check = Check(have_largest_fleet) stable_check = Check(is_stable_enough_to_attack) attack_close = Action(attack_closet_enemy_outpost) attack_weak = Action(attack_weakest_enemy_planet) offensive_plan.child_nodes = [stable_check, attack_close, attack_weak] spread_sequence = Sequence(name='Spread Strategy') neutral_planet_check = Check(if_neutral_planet_available) spread_action = Action(spread_to_weakest_neutral_planet) spread_sequence.child_nodes = [neutral_planet_check, spread_action] repair_sequence = Sequence(name='Repair Strategy') weak_planet_check = Check(is_my_weakest_planet_at_risk) repair_action = Action(spread_my_fleet) repair_sequence.child_nodes = [weak_planet_check, repair_action] root.child_nodes = [steal_plan, offensive_plan, spread_sequence, repair_sequence, attack_close.copy()] logging.info('\n' + root.tree_to_string()) return root