请选择 进入手机版 | 继续访问电脑版
收起左侧

关于AI的投降机制

[复制链接]
阿吉熊发表于 2024-3-23 16:44:29
这决定版AI的投降相关的语句在哪个文件里面?找了一大圈,这种应该是有备注的吧?见有人做过,但是就是找不到,能否请大神指点一下
こはね发表于 2024-3-23 17:56:56
搜索aiAttemptResign試試看?
[(void )] aiAttemptResign(): asks the player if its ok to resign
阿吉熊发表于 2024-3-28 11:35:31
こはね 发表于 2024-3-23 17:56
搜索aiAttemptResign試試看?
[(void )] aiAttemptResign(): asks the player if its ok to resign ...

大概在这里
然后我还有点不会这AI的命令
屏幕截图 2024-03-28 113250.png
阿吉熊发表于 2024-3-28 11:38:30
阿吉熊 发表于 2024-3-28 11:35
大概在这里
然后我还有点不会这AI的命令

这cvoktoresign是什么鬼东西,也没有定义,也没有赋值
こはね发表于 2024-3-28 13:00:36
相关代码在AI\core\AIcode.xs;大概也能看得懂

//==============================================================================
// ShouldIResign
//==============================================================================
rule ShouldIResign
minInterval 7
inactive
{
// Don't resign during treaty since that looks dumb.
// Don't resign too soon.
// Don't resign if we have over 30 active pop slots.
if ((aiTreatyActive() == true) || (kbGetPop() >= 30) || (xsGetTime() < 10 * 60 * 1000))
{
return;
}


bool humanAlly = false; // Set true if we have a surviving human ally.
// Look for human allies.
for (i = 1; <= cNumberPlayers)
{
if ((kbIsPlayerAlly(i) == true) && (kbHasPlayerLost(i) == false) && (kbIsPlayerHuman(i) == true))
{
humanAlly = true; // Don't return just yet, let's see if we should chat.
}
}


// Resign if the known enemy pop is > 10x mine.
int enemyPopTotal = 0;
int enemyCount = 0;
int myPopTotal = 0;


for (i = 1; < cNumberPlayers)
{
if (kbHasPlayerLost(i) == false)
{
if (i == cMyID)
{
myPopTotal += kbUnitCount(i, cUnitTypeUnit, cUnitStateAlive);
}
if (kbIsPlayerEnemy(i) == true)
{
enemyPopTotal += kbUnitCount(i, cUnitTypeUnit, cUnitStateAlive);
enemyCount++;
}
}
}


if (enemyCount < 1)
{
enemyCount = 1; // Avoid div by 0.
}


float enemyRatio = (enemyPopTotal / enemyCount) / myPopTotal;


// My pop is 1/3 the average known pop of enemies so I'm going to whine to my human ally.
if ((enemyRatio > 3) && (humanAlly == true))
{
sendStatement(cPlayerRelationAllyExcludingSelf, cAICommPromptToAllyImReadyToQuit);
xsEnableRule("resignRetry");
xsDisableSelf();
return; // Never resign if we still have a human ally.
}

// My pop is 1/4 the average known pop of enemies.
// I have no TC.
// I have no human ally that I want to stay in the game for so try to resign.
if ((enemyRatio > 4) && (kbUnitCount(cMyID, cUnitTypeAgeUpBuilding, cUnitStateAlive) < 1) && (humanAlly == false))
{
debugCore("Attempting to resign since I'm heavily outnumbered and have no Town Center left");
aiAttemptResign(cAICommPromptToEnemyMayIResign);
xsDisableSelf();
}
}

  • 阿吉熊 : 哇哦,谢谢大佬
跳转到