void NPC::plan_to_craft(const string & item_id) { // assumes item_id is craftable // The following loops deliberately do not take into account what the NPC already has. // If the NPC has 3 wood and needs 8, it will add 8 wood-finding objectives. // Other materials are assumed to be present for other objective. // Add the local requirements/needs before the inventory requirements/needs because // the inventory requirements should always be completed first. // two GOTO objective types for (const pair<string, int> & requirement : recipes.get_recipe(item_id).local_need) { for (int i = 0; i < requirement.second; ++i) { add_objective(high_priority, C::AI_OBJECTIVE_GOTO, requirement.first, item_id); } } for (const pair<string, int> & requirement : recipes.get_recipe(item_id).local_remove) { for (int i = 0; i < requirement.second; ++i) { add_objective(high_priority, C::AI_OBJECTIVE_GOTO, requirement.first, item_id); } } // two ACQUIRE objective types for (const pair<string, int> & requirement : recipes.get_recipe(item_id).inventory_need) { for (int i = 0; i < requirement.second; ++i) { add_objective(high_priority, C::AI_OBJECTIVE_ACQUIRE, requirement.first, item_id); } } for (const pair<string, int> & requirement : recipes.get_recipe(item_id).inventory_remove) { for (int i = 0; i < requirement.second; ++i) { add_objective(high_priority, C::AI_OBJECTIVE_ACQUIRE, requirement.first, item_id); } } }
void bv_minimizet::operator()(const minimization_listt &symbols) { // build bit-wise objective function prop_minimizet prop_minimize(boolbv); prop_minimize.set_message_handler(get_message_handler()); for(minimization_listt::const_iterator l_it=symbols.begin(); l_it!=symbols.end(); l_it++) { add_objective(prop_minimize, *l_it); } // now solve prop_minimize(); }
// objective planning void NPC::plan_to_get(const string & item_id) { add_objective(high_priority, C::AI_OBJECTIVE_ACQUIRE, item_id, item_id); }