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


C++ Bot类代码示例

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


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

示例1: botGameStart

void Player::botGameStart(Bot &b)
{
	cout << " The bot game is setting " << endl;

	b.botSettingGame();
	b.botDisplayGame();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: QObject

Simulator::Simulator(QGraphicsScene *scene, QObject *parent): QObject(parent), timerId(0), scene(scene){
			// Define the gravity vector.
			b2Vec2 gravity(0.0f,-10.0f);
			world = new b2World(gravity, true);

			b2BodyDef bodyDef;
			b2PolygonShape shapeDef;
			b2FixtureDef fixtureDef;

			bodyDef.position.Set(200.0f,-250);
			shapeDef.SetAsBox(100.0f, 10.0f);
			fixtureDef.shape = &shapeDef;
			groundBody = world->CreateBody(&bodyDef);
			groundBody->CreateFixture(&fixtureDef);

			// Create lots of little colored triangles, random pos, rotation, color.
			for (int i = 0; i < BODYCOUNT; ++i) {
				//poly << QPointF(0, -10) << QPointF(-5, 0) << QPointF(5, 0);
				Bot* polygon = bodyItems[i] = new Bot(world);
				polygon->setPos(200+-20 + qrand() % 40,200+ -75 - qrand() % 150);
				polygon->setRotation(qrand() % 360);
				polygon->setBrush(QColor(128 + qrand() % 128, 128 + qrand() % 128, 128 + qrand() % 128));
				polygon->_init();
				scene->addItem(polygon);
			}
}
开发者ID:FuMaster,项目名称:UI2,代码行数:26,代码来源:simulator.cpp

示例3: RemoveBot

void GameMechanic::UpdateShoot(float dt)
{
	vector<Bullet*>::iterator it;
	for(it = mBullets.begin(); it != mBullets.end(); ++it)
	{
		Bullet* bullet = *it;
		bullet->Update(dt);
		
		vector<Bot*>::iterator botIt;
		for (botIt = mBots.begin(); botIt != mBots.end(); ++botIt )
		{
			Bot* bot = *botIt;
			if(xEntityDistance(bot->GetHandle(), bullet->GetHandle()) < 50.f)
			{
				bot->DealDamage(mPlayer->GetDamage());
				if(bot->GetHealth() == 0)
					RemoveBot(botIt);
				RemoveBullet(it);
				return;
			}
		}

		//todo: investigate how to remove group of objects from collection
		float distance = xEntityDistance(bullet->GetHandle(), bullet->GetStartPositionPivot());
		if( distance > 1000.f)
		{
			RemoveBullet(it);
			return;
		}
	}
}
开发者ID:QLubov,项目名称:ConfShooter,代码行数:31,代码来源:GameMechanic.cpp

示例4: main

int main(int argc, char *argv[])
{
  QCoreApplication a(argc, argv);

  std::cout << "start test\n";
  Irc* irc = new Irc("irc.quakenet.org", 6667);
  Bot* bot = new Bot(irc);

  PingListener* ping_listener = new PingListener;
  bot->AddListener("irc.ping", ping_listener);

  AutoJoin* aj = new AutoJoin;
  bot->AddListener("irc.connect", aj);

  // Disconnect automatically from irc in 3 seconds
  Disconnecter* disconnecter = new Disconnecter;
  bot->AddListener("irc.connect", disconnecter);

  int bret = bot->Run();

  std::cout << bret << std::endl;

  sleep(8); //wait 8 s

  bret = irc->Disconnect();
  std::cout << "Disconnected: " << bret << std::endl;


  delete bot;
//  delete bot;
  return a.exec();
}
开发者ID:sniemela,项目名称:spammelicpp,代码行数:32,代码来源:main.cpp

示例5: main

int main (void) {
	ifstream fich;
	fich.open(FILE_NAME);
  Bot BOT (&fich);
  fich.close();
  while (1) {
  	BOT.exe();
  	BOT.modifyEnvironment();
  }
} 
开发者ID:alu0100824780,项目名称:IAA_BayesianGame,代码行数:10,代码来源:main.cpp

示例6: return

int	EntityManager::createEntitiesFromFolder(std::list<Bot*> bots, int iterator)
{
  (void)iterator;
  Bot *newEntity = bots.back();

  _id++;
  newEntity->setId(_id);
  _entities.push_back(newEntity);
  return (_id);
}
开发者ID:antgar,项目名称:rtype_cpp,代码行数:10,代码来源:EntityManager.cpp

示例7: main

int main(int argc, char** argv)
{
	gnutls_global_init();
	curl_global_init(CURL_GLOBAL_ALL);

	Logger::instance = new StderrLogger();
	ConnectionDispatcher d;
	std::vector<Bot*> bots;

	Data::add_type("string", new StringType());
	Data::add_type("int", new IntType());
	Data::add_type("pair", new PairType());
	Data::add_type("list", new ListType());
	Data::add_type("map", new MapType());

	if (util::fs::exists("./bot.conf")) // move old bot.conf to networks/default.conf
	{
		if (!util::fs::is_directory("./networks"))
		{
			util::fs::mkdir("./networks");
		}

		util::fs::rename("./bot.conf", "./networks/default.conf");
	}

	Config *c = NULL;

	auto networks = util::fs::listdir("./networks");
	for (auto name : networks)
	{
		c = Config::load("./networks/" + name);
		Config *l = Config::load("./lang/" + c->get("locale.language")->as_string() + ".conf");
		Bot *b = new IRCBot(c, l);
		bots.push_back(b);
		b->connect(&d);
	}
	
	while(true)
	{
		if(d.count() == 0)
		{
			break;
		}

		d.handle();
	}

	Data::cleanup_types();

	curl_global_cleanup();
	gnutls_global_deinit();

	return 0;
}
开发者ID:Stary2001,项目名称:BakaBot,代码行数:54,代码来源:main.cpp

示例8: addMoreBots

void BotRecycler::addMoreBots(wstring botType, unsigned int numToAdd)
{
	// NOW MAKE THE BOTS
	Bot* sampleBot = registeredBotTypes[botType];

	for (unsigned int i = 0; i < numToAdd; i++)
	{
		Bot *botClone = sampleBot->clone();
		recyclableBots[botType]->push_back(botClone);
	}
}
开发者ID:bsbae402,项目名称:McKillasGorilla_repo,代码行数:11,代码来源:BotRecycler.cpp

示例9: main

int main(int argc, char *argv[])
{
    Bot bot;

    if(bot.connectToServer()==sf::Socket::Done)
    {
        bot.registerConnection();
        bot.join();
        bot.loop();
    }
}
开发者ID:Dyrand,项目名称:IRC-Bot,代码行数:11,代码来源:main.cpp

示例10: main

int main(int argc, char *argv[])
{
  std::cout.sync_with_stdio(0); 

  Bot* bot = new Bot();
  bot->playGame();
  delete bot;

  LOG("Bot gracefully shutting down...");

  return 0;
}
开发者ID:Mondobot,项目名称:Ai-challenge,代码行数:12,代码来源:main.cpp

示例11: main

int main()
{
	Bot bot;
	std::string str = "";
	while(!([&str]() -> std::istream& { std::cout << ">> "; return std::getline(std::cin, str); }().eof() || std::cin.fail() || std::cin.bad()))
	{
		if(bot.IssueCommand(str) == false)
		{
			break;
		}
	}
	return 0;
}
开发者ID:Dessix,项目名称:Eloquence,代码行数:13,代码来源:main.cpp

示例12: unload

void AI::unload(Bot& actor, Unit& target)
{
  if(actor.actions()==0)
  {
    cout<<"Big guy cant attack?"<<endl;
  }
  while(actor.actions()>0)
  {
    if(actor.damage()==0){cout<<"NOT ";};
    cout<<"ATTACKING!"<<endl;
    actor.attack(target);
  }
}
开发者ID:siggame,项目名称:MegaMinerAI-6,代码行数:13,代码来源:AI.cpp

示例13: while

/*
	update - This method should be called once per frame. It
	goes through all of the sprites, including the player, and calls their
	update method such that they may update themselves.
*/
void SpriteManager::update(Game *game)
{
	// UPDATE THE PLAYER SPRITE
	player.updateSprite();

	// NOW UPDATE THE REST OF THE SPRITES
	list<Bot*>::iterator botIterator;
	botIterator = bots.begin();
	while (botIterator != bots.end())
	{
		Bot *bot = (*botIterator);
		bot->think(game);
		bot->updateSprite();
		botIterator++;
	}
}
开发者ID:DavidLui,项目名称:-CSE380-Balloon-Escape,代码行数:21,代码来源:SpriteManager.cpp

示例14: main

int main(void)
{
	Bot a = Bot();
	float c_rgb[3];
	GLFWwindow* window;
	glfwSetErrorCallback(error_callback);
	if (!glfwInit())
		exit(EXIT_FAILURE);
	window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL);
	if (!window)
	{
		glfwTerminate();
		exit(EXIT_FAILURE);
	}
	glfwMakeContextCurrent(window);
	glfwSwapInterval(1);
	glfwSetKeyCallback(window, key_callback);
	while (!glfwWindowShouldClose(window))
	{
		float ratio;
		int width, height;
		glfwGetFramebufferSize(window, &width, &height);
		ratio = width / (float)height;
		glViewport(0, 0, width, height);
		glClear(GL_COLOR_BUFFER_BIT);
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f);
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		glRotatef((float)glfwGetTime() * 50.f, 0.f, 0.f, 1.f);
		glBegin(GL_TRIANGLES);
		a.getColor(c_rgb);
		glColor3f(c_rgb[0], c_rgb[1], c_rgb[2]);
		glVertex3f(-0.6f, -0.4f, 0.f);
		//glColor3f(0.f, 1.f, 0.f);
		glVertex3f(0.6f, -0.4f, 0.f);
		//glColor3f(0.f, 0.f, 1.f);
		glVertex3f(0.f, 0.6f, 0.f);
		glEnd();
		glfwSwapBuffers(window);
		glfwPollEvents();
	}
	glfwDestroyWindow(window);
	glfwTerminate();
	exit(EXIT_SUCCESS);
}
开发者ID:MarkGrivainis,项目名称:community,代码行数:47,代码来源:Main.cpp

