您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ AI类代码示例

51自学网 2021-06-03 12:03:37
  C++
这篇教程C++ AI类代码示例写得很实用,希望能帮到您。

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

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

示例1: main

// DO NOT TOUCH ANYTHING {{{int main() { 	AI* instance = new AI();	int n, m, T, x, y;	cin >> n >> m >> T >> x >> y;	instance->init(n, m, T, x, y);	cout << "READY" << endl;	for(int turn = 1; turn <= T; ++ turn) {		vector<string> S1;		for(int i=0; i<	n; ++i) {			string buf;			cin >> buf;			S1.push_back(buf);		}		vector< vector<int> > S2;		for(int i = 0; i < n; ++ i) {			S2.push_back(vector<int>(m));			for(int j = 0; j < m; ++ j) {				cin >> (S2.back()[j]);			}		}		int ox, oy;		cin >> ox >> oy;		string act = instance->action(S1, S2, ox, oy);		cout << act.c_str() << endl;	}	delete instance;	return 0;}
开发者ID:ESRENLL,项目名称:2015AI,代码行数:31,


示例2: rd

//// This function generates a boss AI for the dungeon at specified coordinates.//// @Param x - x coordinate of the spawn point// @Param y - y coordinate of the spawn point//void AI_Group::SpawnBoss(int x, int y){	AI* ai;	std::random_device rd;	int sight, speed, type, health, ATK;	int lv = dungeon->Get_DungeonLevel();	BossActive = true;	type = rd() % 2;                             // Randomly pick either 0 or 1 (0 = Melee, 1 = Ranger)	BossID = rd() % 99999 + 1;                   // Get random ID value (up to 5 digits)	while (IDExists(BossID))                     // Ensure the ID is unique		BossID = rd() % 99999 + 1;	sight = rd() % 3 + 3;                        // Sight ranges from 3 to 5	speed = rd() % 3 + 2;                        // Speed ranges from 2 to 4	health = rd() % 11 + 40 + (30 * (lv - 1));   // Health ranges from 40 to 50 (values get higher by 30 per level as dungeon level increases)	ATK = rd() % 4 + 10 + (5 * (lv - 1));        // ATK ranges from 10 to 13 (values get higher by 5 per level as dungeon level increases)	if (!type)		ai = new AI(e_queue, boss_melee_sprite, BOSS_MELEE, sight, speed, health, ATK);	else		ai = new AI(e_queue, boss_ranger_sprite, BOSS_RANGER, sight, speed, health, ATK);	ai->SetSpawn(*dungeon);	ai->SetXPosition(x);	ai->SetYPosition(y);	group.insert(std::pair<int, AI*>(BossID, ai));}
开发者ID:ChicoState,项目名称:hack-n-slash,代码行数:34,


示例3: main

int main(int argc, char* argv[]) {    if(argc != 3 && argc != 2){        std::cerr << "<usage>: client ip [port]" << std::endl;        return 1;    }    std::string message;        std::string port = argc == 3 ? argv[2] : "12345";    IO client(argv[1], port);    client.receive(message);        srand(static_cast<unsigned int>(time(0)+message[0]));    AI* ai = new AI(message[0]-'0');        client.send(ai->name() + '/n');    while (true) {        client.receive(message);                if (message == "game end") {            break;        } else if (message == "action") {            const Operation& op = ai->makeDecision();            auto decision = boost::format("%d %d %d/n") % op.source.x % op.source.y % DIR_CHAR[op.direction];            client.send(decision.str());        } else {            const int id = message[0]-'0';            const Point src(message[2]-'0', message[4]-'0');            const Point tar(message[6]-'0', message[8]-'0');            ai->update(id, src, tar);        }    }}
开发者ID:abcdabcd987,项目名称:animal-ai,代码行数:32,


示例4: AI

void Engine::do_turn( int allegiance ){	AI* ai = new AI( world );	Round* r = ai->create_round( allegiance );	create_controls( r );	delete ai;	set_turn( 0 );}
开发者ID:benjamin-t-brown,项目名称:tactics-simulator,代码行数:7,


示例5: AI

void Map::CreateUnit(float x, float y, UNITTYPE utype, OWNER owner){	AI *ai = new AI(*this);	Animation *animation = new Animation(m_conf);	Unit *unit = new Unit(x, y, utype, owner, ai, animation);	ai->SetOwner(unit);	m_units.push_back(unit);}
开发者ID:repesorsa,项目名称:TDpeli,代码行数:8,


