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

[求助] 怎么让印度AI时代2选择不造红堡?我试了好久没成功。

[复制链接]
沉默的lsp发表于 2023-9-2 16:45:39
 本帖最后由 沉默的lsp 于 2023-9-2 17:18 编辑 

之前我直接禁止在时代2选择红堡,但这不仅影响电脑也影响玩家,所以就想修改AI。反正AI的红堡都是放家里,希望AI在时代3及以后造,我已经调高了时代3及以后的红堡的属性。
我先是把代码修改成如下,本来代码的ypWIAgraFort都在第一行,全被我放在第二行了。但是修改无效,AI还是选择时代2造红堡。
if ((cMyCiv == cCivIndians) || (cMyCiv == cCivSPCIndians)) {
//Agra Fort, Charminar Gate, Karni Mata, Taj Mahal, Tower of Victory
if (wonderchoice == 0) {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWICharminarGate2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWIAgraFort3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWIKarniMata4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWITajMahal5);
}
else if (wonderchoice == 1) {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWIKarniMata2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWIAgraFort3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWICharminarGate4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWITajMahal5);
}
else if (wonderchoice == 2) {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWICharminarGate2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWIKarniMata3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWIAgraFort4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWITowerOfVictory5);
}

然后我又在如下代码里,删除了第一行的“(kbUnitCount(cMyID, cUnitTypeypWIAgraFort2, cUnitStateAlive) > 0) ||”,还是无效。因为双竖线表示or逻辑?所以只要没红堡就一定会先造红堡?
// Age 3 agra fort upgrade (provided there is one)
if ((kbUnitCount(cMyID, cUnitTypeypWIAgraFort2, cUnitStateAlive) > 0) ||
(kbUnitCount(cMyID, cUnitTypeypWIAgraFort3, cUnitStateAlive) > 0) ||
(kbUnitCount(cMyID, cUnitTypeypWIAgraFort4, cUnitStateAlive) > 0) ||
(kbUnitCount(cMyID, cUnitTypeypWIAgraFort5, cUnitStateAlive) > 0))
{
if (kbTechGetStatus(cTechypFrontierAgra) == cTechStatusObtainable)
{
addTechToForecasts(cTechypFrontierAgra);
}
}

我还搜到如下代码,并把ypWIAgraFort2所在的1~4行全删去,也无效。
// Check for agra fort
if (kbUnitCount(cMyID, cUnitTypeypWIAgraFort2, cUnitStateAlive) > 0)
{
agraFortType = cUnitTypeypWIAgraFort2;
}
else if (kbUnitCount(cMyID, cUnitTypeypWIAgraFort3, cUnitStateAlive) > 0)
{
agraFortType = cUnitTypeypWIAgraFort3;
}
else if (kbUnitCount(cMyID, cUnitTypeypWIAgraFort4, cUnitStateAlive) > 0)
{
agraFortType = cUnitTypeypWIAgraFort4;
}
else if (kbUnitCount(cMyID, cUnitTypeypWIAgraFort5, cUnitStateAlive) > 0)
{
agraFortType = cUnitTypeypWIAgraFort5;
}

我现在想是不是应该加上一个(the_age == cAge3)前提,但不知道怎么加,也不知道行不行。
所以求助大神们,怎么修改呀~只要时代3及以后造红堡就行了。
是不是能删除所有时代2红堡的判定,然后添加一段新代码,要求时代2不允许造红堡,才行?@青天小羽 大神路过看一眼QAQ

こはね发表于 2023-9-3 00:19:36
有空再帮你看下
PS:我只会咕咕咕

  • 沉默的lsp : 我把搜到的所有Check for agra fort、Age 3 agra fort upgrade (provided there is one)的都删了,还是没用,绝望了
こはね发表于 2023-9-3 20:46:10
你这个是什么AI?原版的我只找到以下语句

/*gAsianWonders定义为一个新数组*/
gAsianWonders = xsArrayCreateInt(5, 0, "Wonder Age IDs");

/*aiRandInt(int max),返回随机整数,最小值为0,最大值自定义*/
int wonderchoice = aiRandInt(4);