示例15: moveTowardsTarget

void AI::moveTowardsTarget(Bot& actor, Unit& target)
{
  int dist = INT_MAX,startDist = 0;
  while(actor.steps()>0 && dist > actor.range() && dist != startDist)
  {
    //startDist = distance(actor.x(),actor.y(),actor.size(), target.x(),target.y(),target.size());
    startDist = distance(actor.x(),actor.y(),actor.size(), target.x(),target.y(),1)+1;
    cout<<"Distance to target: "<<startDist<<endl;
    dist = startDist;
    int dir = 0;
    // find the best, non blocked direction
    for(unsigned int d=0;d<DIR_SIZE;d++)
    {
      int x=actor.x()+xMod[d];
      int y=actor.y()+yMod[d];
      
      if(x>=0 && x<boardX() && y>=0 && y<boardY())
      {
        //int tempDist = distance(x,y,actor.size(), target.x(),target.y(),target.size());
        int tempDist = distance(x,y,actor.size(), target.x(),target.y(),1);
        if(tempDist < dist)
        {
          bool blocked = false;
          // check if blocked TODO add other blocking calls
          for(unsigned int b=0;b<bots.size() && !blocked;b++)
          {
            //if(bots[b].x()==x && bots[b].y()==y && bots[b].partOf()==0)
            if(bots[b].partOf()==0 && distance(bots[b].x(),bots[b].y(),bots[b].size(),x,y,actor.size())==0 && bots[b].id() != actor.id())
            {
              blocked=true;
            }
          }
          if(!blocked)
          {
            dir=d;
            dist = tempDist;
          }
        }
      }
    }
    if(dist != startDist)
    {
      cout<<"Big guy moving: "<<direction[dir]<<endl;
      actor.move(direction[dir]);
    }
    else
    {
      cout<<"Nothing worth going to!"<<endl;
    }
  }
}
开发者ID:siggame,项目名称:MegaMinerAI-6,代码行数:51,代码来源:AI.cpp


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