示例6: main

int main( int argc, const char* argv[] ){	int motor_ports[8] = {1, 2, 3, 4, 5, 6, 7, 8}		Robot robot = new Robot(motor_ports);		AI ai = new AI(robot);		ai.winTheRace();}
开发者ID:AaronGitH,项目名称:TheIncredibleHumongousWalker,代码行数:9,


示例7: printf

void Game_private::runAI() {	printf("Thread AI run/n");	mp_AI->RunAI(mp_chess);	if (mp_AI->get_ans_tx()) { printf("电脑投降了/n"); gameWin(); return;  }	mp_chess->setOneData(mp_AI->get_ans_x(), mp_AI->get_ans_y(), 2);	int judge_ans = mp_chess->judge();	if (judge_ans == 1) { gameWin(); return; }	if (judge_ans == 2) { gameOver(); return; }	mp_area->queue_draw();	mp_area->setCanUserclick(true);}
开发者ID:sunxfancy,项目名称:GtkFIR,代码行数:11,


示例8: turnTest

  static void turnTest(){    AI ar = AI("Arun", 5);    Deck inPlay;    inPlay.initialize();    Table blds;    for (int i = 0; i < 20; ++i) {      ar.stockPile.push(inPlay.draw(blds.getOutofPlay()));    }    ar.takeTurn(inPlay, blds);    }
开发者ID:grawson,项目名称:Skip-Bo,代码行数:11,


示例9: main

int main(){    char ch;    AI ai;    while(ai.cget()) {        while(scanf(" %c", &ch) != EOF && ai.doit(ch));        ai.cput();    }    return 0;}
开发者ID:Crmiv,项目名称:AlgoSolution,代码行数:12,


示例10: AIMainThread

//================================================================================// Основная нить сервера//DWORD WINAPI AIMainThread(LPVOID Param){	AI* ai = (AI*)Param;	while (true)	{		ai->Frame();		Sleep(10);	}		return 0;}
开发者ID:leandrodiogenes,项目名称:icarus-emu,代码行数:16,


示例11: GameInit

void NetworkManager::GameInit(){	if (m_player->GetType() == Ai)	{		AI* ai = (AI*) m_player;		ai->PlayerInit();	}	else	{		m_player->PlayerInit();	}	}
开发者ID:yelimlim,项目名称:battleship,代码行数:13,


示例12: moveAI

void moveAI(){	if(myAI.win() == false)	{		if(myAI.block() == false)		{			myAI.random_move();		}			}}
开发者ID:Vaztor,项目名称:TicTacToeR,代码行数:13,


示例13: main

int	main(int ac, char **av){  AI	ai;  if (!parse_args(ac, av, ai))    return (-1);  if (!ai.connectToServer())    return (-1);  ai.incPid();  if (!ai.getHeader())    return (-1);  ai.actionLoop();  return (0);}
开发者ID:canercandan,项目名称:ai-game,代码行数:14,


示例14: nearestEntity

		int AIScriptRelay::cpp_nearestEntityId(lua_State *lua, String type)		{			AI *nearest = nearestEntity(type);			if (nearest)			{				mCurrentScript->addRecentAiReference(nearest);				lua_pushnumber(lua, nearest->getHost());				return 1;			}			return 0;		}
开发者ID:DanWatkins,项目名称:glZombies,代码行数:14,


示例15: AI

int AI::answerB(Board board){	AI* ai = new AI(board);	ai->ininB(board);	if (board.getThisTurn() < ai->startFinalRead)	{		return ai->basicRead->answer(ai->readNumber);	}	else	{		return ai->finalRead->answer();	}	delete ai;}
开发者ID:MrYD,项目名称:DxREVERSI,代码行数:14,


示例16: display

