Пример #1
0
void Environment::addWoodCutter() {
    // Random location of WC's home
    int wc_home_cell = rand() % unused.size();
    unsigned hx = unused[wc_home_cell].first;
    unsigned hy = unused[wc_home_cell].second;
    unused.erase(unused.begin() + wc_home_cell);
 
    // Random location of WC's work
    int wc_work_cell = rand() % unused.size();
    unsigned wx = unused[wc_work_cell].first;
    unsigned wy = unused[wc_work_cell].second;
    unused.erase(unused.begin() + wc_work_cell);

    // Place WC either in home cell or work cell
    int choice = rand() % 2;
    woodcutter = new WoodCutter(hx, hy, wx, wy, choice);

    if (choice)
        setAgent(hx, hy, woodcutter);
    else
        setAgent(wx, wy, woodcutter);

    point home = {hx, hy};
    point work = {wx, wy};
    rrh->map_data.woodcutter = make_pair(home, work);
}
Пример #2
0
void CFootBotUN::initLocalNavigation(TConfigurationNode& t_tree) {
	hlAgent.Init(t_tree);
	hlAgent.axisLength = axisLength;
	orcaAgent.Init(t_tree);
	orcaAgent.axisLength = axisLength;
	hrvoAgent.Init(t_tree);
	hrvoAgent.axisLength = axisLength;

	localNavigationType = "HL";

	if (NodeExists(t_tree, "local_navigation")) {
		TConfigurationNode node = GetNode(t_tree, "local_navigation");
		if (node.HasAttribute("type"))
			GetNodeAttribute(node, "type", localNavigationType);
	}

	if (localNavigationType == "HL") {
		localNavigationIndex = 2;
		setAgent(hlAgent);
	} else if (localNavigationType == "ORCA") {
		localNavigationIndex = 0;
		setAgent(orcaAgent);
	} else if (localNavigationType == "HRVO") {
		localNavigationIndex = 0;
		setAgent(hrvoAgent);
	} else {
		throw "Navigation type not defined!";
		return;
	}

	printf("INIT local nav %.3f %.3f", axisLength, agent->axisLength);

}
 AgentCallbackLoginAction::AgentCallbackLoginAction(const std::string& agent, const std::string& exten, const std::string& context, bool ackCall, long wrapupTime) {
     setAgent(agent);
     setExten(exten);
     setContext(context);
     setAckCall(ackCall);
     setWrapupTime(wrapupTime);
 }
Пример #4
0
void Environment::addBear() {
    int bear_cell = rand() % unused.size();
    int bx = unused[bear_cell].first;
    int by = unused[bear_cell].second;
    bear = new Bear(bx, by);
    // If Bear's range on RRH - try again
    if (!checkRange(bear)) {addBear(); return;}
    setAgent(bx, by, bear);
    setBearFeel(bx, by);
    unused.erase(unused.begin() + bear_cell);
    
   for (int i = bx - 1; i <= bx + 1; i++)
        for (int j = by - 1; j <= by + 1; j++)
            if (checkBounds(i, j) && !(i == bx && j == by))
                setBearFeel(i, j);

    for (int i = 0; i < (int)unused.size(); i++) {
        unsigned x = unused[i].first;
        unsigned y = unused[i].second;
        if (forest[x][y].feel_wolf || forest[x][y].feel_bear) {
            unused.erase(unused.begin() + i);
            i--;
        }
    }
}
Пример #5
0
void Environment::addGranny() {
    int gr_cell = rand() % unused.size();
    unsigned gx = unused[gr_cell].first;
    unsigned gy = unused[gr_cell].second;
    granny = new Granny(gx, gy);
    setAgent(gx, gy, granny);
    unused.erase(unused.begin() + gr_cell);

    point gr = {gx, gy};
    rrh->map_data.granny = gr;
}
Пример #6
0
void Environment::fillEnvironment() {
    rrh = new RRH(0, 0);
    setAgent(0, 0, rrh);
    for (int i = 0; i < SIZE; i++)
        for (int j = 0; j < SIZE; j++)
            if (!(i == 0 && j == 0))
                unused.push_back(make_pair(i, j));
    addWolf();
    addBear();
    addWoodCutter();
    addGranny();
}
Пример #7
0
void Environment::addWolf() {
    int wolf_cell = rand() % unused.size();
    unsigned wx = unused[wolf_cell].first;
    unsigned wy = unused[wolf_cell].second;
    wolf = new Wolf(wx, wy);
    // If wolf's range on RRH - try again
    if (!checkRange(wolf)) { addWolf(); return;}
    setAgent(wx, wy, wolf);
    unused.erase(unused.begin() + wolf_cell);

    if (checkBounds(wx - 1, wy)) setWolfFeel(wx - 1, wy);
    if (checkBounds(wx + 1, wy)) setWolfFeel(wx + 1, wy);
    if (checkBounds(wx, wy - 1)) setWolfFeel(wx, wy - 1);
    if (checkBounds(wx, wy + 1)) setWolfFeel(wx, wy + 1);
}
 AgentCallbackLoginAction::AgentCallbackLoginAction(const std::string& agent, const std::string& exten) {
     setAgent(agent);
     setExten(exten);
 }
Пример #9
0
void
iPAR::setAgent(const std::string&  agname){
	MetaObject *agent_obj=actionary->searchByNameObj(agname);
	setAgent(agent_obj);
  }
Пример #10
0
ec_gui::Actuator::Actuator(Agent *agent)
{
    setAgent(agent);
}
Пример #11
0
 Browser::Browser() {
     setAgent("WebBrowser");
 }
Пример #12
0
ec_gui::Sensor::Sensor(Agent *agent) : QObject(){
    setAgent(agent);
}
Пример #13
0
void CMsgObject::changeParent(CMsgObject* newParent) {
	p_Parent->removeChild(this);
	p_Parent = newParent;
	setAgent(newParent->p_agent);
}