当前位置: 首页>>代码示例>>C++>>正文


C++ Agent::init方法代码示例

本文整理汇总了C++中Agent::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Agent::init方法的具体用法?C++ Agent::init怎么用?C++ Agent::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Agent的用法示例。


在下文中一共展示了Agent::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addAgent

	void SimulationEngine::addAgent(AgentInitialParameters& agentConditions)
	{
		// std::cout << "addAgent " << force(Vector2D(0,0)) << std::endl;

		Agent* newAgent = new Agent();
		if (newAgent != NULL) {
			newAgent->init(agentConditions);
			// std::cout << "addAgent " << force(Vector2D(0,0)) << std::endl;
			newAgent->setForceFunction(this->force);
			newAgent->setRadiusFunction(this->rad);
			_agents.push_back(newAgent);
		}
	}
开发者ID:jessecoleman,项目名称:pedestrian-interactions,代码行数:13,代码来源:SimulationEngine.cpp

示例2: main

int main(int argc, char** argv) {
	list<PlotOption> plotoptions;
	int port = 1;

	int index = contains(argv, argc, "-g");
	if (index > 0 && argc > index) {
		plotoptions.push_back(PlotOption(GuiLogger, atoi(argv[index])));

	}
	if (contains(argv, argc, "-f") != 0)
		plotoptions.push_back(PlotOption(File));
	if (contains(argv, argc, "-n") != 0)
		plotoptions.push_back(PlotOption(MatrixViz));
	if (contains(argv, argc, "-l") != 0)
		singleline = false;
	index = contains(argv, argc, "-p");
	if (index > 0 && argc > index)
		port = atoi(argv[index]);
	if (contains(argv, argc, "-h") != 0) {
		printf("Usage: %s [-g N] [-f] [-n] [p PORT]\n", argv[0]);
		printf("\t-g N\tstart guilogger with interval N\n\t-f\twrite logfile\n");
		printf("\t-n\tstart neuronviz\n");
		printf("\t-p PORT\t COM port number, default 1\n");
		printf("\t-h\tdisplay this help\n");
		exit(0);
	}

	GlobalData globaldata;
	dacbot_serial* robot;
	Agent* agent;
	initializeConsole();

	// Different controllers

	AbstractController* controller = new MuscleRunbotController("muscleRunbotController","0.1");
	// one2onewiring gives full range of robot actuators
	AbstractWiring* wiring = new One2OneWiring(new WhiteUniformNoise(), true);

	//****************Finetuning for real robot experiments
	//((AmosIIControl*) controller)->  ---Access to controller parameters
	//see  $(AMOSIICONT)/amosIIcontrol.cpp for controller classes

	//robot         = new AmosIISerialV2("/dev/ttyS0");     // using serial port
	robot = new dacbot_serial("/dev/ttyUSB0"); // using USB-to-serial adapter


	agent = new Agent(plotoptions);
	agent->init(controller, robot, wiring);
	// if you like, you can keep track of the robot with the following line.
	// this assumes that your robot returns its position, speed and orientation.
	// agent->setTracMkOptions(TrackRobot(true,false,false, false,"systemtest"));

	globaldata.agents.push_back(agent);
	globaldata.configs.push_back(robot);
	globaldata.configs.push_back(controller);

	showParams(globaldata.configs);
	printf("\nPress c to invoke parameter input shell\n");
	printf("The output of the program is more fun then useful ;-).\n");
	printf(" The number are the sensors and the position there value.\n");
	printf(" You probably want to use the guilogger with e.g.: -g 10\n");

	cmd_handler_init();
	long int t=0;

	initscr();
	cbreak();
	//noecho();
	intrflush(stdscr,FALSE);
	keypad(stdscr,TRUE);
	nodelay(stdscr,TRUE);

	/*cout<<"Options: Press a= Obstacle Avoidance ON/OFF"<<endl;
	cout<<"Options: Press b= BJC ON/OFF"<<endl;
	cout<<"Options: Press e= Reflex ON/OFF"<<endl;

	cout << "hi brf"<< endl;
	*/while(!stop) {//!stop

		agent->step(noise,t);
		//std::cout << "hifgvf" << t <<endl;


		 if(control_c_pressed()) {

			 if(!handleConsole(globaldata)) {
				 stop=1;
			 }
			 cmd_end_input();
		 }


		 t++;
	};
	delete robot;
	delete agent;
	closeConsole();
	fprintf(stderr,"terminating\n");
	// should clean up but what costs the world
	return 0;
//.........这里部分代码省略.........
开发者ID:pmanoonpong,项目名称:gorobots_edu,代码行数:101,代码来源:main.cpp


注:本文中的Agent::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。