/*省略其他语句*/
if ((cMyCiv == cCivIndians) || (cMyCiv == cCivSPCIndians)) {
//Agra Fort, Charminar Gate, Karni Mata, Taj Mahal, Tower of Victory
/*根据wonderchoice的值设定数组赋值,0、1、2、3只是数组的顺序(也可以叫名称,因为创建的是Int数组,所以是从0开始的整数),没有什么特定用法,取决于你后面的程序是怎么写的*/
if (wonderchoice == 0) {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWIAgraFort2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWICharminarGate3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWIKarniMata4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWITajMahal5);
}
else if (wonderchoice == 1) {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWITowerOfVictory2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWIAgraFort3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWICharminarGate4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWIKarniMata5);
}
else if (wonderchoice == 2) {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWICharminarGate2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWITajMahal3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWIAgraFort4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWITowerOfVictory5);
}
else {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWITajMahal2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWIKarniMata3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWITowerOfVictory4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWICharminarGate5);
}
}

搜索WIAgraFort还能找到getWonderToBuild,getWonderToBuild经过搜查并没有调用到

int getWonderToBuild(int the_age=-1)
{
if ((cMyCiv == cCivJapanese) || (cMyCiv == cCivSPCJapanese) || (cMyCiv == cCivSPCJapanese)) {
//Giant Buddha, Golden Pavillion, Shogunate, Torii Gates, Toshogu Shrine
//age2
if (the_age == cAge2) {
return (cUnitTypeypWJGiantBuddha2);
}
//age3
else if (the_age == cAge3) {
return (cUnitTypeypWJToriiGates3);
}
//age4
else if (the_age == cAge4) {
return (cUnitTypeypWJShogunate4);
}
//age5
else if (the_age == cAge5) {
return (cUnitTypeypWJToshoguShrine5);
}
}
if ((cMyCiv == cCivChinese) || (cMyCiv == cCivSPCChinese)) {
//age2
if (the_age == cAge2) {
return (cUnitTypeypWCPorcelainTower2);
}
//age3
else if (the_age == cAge3) {
return (cUnitTypeypWCSummerPalace3);
}
//age4
else if (the_age == cAge4) {
return (cUnitTypeypWCTempleOfHeaven4);
}
//age5
else if (the_age == cAge5) {
return (cUnitTypeypWCWhitePagoda5);
}
}
if ((cMyCiv == cCivIndians) || (cMyCiv == cCivSPCIndians)) {
//age2
if (the_age == cAge2) {
return (cUnitTypeypWICharminarGate2);
}
//age3
else if (the_age == cAge3) {
return (cUnitTypeypWIKarniMata3);
}
//age4
else if (the_age == cAge4) {
return (cUnitTypeypWITajMahal4);
}
//age5
else if (the_age == cAge5) {
return (cUnitTypeypWIAgraFort5);
}
}

return (-1);
}


搜索gAsianWonders可找到以下代码,我只是一个业余的,专业术语应该叫事件?该事件会根据the_age赋值,用xsArrayGetInt命令,从数组gAsianWonders获取不同的值,并且返回获取的值;age2获取数组中排序为0的值,而根据前面的赋值(前面xsArraySetInt设定了0、1、2、3),即为cUnitTypeXXXXXXXXXX2,时代2奇观
int getPreferredWonderToBuild(int the_age=-1)
{
if (the_age == cAge2) {
return(xsArrayGetInt(gAsianWonders, 0));
}
//age3
else if (the_age == cAge3) {
return(xsArrayGetInt(gAsianWonders, 1));
}
//age4
else if (the_age == cAge4) {
return(xsArrayGetInt(gAsianWonders, 2));
}
//age5
else if (the_age == cAge5) {
if (aiGetGameMode() == cGameModeDeathmatch) {
return(-1); //BHG:CGN: don't try to get to age 5 in a deathmatch game
}
return(xsArrayGetInt(gAsianWonders, 3));
}
return (-1);
}
然后搜索getPreferredWonderToBuild可以找到在其他地方调用该事件,然后又有其他事件关联,不想解释实际上是不想去理解别人的代码,有兴趣你可以自己去理解。干脆直接丢给chatGPT吧

