script_game_start里面: 
 
#pass 1: Give one village to each castle 
      (try_for_range, ":cur_center", castles_begin, castles_end), 
        (assign, ":min_dist", 999999), 
        (assign, ":min_dist_village", -1), 
        (try_for_range, ":cur_village", villages_begin, villages_end), 
          (neg|party_slot_ge, ":cur_village", slot_village_bound_center, 1), #skip villages which are already bound. 
          (store_distance_to_party_from_party, ":cur_dist", ":cur_village", ":cur_center"), 
          (lt, ":cur_dist", ":min_dist"), 
          (assign, ":min_dist", ":cur_dist"), 
          (assign, ":min_dist_village", ":cur_village"), 
        (try_end), 
        (party_set_slot, ":min_dist_village", slot_village_bound_center, ":cur_center"), 
        (store_faction_of_party, ":town_faction", ":cur_center"), 
        (call_script, "script_give_center_to_faction_aux", ":min_dist_village", ":town_faction"), 
      (try_end), 
 
       
    #pass 2: Give other villages to closest town. 
      (try_for_range, ":cur_village", villages_begin, villages_end), 
        (neg|party_slot_ge, ":cur_village", slot_village_bound_center, 1), #skip villages which are already bound. 
        (assign, ":min_dist", 999999), 
        (assign, ":min_dist_town", -1), 
        (try_for_range, ":cur_town", towns_begin, towns_end), 
          (store_distance_to_party_from_party, ":cur_dist", ":cur_village", ":cur_town"), 
          (lt, ":cur_dist", ":min_dist"), 
          (assign, ":min_dist", ":cur_dist"), 
          (assign, ":min_dist_town", ":cur_town"), 
        (try_end), 
        (party_set_slot, ":cur_village", slot_village_bound_center, ":min_dist_town"), 
        (store_faction_of_party, ":town_faction", ":min_dist_town"), 
        (call_script, "script_give_center_to_faction_aux", ":cur_village", ":town_faction"), 
      (try_end), 
 |