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了
//============================================================================== //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); }
|