理论上只要把 xsArraySetInt(gAsianWonders, 0, cUnitTypeypWIAgraFort2);给注释掉就行了;然后会引发新BUG
当wonderchoice == 0时,印度无法进入殖民时代,所以你不能这样做,你需要将cUnitTypeypWIAgraFort2修改成cUnitTypeypWITowerOfVictory2;当然你可以来点更简单复杂粗暴的方法,直接把wonderchoice赋值改掉。如果想保留随机性质,你需要用aiRandInt设定随机数,但你没有办法设定最小值,又要多出n行判断代码
顺便提一下,aiChat是用来输出ai聊天的,可以用来查看各项变量设定,因为全效没有留给我们任何可以查询AI输出的工具,所以只能用aiChat
if ((cMyCiv == cCivIndians) || (cMyCiv == cCivSPCIndians)) {
//wonderchoice = 0;
aiChat(1,"wonderchoice:"+wonderchoice);

//Agra Fort, Charminar Gate, Karni Mata, Taj Mahal, Tower of Victory
if (wonderchoice == 0) {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWITowerOfVictory2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWICharminarGate3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWIKarniMata4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWITajMahal5);
}
else if (wonderchoice == 1) {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWITowerOfVictory2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWIAgraFort3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWICharminarGate4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWIKarniMata5);
}
else if (wonderchoice == 2) {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWICharminarGate2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWITajMahal3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWIAgraFort4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWITowerOfVictory5);
}
else {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWITajMahal2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWIKarniMata3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWITowerOfVictory4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWICharminarGate5);
}

aiChat(1,"Wonders age2:"+xsArrayGetInt(gAsianWonders, 0)+":"+kbGetUnitTypeName(xsArrayGetInt(gAsianWonders, 0)));
aiChat(1,"Wonders age3:"+xsArrayGetInt(gAsianWonders, 1)+":"+kbGetUnitTypeName(xsArrayGetInt(gAsianWonders, 1)));
aiChat(1,"Wonders age4:"+xsArrayGetInt(gAsianWonders, 2)+":"+kbGetUnitTypeName(xsArrayGetInt(gAsianWonders, 2)));
aiChat(1,"Wonders age5:"+xsArrayGetInt(gAsianWonders, 3)+":"+kbGetUnitTypeName(xsArrayGetInt(gAsianWonders, 3)));
}

age3a.exe Screenshot 2023.09.03 - 20.44.46.05.jpg

こはね发表于 2023-9-3 21:12:43
最后,BUG自测,好像是因为我之前帮你测试删除红堡的原因,现在改了印度AI,进入殖民时代后不会再升级。

而用中国禁掉时代2孔庙是成功的
if ((cMyCiv == cCivChinese) || (cMyCiv == cCivSPCChinese)) {
//Confucian Academy, Porcelain Tower, Summer Palace, Temple of Heaven, White Pagoda
//wonderchoice = 0;
if (wonderchoice == 0) {
//xsArraySetInt(gAsianWonders, 0, cUnitTypeypWCConfucianAcademy2);
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWCWhitePagoda2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWCPorcelainTower3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWCSummerPalace4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWCTempleOfHeaven5);
}
else if (wonderchoice == 1) {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWCWhitePagoda2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWCConfucianAcademy3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWCSummerPalace4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWCPorcelainTower5);
}
else if (wonderchoice == 2) {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWCSummerPalace2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWCWhitePagoda3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWCTempleOfHeaven4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWCConfucianAcademy5);
}
else {
xsArraySetInt(gAsianWonders, 0, cUnitTypeypWCTempleOfHeaven2);
xsArraySetInt(gAsianWonders, 1, cUnitTypeypWCWhitePagoda3);
xsArraySetInt(gAsianWonders, 2, cUnitTypeypWCSummerPalace4);
xsArraySetInt(gAsianWonders, 3, cUnitTypeypWCConfucianAcademy5);
}

aiChat(1,"wonderchoice:"+wonderchoice);
aiChat(1,"Wonders age2:"+xsArrayGetInt(gAsianWonders, 0)+":"+kbGetUnitTypeName(xsArrayGetInt(gAsianWonders, 0)));
aiChat(1,"Wonders age3:"+xsArrayGetInt(gAsianWonders, 1)+":"+kbGetUnitTypeName(xsArrayGetInt(gAsianWonders, 1)));
aiChat(1,"Wonders age4:"+xsArrayGetInt(gAsianWonders, 2)+":"+kbGetUnitTypeName(xsArrayGetInt(gAsianWonders, 2)));
aiChat(1,"Wonders age5:"+xsArrayGetInt(gAsianWonders, 3)+":"+kbGetUnitTypeName(xsArrayGetInt(gAsianWonders, 3)));

}