/* Callback handler for window re-paint event */void display() {    glClear(GL_COLOR_BUFFER_BIT);  // Clear the color buffer    glMatrixMode(GL_MODELVIEW);    // To operate on the model-view matrix    glLoadIdentity();              // Reset model-view matrix    paddleRight.move();    ball.draw();    paddleRight.draw();    paddleLeft.draw();    glutSwapBuffers();  // Swap front and back buffers (of double buffered mode)    // Animation Control - compute the location for the next refresh    ball.contactLeft(paddleLeft);    ball.contactRight(paddleRight);    ball.move();    ai.AIPaddleMove(ball);    //ai2.AIPaddleMove(ball);    if (ball.didRoundEnd() == 'R') {        ++scoreRight;        ball.resetBallPos();    }    else if (ball.didRoundEnd() == 'L') {        ++scoreLeft;        ball.resetBallPos();    }    else        return;}
开发者ID:harman666666,项目名称:PONG,代码行数:31,


示例17: place

void Board::get_move(bool is_2_player_game, AI &_AI,int cur_player){	Board cur_board_ = *this;	if (is_2_player_game == false && cur_player == _AI._AI_player)		place(_AI.get_move(cur_board_, cur_player,-(1<<30),(1<<30)).position, cur_player);	else{		while (readMove(cur_player) == false);	}	return;}
开发者ID:magdy-hasan,项目名称:XO,代码行数:9,


示例18: cpp_nearestEntityId

		int AIScriptRelay::cpp_nearestEntityId(lua_State *lua)		{			String arg = mCurrentScript->getArgString(1);			if (arg != "")				return cpp_nearestEntityId(lua, arg);			AI *nearest = nearestEntity();			if (nearest)			{				mCurrentScript->addRecentAiReference(nearest);				lua_pushnumber(lua, nearest->getHost());				return 1;			}			return 0;		}
开发者ID:DanWatkins,项目名称:glZombies,代码行数:19,


示例19: ArtificialIntelligence

unsigned _stdcall ArtificialIntelligence(void *clc){	int kkl;	while (1){		kkl = clock() - timeai;		if (kkl >= 50){			timeai = clock();			EnterCriticalSection(&regen);			_AI.Update(kkl);			LeaveCriticalSection(&regen);		}	}}
开发者ID:vladikve,项目名称:Server_client,代码行数:12,


示例20: main

int main(int argc, char** argv) {	string input;	cout << "Color type: Black or White" << endl;	cin >> input;	Board* Othello = new Board;	Othello->SetSquare();	Player* player = Board::player;	AI* ai = Board::ai;	if(input.compare("Black") == 0) {		player->setType(BLACK);		ai->setType(WHITE);		Othello->initializeBoard(argc, argv);	}	else if(input.compare("White") == 0) {		player->setType(WHITE);		ai->setType(BLACK);		Othello->initializeBoard(argc, argv);	}	else {		cout << "Invalid choice." << endl;	}}
开发者ID:MichaelRiccardi,项目名称:Othello,代码行数:22,


示例21: main

int main(int argc, char *argv[]){    srand(time(NULL));    cout << "Welcome to Battleship!/nYou will be placing your ships on the bottom half while the/ntop half keeps "         << "up with your hits and misses" << endl << endl;    Board board;    AI ai;    //setup game    board.print();    board.setShips();    board.setCPUShips();    cout << endl;    //play game    QProcess::execute("clear");    while(board.getPHits() > 0 && ai.getCPUHits() > 0){        board.print();        board.chooseHitSpot();        ai.runAI(board);    }    return 0;}
开发者ID:anfelder,项目名称:GeneralStuff,代码行数:23,


示例22: main

int main(int nArgs, char* args[]) {		if (nArgs < 2) {		return 666;	}		string fileLoc = "player.data";	string board = args[1];	string team = args[2];	bool isRed = (team.compare("red") == 0);		ifstream playerFile("fileLoc");		Board b(board);	b.redTurn = isRed;	AI player;	playerFile >> player;	player.playAsRed = isRed;	player.thinker.maxtime = 14.0;	cout << player.makeMove(b).toString();	}
开发者ID:SavedByGrace251,项目名称:GGBro-Neural-Net,代码行数:23,


示例23: main

int main(){    logfile.open("ai++.log", std::ios_base::out | std::ios_base::trunc);    if (!logfile.is_open()) {        std::cerr << "ai: cannot open log. terminating." << std::endl;        return 1;    }    RawBoard board;    uint8_t state;    AI ai;    while (true) {        read_board(std::cin, board);        read_state(std::cin, state);        AnalyzeResult result = ai.actuate(board);        if (std::get<1>(result)) {            std::cout << (uint8_t)std::get<0>(result) << std::flush;        } else {            std::cerr << "ai: no further options. terminating." << std::endl;            return 0;        }    }}
开发者ID:horazont,项目名称:2048-ai,代码行数:24,


示例24: CollidePlayerDino

void CollidePlayerDino(GameObject* go1, GameObject* go2){  Player* player = dynamic_cast<Player*>(go1);  Assert(player);  Dino* dino = dynamic_cast<Dino*>(go2);  Assert(dino);  if (dino->IsDead())  {    return; // this actually happened!  }  // Get the pets to flee the dino  PetList pets = player->GetPets();  player->DropPets();  for (PetList::iterator it = pets.begin(); it != pets.end(); ++it)  {    Pet* pet = *it;    AI* ai = pet->GetAI(AIFlee::NAME);    ai->SetTarget(dino);    pet->SetAI(ai);    pet->SetIsFalling(true);  }  Vec3f vel = player->GetVel();  player->SetVel(-vel);  vel = dino->GetVel();  dino->SetVel(Vec3f(0, 0, 0));  dino->SetAI(AIStunned::NAME);  PlayWav("hammer_anvil3"); // NB No file ext  WWCamera* cam = GetActiveCamera();  Assert(cam);  cam->SetEarthquake(1.0f); // TODO CONFIG}
开发者ID:jason-amju,项目名称:amju-ww,代码行数:36,


示例25: statusDraw

void statusDraw(WINDOW *win, Player p, AI ai) {	bool isPlayer = p->getID(p) == 1;	wattron(win, A_BOLD);	mvwprintw(win, 1, 1, "Versus AI: Hard");	mvwprintw(win, 5, 1, "Turn: "); wclrtoeol(win);	wattron(win, COLOR_PAIR(isPlayer?1:2));	wprintw(win, "%s", isPlayer?"Player":"AI");	wattroff(win, COLOR_PAIR(isPlayer?1:2));	mvwprintw(win, 9, 1, "AI Status:");	wmove(win, 10, 1); wclrtoeol(win);	wmove(win, 11, 1); wclrtoeol(win);	wprintw(win, "%s", !isPlayer?ai->getStatus(ai):"");	wattroff(win, A_BOLD);	wrefresh(win);}
开发者ID:not-jay,项目名称:C-Connect4-AI,代码行数:16,


示例26: view_query

int view_query(int a, int b){  ai.examined = 0;  #ifdef AICC // hybrid crack-crack    int cnt = ai.crack_crack(a,b,marr);  #endif  #ifdef AICS // hybrid crack-sort    int cnt = ai.crack_sort(a,b,marr);  #endif  #ifdef AISS // hybrid sort-sort    int cnt = ai.sort_sort(a,b,marr);  #endif  #ifdef AICC1R // hybrid crack-crack with 1 stochastic crack    int cnt = ai.scrack_scrack(a,b,marr);  #endif  #ifdef AICS1R // hybrid crack-sort with 1 stochastic crack    int cnt = ai.scrack_sort(a,b,marr);  #endif    #ifdef AICCRP2 // hybrid crack-crack with rounding to nearest power of two    int aa = a, bb;    while (aa&(aa-1)) aa &= aa-1;    if (aa == (1<<30)) bb = 2147483647; else bb = aa<<1;    ai.crack_crack(aa,bb,marr);    int cnt = ai.crack_crack(a,b,marr);  #endif  #ifdef AICCRMSZ // hybrid crack-crack with rounding to a partition with minimum size = RMSZ    int aa = (a/RMSZ)*RMSZ, bb = (int) min((long long)b - (b%RMSZ) + RMSZ, 2147483647LL);    ai.crack_crack(aa,bb,marr);    int cnt = ai.crack_crack(a,b,marr);  #endif  n_touched = ai.examined;  return cnt;}
开发者ID:felix-halim,项目名称:scrack,代码行数:40,


示例27: parse_args

static bool	parse_args(int ac, char **av, AI& ai){  if (ac == 2)    {      ai.setHost("localhost", 12345);      ai.setTeamName(av[1]);      return (true);    }  else if (ac == 3)    {      ai.setHost("localhost", atoi(av[2]));      ai.setTeamName(av[1]);      return (true);    }  else if (ac == 4)    {      ai.setHost(av[2], atoi(av[3]));      ai.setTeamName(av[1]);      return (true);    }  std::cout << "usage: ./AI [[Team Name] [[Host] [Port]]]"	    << std::endl;  return (false);}
开发者ID:canercandan,项目名称:ai-game,代码行数:24,


示例28: onTurn

  void onTurn(Board& board,Reversi::Point p)  {      cout << "コンピュ
C++ AIFilePicker类代码示例
C++ AHRS类代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。