本文整理汇总了C++中AI类的典型用法代码示例。如果您正苦于以下问题:C++ AI类的具体用法?C++ AI怎么用?C++ AI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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));
}
示例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);
}
}
}
示例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 );
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例9: main
int main()
{
char ch;
AI ai;
while(ai.cget()) {
while(scanf(" %c", &ch) != EOF && ai.doit(ch));
ai.cput();
}
return 0;
}
示例10: AIMainThread
//================================================================================
// Основная нить сервера
//
DWORD WINAPI AIMainThread(LPVOID Param)
{
AI* ai = (AI*)Param;
while (true)
{
ai->Frame();
Sleep(10);
}
return 0;
}
示例11: GameInit
void NetworkManager::GameInit()
{
if (m_player->GetType() == Ai)
{
AI* ai = (AI*) m_player;
ai->PlayerInit();
}
else
{
m_player->PlayerInit();
}
}
示例12: moveAI
void moveAI()
{
if(myAI.win() == false)
{
if(myAI.block() == false)
{
myAI.random_move();
}
}
}
示例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);
}
示例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;
}
示例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;
}