age3a.exe Screenshot 2023.09.03 - 21.03.04.40.jpg

age3a.exe Screenshot 2023.09.03 - 21.03.26.21.jpg

另外像这种故意找茬的bug设定是不行的,多个时代使用同种奇观,升级一次时代后,虽然你的新奇观建造好了,但因为你的科技被禁用了,无法再次升级
age3a.exe Screenshot 2023.09.03 - 21.18.39.39.jpg

沉默的lsp发表于 2023-9-5 20:19:43
我用的是UTT3.4,就是三合一版的2018年的一个AI。谢谢羽大,但是我这么改了之后AI还是时代2造红堡啊,不知道为什么。要不那个AI文件,我qq上发你,周末有空帮忙看一下
沉默的lsp发表于 2023-9-5 20:29:29
沉默的lsp发表于 2023-9-6 19:00:11
青天小羽 发表于 2023-9-3 21:12
最后,BUG自测,好像是因为我之前帮你测试删除红堡的原因,现在改了印度AI,进入殖民时代后不会再升级。

...


我用的是UTT3.4,就是三合一版的2018年的一个AI。谢谢羽大,但我这么改了之后AI还是时代2造红堡啊,不知道为什么
こはね发表于 2023-9-6 21:41:04
UTT似乎是通过设定积分方式+随机设定增减积分,最后用for循环得出最高分的奇观,不解释太清楚;关联的地方太多,解释起来太麻烦;总之与原版的AI相比很高级就对了,原版是随机胡乱设定,UTT是根据pvp战术设定

[(int )] aiGetPoliticianListByIndex(int age, int index): Gets the index'th Politicans avaiable for AgeX. 返回可用的升级时代科技ID[(int )] aiGetPoliticianListCount(int age): Gets the number of Politicans avaiable for AgeX. 返回当前时代可用的升级时代科技数量
switch循环获得当前时代对应代码
用for循环遍历,范围0~numChoices(当前时代可用的升级时代科技数量)-1;如果politician(升级时代科技ID)等于设定好的科技ID,则设定积分加减;通过for循环筛选最高分数,然后得出bestChoice ,最后利用预先设定好的数组gAge2WonderList,根据bestChoice获取对应的奇观ID;最后整个函数返回奇观的unitID

不想去理解代码的话,直接把if (politician == cTechYPWonderIndianAgra2) {...}里面的数组值调低就行;下面的代码已用粗体字标出,红色即为分数,我把它设定成-100了
Age of Empires III  The Asian Dynasties Screenshot 2023.09.06 - 21.01.47.54.jpg

Age of Empires III  The Asian Dynasties Screenshot 2023.09.06 - 21.03.13.34.jpg

//==============================================================================
//int chooseAsianWonder()
//==============================================================================
// Chooses age-up wonders for Asian civilizations

int chooseAsianWonder()
{
int numChoices = -1;
int politician = -1;
int ageUpWonder = -1;
int bestChoice = 0;
int bestScore = 0;

for (i=0; <6)
xsArraySetInt(gAsianWonderScores, i, 0); // reset array

switch (kbGetAge())
{
case cAge1:
{
numChoices = aiGetPoliticianListCount(cAge2);
for (i=0; <numChoices)
{
politician = aiGetPoliticianListByIndex(cAge2, i);
if (politician == cTechYPWonderChinesePorcelainTower2) // slight bias against porcelain tower
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 5);
}
if ((politician == cTechYPWonderChineseSummerPalace2) && (gMyInitialStrategy <= 2)) //boom or rush.
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 5);
}
if ((politician == cTechYPWonderChineseConfucianAcademy2) && (gMyInitialStrategy == 3))
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 10);
}

if (politician == cTechYPWonderIndianAgra2) // slight bias towards agra fort
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 100);
}

if (politician == cTechYPWonderIndianTajMahal2) // avoid Taj Mahal
{
if (gMyInitialStrategy >= 2) //FF or FI
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 10);
else
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 10);
}

if ((politician == cTechYPWonderJapaneseGiantBuddha2)||(politician == cTechYPWonderJapaneseShogunate2)) // slight bias against giant buddha
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 10);
}
if (politician == cTechYPWonderJapaneseToshoguShrine2)
{
if (allyIsAI() == false)
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 10);
else
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 5);
}
if (politician == cTechYPWonderJapaneseToriiGates2)
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 5);
}

xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + aiRandInt(5));
}
for (i=0; <numChoices)
{
if (xsArrayGetInt(gAsianWonderScores, i) >= bestScore)
{
bestScore = xsArrayGetInt(gAsianWonderScores, i);
bestChoice = i;
}
}
politician = aiGetPoliticianListByIndex(cAge2, bestChoice);
aiEcho("Chosen age-up wonder: "+kbGetTechName(politician));

// Find building corresponding to chosen tech (i.e. "politician")
for (i=0; <15)
{
if (xsArrayGetInt(gAge2WonderTechList, i) == politician)
{
ageUpWonder = xsArrayGetInt(gAge2WonderList, i);
}
}
break;
}
case cAge2:
{
numChoices = aiGetPoliticianListCount(cAge3);
for (i=0; <numChoices)
{
politician = aiGetPoliticianListByIndex(cAge3, i);
if (politician == cTechYPWonderChinesePorcelainTower3) // slight bias against porcelain tower
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 5);
}
if ((politician == cTechYPWonderChineseSummerPalace3) && (gMyInitialStrategy == 3)) // FI
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 10);
}
if (politician == cTechYPWonderChineseTempleOfHeaven3) //bias against Temple Of Heaven
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 5);
}
if (politician == cTechYPWonderChineseConfucianAcademy3)
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 5);
}

if (politician == cTechYPWonderIndianAgra3) // slight bias towards agra fort
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 5);
}

if (politician == cTechYPWonderIndianTajMahal3) // avoid Taj Mahal
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 10);
}
if (politician == cTechYPWonderIndianKarniMata3)
{
if (gMyInitialStrategy == 3)
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 10);
}
if (politician == cTechYPWonderIndianCharminar3)
{
if (gMyInitialStrategy <= 1)
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 5);
}

if ((politician == cTechYPWonderJapaneseGiantBuddha3)||(politician == cTechYPWonderJapaneseShogunate3))
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 20);
}
if (politician == cTechYPWonderJapaneseGoldenPavillion3) // strong bias towards golden pavillion
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 5);
}

if (kbTechGetStatus(politician) != cTechStatusObtainable)
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 50);
}
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + aiRandInt(10));
}
for (i=0; <numChoices)
{
if (xsArrayGetInt(gAsianWonderScores, i) >= bestScore)
{
bestScore = xsArrayGetInt(gAsianWonderScores, i);
bestChoice = i;
}
}
politician = aiGetPoliticianListByIndex(cAge3, bestChoice);
aiEcho("Chosen age-up wonder: "+kbGetTechName(politician));

// Find building corresponding to chosen tech (i.e. "politician")
for (i=0; <15)
{
if (xsArrayGetInt(gAge3WonderTechList, i) == politician)
{
ageUpWonder = xsArrayGetInt(gAge3WonderList, i);
}
}
break;
}
case cAge3:
{
numChoices = aiGetPoliticianListCount(cAge4);
for (i=0; <numChoices)
{
politician = aiGetPoliticianListByIndex(cAge4, i);
if (politician == cTechYPWonderChinesePorcelainTower4) // strong bias towards porcelain tower
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 10);
}
if (politician == cTechYPWonderChineseTempleOfHeaven4) //bias against Temple Of Heaven
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 5);
}

if (politician == cTechYPWonderIndianCharminar4) // strong bias towards charminar gate
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 10);
}
if (politician == cTechYPWonderIndianTajMahal4) // avoid Taj Mahal
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 10);
}

if (politician == cTechYPWonderJapaneseGiantBuddha4) // slight bias against giant buddha
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 10);
}
if (politician == cTechYPWonderJapaneseGoldenPavillion4) // strong bias towards golden pavillion
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 5);
}
if (politician == cTechYPWonderJapaneseShogunate4) // strong bias towards shogunate
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 10);
}

if (kbTechGetStatus(politician) != cTechStatusObtainable)
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 50);
}
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + aiRandInt(10));
}
for (i=0; <numChoices)
{
if (xsArrayGetInt(gAsianWonderScores, i) >= bestScore)
{
bestScore = xsArrayGetInt(gAsianWonderScores, i);
bestChoice = i;
}
}
politician = aiGetPoliticianListByIndex(cAge4, bestChoice);
aiEcho("Chosen age-up wonder: "+kbGetTechName(politician));

// Find building corresponding to chosen tech (i.e. "politician")
for (i=0; <15)
{
if (xsArrayGetInt(gAge4WonderTechList, i) == politician)
{
ageUpWonder = xsArrayGetInt(gAge4WonderList, i);
}
}
break;
}
case cAge4:
{
numChoices = aiGetPoliticianListCount(cAge5);
for (i=0; <numChoices)
{
politician = aiGetPoliticianListByIndex(cAge5, i);
if (politician == cTechYPWonderChinesePorcelainTower5) // strong bias towards porcelain tower
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 10);
}
if (politician == cTechYPWonderChineseTempleOfHeaven5) // avoid temple of heaven
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 10);
}
if (politician == cTechYPWonderIndianCharminar5) // strong bias towards charminar gate
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 10);
}
if (politician == cTechYPWonderIndianTajMahal5) // avoid Taj Mahal
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 10);
}
if (politician == cTechYPWonderJapaneseGiantBuddha5) // slight bias against giant buddha
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 10);
}
if (politician == cTechYPWonderJapaneseGoldenPavillion5) // strong bias towards golden pavillion
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 10);
}
if (politician == cTechYPWonderJapaneseShogunate5) // strong bias towards shogunate
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 10);
}
if (kbTechGetStatus(politician) != cTechStatusObtainable)
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) - 50);
}
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + aiRandInt(10));
}
for (i=0; <numChoices)
{
if (xsArrayGetInt(gAsianWonderScores, i) >= bestScore)
{
bestScore = xsArrayGetInt(gAsianWonderScores, i);
bestChoice = i;
}
}
politician = aiGetPoliticianListByIndex(cAge5, bestChoice);
aiEcho("Chosen age-up wonder: "+kbGetTechName(politician));

// Find building corresponding to chosen tech (i.e. "politician")
for (i=0; <15)
{
if (xsArrayGetInt(gAge5WonderTechList, i) == politician)
{
ageUpWonder = xsArrayGetInt(gAge5WonderList, i);
}
}
break;
}
}

aiEcho("Chosen age-up wonder: "+kbGetProtoUnitName(ageUpWonder));
return(ageUpWonder);
}

当你把分数调高后,每次必出红堡
if (politician == cTechYPWonderIndianAgra2) // slight bias towards agra fort
{
xsArraySetInt(gAsianWonderScores, i, xsArrayGetInt(gAsianWonderScores, i) + 100);
}Age of Empires III  The Asian Dynasties Screenshot 2023.09.06 - 21.45.24.87.jpg
こはね发表于 2023-9-6 22:26:54


如果可以的話,請直接將命令表(帝國3專用函數)丟給chatGPT,讓其分析AI代碼,雖然結果可能會不太行,但總體上還算不錯
chatgpt2.png

這段代碼看起來是一個遊戲AI的部分,用於選擇特定時代的奇蹟建築(wonders)作為升級選擇。我會為你進行一些解釋:

1. 代碼一開始定義了一些用於操作數組(array)的函數,這些函數用於創建整數數組,設置數組元素的值,並從數組中獲取值。

2. 之後,代碼創建了多個不同時代(Age)的奇蹟列表(wonder list)數組。每個時代都有一個奇蹟列表,其中包含了該時代可用的奇蹟的ID。這些數組使用 `xsArrayCreateInt` 函數創建,然後使用 `xsArraySetInt` 函數設置每個奇蹟的ID。

3. 在代碼的主體部分,使用 `switch` 語句檢查當前的遊戲時代(kbGetAge()),然後根據時代選擇適當的奇蹟進行升級。

4. 在每個不同的時代情況下,代碼使用 `aiGetPoliticianListCount` 和 `aiGetPoliticianListByIndex` 函數來獲取可用的政治家(politician)選項的數量以及每個政治家的ID。然後,代碼對每個政治家進行評分,並根據一些條件進行不同的分數調整。

5. 最終,代碼選擇分數最高的政治家(奇蹟)作為升級選擇,並找到相應的建築物(ageUpWonder),然後返回它的ID。

6. 代碼還使用了 `aiEcho` 函數來輸出一些調試信息。

總之,這段代碼是一個基於遊戲時代和政治家選項的智能選擇系統,它評估不同的政治家選項並選擇最佳的奇蹟建築以進行升級。如果你有任何特定的問題或需要進一步的解釋,請隨時提問。

因為漏了幾行代碼,又重新生成一次

chatgpt1.png

`chooseAsianWonder()` 函数的目的是为亚洲文明选择一个时代提升奇迹(Wonder)。以下是该函数的详细分析:

1. 首先,声明了一些变量,包括 `numChoices`(可用的政治家数量)、`politician`(当前正在考虑的政治家)、`ageUpWonder`(选择的时代提升奇迹)、`bestChoice`(得分最高的政治家的索引)和 `bestScore`(最高得分)。

2. 接下来,根据当前的游戏时代,进入一个 `switch` 语句,以确定选择时代提升奇迹的政治家。根据时代的不同,会有不同的政治家可供选择。

3. 对于每个时代,都会执行类似的操作:
- 计算可用政治家的数量(`numChoices`)。
- 针对每个政治家,根据一系列条件来评分政治家。这些条件通常是关于特定的政治家(例如,中国的夏宫)或策略(例如,初期的经济发展或军事冲突)。
- 对每个政治家的得分进行随机的微小增加(`aiRandInt(10)`)。
- 在评分完成后,找到得分最高的政治家,并将其索引存储在 `bestChoice` 中。

4. 找到了最高得分的政治家后,将该政治家的信息打印到游戏日志中(使用 `aiEcho` 函数)。

5. 然后,根据选定的政治家查找对应的时代提升奇迹(`ageUpWonder`),以便在之后的游戏中建造它。

6. 最后,将选择的时代提升奇迹的 ProtoUnit(建筑或单位)的名称打印到游戏日志中,并返回该 ProtoUnit。

总之,`chooseAsianWonder()` 函数根据游戏时代和一系列条件,评估不同的政治家并选择一个,然后确定该政治家对应的时代提升奇迹,最后将其信息打印出来并返回。这个函数的目的是帮助游戏AI智能地选择适合当前游戏状态的时代提升奇迹。

  • 沉默的lsp : nb!这下终于实现稳定时代3红堡了!羽大nb!
沉默的lsp发表于 2023-9-7 21:06:55
青天小羽 发表于 2023-9-6 22:26
如果可以的話,請直接將命令表(帝國3專用函數)丟給chatGPT,讓其分析AI代碼,雖然結果可能會 ...


nb!这下终于实现稳定时代3红堡了!羽大nb!
能不能帮忙看一下rule forwardBaseManager下面哪个是关于堡垒位置的代码,因为UTT3.4把AI的前置堡垒改成放在地图中央了,我想改回以前堡垒直接压在玩家门口的情况。
  • こはね : 不想看,因为红堡那里我找了半个小时;不仅要前后分析代码,还要去命令表查函数;
  • 沉默的lsp 回复 こはね : 辛苦羽大!那推荐个PC端好用的梯子好不,我怕网上随便找到的有木马。我手机上用谷歌浏览器登CHATGPT不知道为什么登录后是一片空白,手机的梯子在电脑上用不了,搞了半天花钱买的GPT账号没用上。又试了试文心一言,又说不清楚。结果搞了两小时啥都没搞懂!气死了
  • こはね 回复 沉默的lsp : 我不需要爬梯,外网都是直连的,没有任何墙;顺便提一下,chatGPT账号我都注册几个了,但是没办法回天朝注册墙内软件账号
沉默的lsp发表于 2023-9-8 22:33:01
青天小羽 发表于 2023-9-6 22:26
如果可以的話,請直接將命令表(帝國3專用函數)丟給chatGPT,讓其分析AI代碼,雖然結果可能會 ...

你他娘还是富哥+外宾!羽大给个qq,qq海外应该也有吧,我要上贡红包288报答你这些年来的无私帮助,顺便请你帮忙放大一下碉堡,我刚刚买了正版然后又花两小时下了3dmax,一想到明天早上起来还要去b站学这个完全陌生的软件,再结合站内的视频,我头都要大了 我的龟龟 专业的事还是教给专业的人做吧,羽大给个上贡的联系方式!
  • こはね : QQ没办法注册,当前情况是墙外进不了墙内(几年前就开始了);上贡方式,直接帮忙给服务器续费就行
跳转到