Commit 3e009cfc authored by nanahira's avatar nanahira

Merge branch 'auto' of github.com:jwyxym/windbot

parents 91288ccf 30073258
Pipeline #25616 passed with stages
in 49 seconds
...@@ -11,11 +11,11 @@ namespace WindBot.Game.AI.Decks ...@@ -11,11 +11,11 @@ namespace WindBot.Game.AI.Decks
[Deck("AutoChess", "AI_Test", "Test")] [Deck("AutoChess", "AI_Test", "Test")]
public class AutoChessExecutor : DefaultExecutor public class AutoChessExecutor : DefaultExecutor
{ {
public AutoChessExecutor(GameAI ai, Duel duel) public AutoChessExecutor(GameAI ai, Duel duel)
: base(ai, duel) : base(ai, duel)
{ {
AddExecutor(ExecutorType.SpSummon); AddExecutor(ExecutorType.SpSummon, SPSummonFunction);
AddExecutor(ExecutorType.Activate, PendulumActivateFunction); AddExecutor(ExecutorType.Activate, PendulumActivateFunction);
AddExecutor(ExecutorType.Activate, EquipEffectActivateFunction); AddExecutor(ExecutorType.Activate, EquipEffectActivateFunction);
AddExecutor(ExecutorType.Activate, EquipActivateFunction); AddExecutor(ExecutorType.Activate, EquipActivateFunction);
...@@ -94,9 +94,58 @@ namespace WindBot.Game.AI.Decks ...@@ -94,9 +94,58 @@ namespace WindBot.Game.AI.Decks
{ {
HintMsg.SpSummon, HintMsg.ToGrave, HintMsg.AddToHand, HintMsg.FusionMaterial, HintMsg.Destroy HintMsg.SpSummon, HintMsg.ToGrave, HintMsg.AddToHand, HintMsg.FusionMaterial, HintMsg.Destroy
}; };
//非常愚蠢的穷举函数 private bool p_summoning = false;
private bool BlackmailAttackerSunmmon(ClientCard card)//黑手!(其实是碰瓷)
/*
函数目录 Function Catalogue
卡片过滤函数
碰瓷怪检测
BlackmailAttackerSunmmon(ClientCard card)
BlackmailAttackerSunmmon2(int cardId)
BlackmailAttacker(ClientCard card, ClientField player)
不可通招怪兽检测
DontSummon(ClientCard card)
反转怪兽检测
FilpMonster(ClientCard card)
装备检测
EquipForEnemy(ClientCard card)
卡片选择检测
EnemyCardTarget(ClientCard card, bool chkc, CardLocation loc, CardType[] type, CardPosition[] pos)
得到某个位置的卡片的函数(从神数不神那借来的)
GetZoneCards(CardLocation loc, ClientField player)
系统提示检测
HintFunction(int hint, int last, int[] except)
卡片发动过滤函数
灵摆刻度设置
PendulumActivateFunction()
装备卡的发动
EquipActivateFunction()
装备卡的效果的发动
EquipEffectActivateFunction()
其他
ActivateFunction()
怪兽相关函数
改变表示形式
MonsterRepos()
通常召唤
MonsterSummon()
盖放
MonsterSet()
特殊召唤
SPSummonFunction()
OnSelect函数重写
选择卡片
OnSelectCard(IList<ClientCard> _cards, int min, int max, int hint, bool cancelable)
选择效果的选项
OnSelectOption(IList<int> options)
选择特殊召唤时的表示形式
OnSelectPosition(int cardId, IList<CardPosition> positions)
选择攻击对象
OnSelectAttackTarget(ClientCard attacker, IList<ClientCard> defenders)
*/
private bool BlackmailAttackerSunmmon(ClientCard card)
{ {
int[] cardsname = new[] {34031284, 35494087, 54366836, 94004268, 97403510, 59627393, 93730230, 69058960, 95442074, 24874631}; int[] cardsname = new[] {34031284, 35494087, 54366836, 94004268, 97403510, 59627393, 93730230, 69058960, 95442074, 24874631};
foreach(int cardname in cardsname) foreach(int cardname in cardsname)
...@@ -126,7 +175,7 @@ namespace WindBot.Game.AI.Decks ...@@ -126,7 +175,7 @@ namespace WindBot.Game.AI.Decks
return false; return false;
} }
private bool BlackmailAttacker(ClientCard card, ClientField player)//让你知道什么是黑手! private bool BlackmailAttacker(ClientCard card, ClientField player)
{ {
if (!card.IsDisabled()) if (!card.IsDisabled())
{ {
...@@ -154,7 +203,7 @@ namespace WindBot.Game.AI.Decks ...@@ -154,7 +203,7 @@ namespace WindBot.Game.AI.Decks
} }
private bool DontSummon(ClientCard card)//别通召这些 private bool DontSummon(ClientCard card)
{ {
if (card.HasSetcode(0x40) || card.HasSetcode(0xa4) || card.HasSetcode(0xd3)) return true; if (card.HasSetcode(0x40) || card.HasSetcode(0xa4) || card.HasSetcode(0xd3)) return true;
int[] cardsname = new[] {74762582, 90179822, 16759958, 26964762, 42352091, 2511, 74018812, 76214441, 62886670, 69105797, 32391566, 94076521, 73625877, 1980574, 42090294, 68823957, 34976176, 89785779, 76133574, 3248469, 87102774 int[] cardsname = new[] {74762582, 90179822, 16759958, 26964762, 42352091, 2511, 74018812, 76214441, 62886670, 69105797, 32391566, 94076521, 73625877, 1980574, 42090294, 68823957, 34976176, 89785779, 76133574, 3248469, 87102774
...@@ -174,7 +223,7 @@ namespace WindBot.Game.AI.Decks ...@@ -174,7 +223,7 @@ namespace WindBot.Game.AI.Decks
return false; return false;
} }
private bool FilpMonster(ClientCard card)//反转 private bool FilpMonster(ClientCard card)
{ {
if (card.HasType(CardType.Flip)) return true; if (card.HasType(CardType.Flip)) return true;
int[] cardsname = new[] {20073910, 89707961, 41753322, 86346363, 75421661, 87483942, 40659562, 41039846, 72370114, 92693205, 22134079, 16509093, 96352326, 923596, 47111934, 81306586, 26016357, 52323207, 64804316, 75209824, 71071546, 92736188, 16279989, 97584500, 72913666, 71415349, 51196805, 85463083, 41872150, 75109441, 3510565, 15383415, 2326738, 80885284, 84472026, 93294869, 27491571, 54490275, 36239585, 2694423, 81278754, 24101897, 46925518, 99641328, 61318483, 54512827, 81907872, 98707192 int[] cardsname = new[] {20073910, 89707961, 41753322, 86346363, 75421661, 87483942, 40659562, 41039846, 72370114, 92693205, 22134079, 16509093, 96352326, 923596, 47111934, 81306586, 26016357, 52323207, 64804316, 75209824, 71071546, 92736188, 16279989, 97584500, 72913666, 71415349, 51196805, 85463083, 41872150, 75109441, 3510565, 15383415, 2326738, 80885284, 84472026, 93294869, 27491571, 54490275, 36239585, 2694423, 81278754, 24101897, 46925518, 99641328, 61318483, 54512827, 81907872, 98707192
...@@ -187,7 +236,7 @@ namespace WindBot.Game.AI.Decks ...@@ -187,7 +236,7 @@ namespace WindBot.Game.AI.Decks
return false; return false;
} }
private bool EquipForEnemy(ClientCard card)//装备给对手 private bool EquipForEnemy(ClientCard card)
{ {
int[] cardsname = new[] {33453260, 79912449, 32919136, 45986603, 45247637, 44092304, 46967601, 94303232, 56948373, 69954399, 83584898, 62472614, 75560629, 23842445, 24668830, 98867329, 50152549, 62472614 int[] cardsname = new[] {33453260, 79912449, 32919136, 45986603, 45247637, 44092304, 46967601, 94303232, 56948373, 69954399, 83584898, 62472614, 75560629, 23842445, 24668830, 98867329, 50152549, 62472614
}; };
...@@ -199,7 +248,225 @@ namespace WindBot.Game.AI.Decks ...@@ -199,7 +248,225 @@ namespace WindBot.Game.AI.Decks
return false; return false;
} }
//从神数不神那借来的非常有亲切感的函数 Duel.GetMatchingGroup(不是) private bool EnemyCardTarget(ClientCard card, bool chkc, CardLocation loc, CardType[] type, CardPosition[] pos)
{
int a = 0;
int b = 0;
int[] cardsname;
foreach (CardType ty in type)
{
if (ty == CardType.Spell)
a++;
if (ty == CardType.Trap)
a = a + 2;
if (ty == CardType.Spell || ty == CardType.Trap || ty == CardType.Monster)
a = a + 3;
}
foreach (CardPosition po in pos)
{
if (po == CardPosition.FaceUp)
b++;
if (po == CardPosition.FaceDown)
b = b + 2;
}
if ((loc & CardLocation.MonsterZone) > 0 && (loc & CardLocation.SpellZone) > 0)
{
if (chkc)
{
if (a == 1 && b == 1)
{
if (card.Id == 76137614)
return true;
}
else if (a == 2 && b == 1)
{
if (card.Id == 5640330 && ActivateDescription == Util.GetStringId(5640330, 1))
return true;
}
else if (a == 3 && b == 1)
{
cardsname = new[] {10071151, 14883228, 43785278, 44852429, 69452756, 76137614, 80019195, 80275707, 84565800, 85800949
};
foreach(int cardname in cardsname)
{
if (card.Id == cardname) return true;
}
if ((card.Id == 5133471 && ActivateDescription == Util.GetStringId(5133471, 1)) || (card.Id == 17241941 && ActivateDescription == Util.GetStringId(17241941, 2)))
return true;
}
else if (a == 3 && b == 2)
{
cardsname = new[] {25955749, 18489208, 20351153, 40736921, 61831093, 76515293
};
foreach(int cardname in cardsname)
{
if (card.Id == cardname) return true;
}
if ((card.Id == 5133471 && ActivateDescription == Util.GetStringId(5133471, 0))
|| (card.Id == 64398890 && ActivateDescription == Util.GetStringId(64398890, 0))
|| (card.Id == 73213494 && ActivateDescription == Util.GetStringId(73213494, 1))
)
return true;
}
else if (a == 3 && b == 3)
{
cardsname = new[] {5318639, 51232472, 6983839, 8267140, 22923081, 29223325, 71413901, 76471944, 89172051, 43898403
};
foreach(int cardname in cardsname)
{
if (card.Id == cardname) return true;
}
if ((card.Id == 41470137 && ActivateDescription == Util.GetStringId(41470137, 0))
|| (card.Id == 98558751 && ActivateDescription == Util.GetStringId(98558751, 0))
|| (card.Id == 49456901 && ActivateDescription == Util.GetStringId(49456901, 0))
|| (card.Id == 53618197 && ActivateDescription == Util.GetStringId(53618197, 0))
|| (card.Id == 71100270 && ActivateDescription == Util.GetStringId(71100270, 0))
|| (card.Id == 85252081 && ActivateDescription == Util.GetStringId(85252081, 0))
|| (card.Id == 89423971 && ActivateDescription == Util.GetStringId(89423971, 0))
|| (card.Id == 19025379 && ActivateDescription == Util.GetStringId(19025379, 1))
|| (card.Id == 64182380 && ActivateDescription == Util.GetStringId(64182380, 1))
|| (card.Id == 75425320 && ActivateDescription == Util.GetStringId(75425320, 2))
|| (card.Id == 10117149 && card.Location == CardLocation.MonsterZone)
|| (card.Id == 15710054 && card.Location == CardLocation.MonsterZone)
|| (card.Id == 37991342 && card.Location == CardLocation.MonsterZone)
|| (card.Id == 94454495 && card.Location == CardLocation.MonsterZone)
|| (card.Id == 35035481 && card.Location == CardLocation.SpellZone)
|| (card.Id == 75782277 && card.Location == CardLocation.SpellZone)
|| (card.Id == 51531505 && card.Location == CardLocation.SpellZone)
|| (card.Id == 97692972 && card.Location == CardLocation.SpellZone)
|| (card.Id == 18444733 && card.Location == CardLocation.SpellZone && card.IsFaceup())
|| (card.Id == 49430782 && card.Location == CardLocation.Grave)
|| (card.Id == 77723643 && card.Location == CardLocation.Grave)
|| (card.Id == 83656563 && card.Location == CardLocation.Grave)
|| (card.Id == 60362066 && card.Location != CardLocation.Grave)
)
return true;
}
else if (a == 6 && b == 1)
{
cardsname = new[] {744887, 20403123, 20745268, 23204029, 38694052, 38904695, 43892408, 48905153, 89883517, 93379652,
};
foreach(int cardname in cardsname)
{
if (card.Id == cardname) return true;
}
if ((card.Id == 5795980 && card.Location == CardLocation.SpellZone)
|| (card.Id == 9940036 && ActivateDescription == Util.GetStringId(9940036, 2))
|| (card.Id == 13364097 && ActivateDescription == Util.GetStringId(13364097, 0))
|| (card.Id == 50078320 && ActivateDescription == Util.GetStringId(50078320, 0))
|| (card.Id == 50907446 && ActivateDescription == Util.GetStringId(50907446, 0))
|| (card.Id == 65398390 && ActivateDescription == Util.GetStringId(65398390, 0))
|| (card.Id == 29601381 && ActivateDescription == Util.GetStringId(29601381, 1))
|| (card.Id == 48461764 && ActivateDescription == Util.GetStringId(48461764, 1))
|| (card.Id == 94073244 && ActivateDescription == Util.GetStringId(94073244, 1))
|| (card.Id == 13317419 && card.Location == CardLocation.SpellZone && card.IsFaceup())
|| (card.Id == 37491810 && card.Location == CardLocation.SpellZone && card.IsFaceup())
|| (card.Id == 38761908 && card.Location == CardLocation.SpellZone)
)
return true;
}
else if (a == 6 && b == 2)
{
cardsname = new[] {60229110, 93554166, 99940363, 15545291, 58475908
};
foreach(int cardname in cardsname)
{
if (card.Id == cardname) return true;
}
if ((card.Id == 20281581 && ActivateDescription == Util.GetStringId(20281581, 1))
|| (card.Id == 31467949 && ActivateDescription == Util.GetStringId(31467949, 1))
|| (card.Id == 32912040 && ActivateDescription == Util.GetStringId(32912040, 0))
)
return true;
}
else if (a == 6 && b == 3)
{
cardsname = new[] {744887, 4178474, 5168381, 9765723, 13298352, 18318842, 19943114, 22850702, 28016193, 28112535, 28423537, 28711704, 29477860, 29479265, 32785578, 33846209, 33964637
, 35252119, 35330871, 38265153, 38342335, 43215738, 43912676, 44553392, 47264717, 48626373, 55794644, 56804361, 65192027, 65892310, 68182934, 69764158, 71279983, 72959823, 73964868
, 76552147, 77449773, 83102080, 84125619, 84453939, 89211486, 97317530, 14154221, 17494901, 31677606, 66789970, 72044448, 78156759, 84290642, 85893201
};
foreach(int cardname in cardsname)
{
if (card.Id == cardname) return true;
}
if (card.Id == 1561110 && ActivateDescription == Util.GetStringId(1561110, 0)
|| (card.Id == 4779823 && ActivateDescription == Util.GetStringId(4779823, 0))
|| (card.Id == 23626223 && ActivateDescription == Util.GetStringId(23626223, 0))
|| (card.Id == 26692769 && ActivateDescription == Util.GetStringId(26692769, 0))
|| (card.Id == 32617464 && ActivateDescription == Util.GetStringId(32617464, 0))
|| (card.Id == 32939238 && ActivateDescription == Util.GetStringId(32939238, 0))
|| (card.Id == 36609518 && ActivateDescription == Util.GetStringId(36609518, 0))
|| (card.Id == 38267552 && ActivateDescription == Util.GetStringId(38267552, 0))
|| (card.Id == 50056656 && ActivateDescription == Util.GetStringId(50056656, 0))
|| (card.Id == 79194594 && ActivateDescription == Util.GetStringId(79194594, 0))
|| (card.Id == 84815190 && ActivateDescription == Util.GetStringId(84815190, 0))
|| (card.Id == 90835938 && ActivateDescription == Util.GetStringId(90835938, 0))
|| (card.Id == 98462037 && ActivateDescription == Util.GetStringId(98462037, 0))
|| (card.Id == 43227 && ActivateDescription == Util.GetStringId(43227, 1))
|| (card.Id == 2530830 && ActivateDescription == Util.GetStringId(2530830, 1))
|| (card.Id == 6764709 && ActivateDescription == Util.GetStringId(6764709, 1))
|| (card.Id == 12444060 && ActivateDescription == Util.GetStringId(12444060, 1))
|| (card.Id == 10406322 && ActivateDescription == Util.GetStringId(10406322, 1))
|| (card.Id == 13482262 && ActivateDescription == Util.GetStringId(13482262, 1))
|| (card.Id == 20563387 && ActivateDescription == Util.GetStringId(20563387, 1))
|| (card.Id == 21113684 && ActivateDescription == Util.GetStringId(21113684, 1))
|| (card.Id == 22110647 && ActivateDescription == Util.GetStringId(22110647, 1))
|| (card.Id == 22908820 && ActivateDescription == Util.GetStringId(22908820, 1))
|| (card.Id == 28373620 && ActivateDescription == Util.GetStringId(28373620, 1))
|| (card.Id == 34481518 && ActivateDescription == Util.GetStringId(34481518, 1))
|| (card.Id == 40732515 && ActivateDescription == Util.GetStringId(40732515, 1))
|| (card.Id == 46294982 && ActivateDescription == Util.GetStringId(46294982, 1))
|| (card.Id == 61307542 && ActivateDescription == Util.GetStringId(61307542, 1))
|| (card.Id == 63101468 && ActivateDescription == Util.GetStringId(63101468, 1))
|| (card.Id == 73667937 && ActivateDescription == Util.GetStringId(73667937, 1))
|| (card.Id == 81055000 && ActivateDescription == Util.GetStringId(81055000, 1))
|| (card.Id == 83533296 && ActivateDescription == Util.GetStringId(83533296, 1))
|| (card.Id == 87188910 && ActivateDescription == Util.GetStringId(87188910, 1))
|| (card.Id == 90579153 && ActivateDescription == Util.GetStringId(90579153, 1))
|| (card.Id == 95207988 && ActivateDescription == Util.GetStringId(95207988, 1))
|| (card.Id == 5973663 && ActivateDescription == Util.GetStringId(5973663, 1))
|| (card.Id == 11132674 && ActivateDescription == Util.GetStringId(11132674, 2))
|| (card.Id == 28798938 && ActivateDescription == Util.GetStringId(28798938, 2))
|| (card.Id == 30989084 && ActivateDescription == Util.GetStringId(30989084, 2))
|| (card.Id == 37495766 && ActivateDescription == Util.GetStringId(37495766, 2))
|| (card.Id == 91336701 && ActivateDescription == Util.GetStringId(91336701, 2))
|| (card.Id == 73734821 && ActivateDescription == Util.GetStringId(73734821, 3))
|| (card.Id == 13073850 && card.Location == CardLocation.MonsterZone)
|| (card.Id == 15130912 && card.Location == CardLocation.MonsterZone)
|| (card.Id == 35187185 && card.Location == CardLocation.MonsterZone)
|| (card.Id == 47021196 && card.Location == CardLocation.MonsterZone)
|| (card.Id == 47963370 && card.Location == CardLocation.MonsterZone)
|| (card.Id == 56638325 && card.Location == CardLocation.MonsterZone)
|| (card.Id == 66698383 && card.Location == CardLocation.MonsterZone)
|| (card.Id == 74122412 && card.Location == CardLocation.MonsterZone)
|| (card.Id == 86585274 && card.Location == CardLocation.MonsterZone)
|| (card.Id == 36148308 && card.Location == CardLocation.SpellZone)
|| (card.Id == 54807656 && card.Location == CardLocation.SpellZone)
|| (card.Id == 57736667 && card.Location == CardLocation.SpellZone)
|| (card.Id == 60176682 && card.Location == CardLocation.SpellZone)
|| (card.Id == 69207766 && card.Location == CardLocation.SpellZone)
|| (card.Id == 71817640 && card.Location == CardLocation.SpellZone)
|| (card.Id == 71832012 && card.Location == CardLocation.SpellZone)
|| (card.Id == 77103950 && card.Location == CardLocation.SpellZone)
|| (card.Id == 87091930 && card.Location == CardLocation.SpellZone)
|| (card.Id == 88667504 && card.Location == CardLocation.SpellZone)
|| (card.Id == 35834119 && card.Location == CardLocation.Grave)
|| (card.Id == 44536921 && card.Location == CardLocation.Grave)
|| (card.Id == 80532587 && card.Location == CardLocation.Grave)
|| (card.Id == 95440946 && card.Location == CardLocation.Hand)
|| (card.Id == 53804307 && card.Location == CardLocation.Hand)
|| (card.Id == 28865322 && card.Location != CardLocation.Hand)
)
return true;
}
}
}
return false;
}
private List<ClientCard> GetZoneCards(CardLocation loc, ClientField player) private List<ClientCard> GetZoneCards(CardLocation loc, ClientField player)
{ {
List<ClientCard> res = new List<ClientCard>(); List<ClientCard> res = new List<ClientCard>();
...@@ -212,107 +479,20 @@ namespace WindBot.Game.AI.Decks ...@@ -212,107 +479,20 @@ namespace WindBot.Game.AI.Decks
if ((loc & CardLocation.Extra) > 0) { temp = player.ExtraDeck.Where(card => card != null).ToList(); if (temp.Count() > 0) res.AddRange(temp); } if ((loc & CardLocation.Extra) > 0) { temp = player.ExtraDeck.Where(card => card != null).ToList(); if (temp.Count() > 0) res.AddRange(temp); }
return res; return res;
} }
public override IList<ClientCard> OnSelectCard(IList<ClientCard> _cards, int min, int max, int hint, bool cancelable)
{
if (Duel.Phase == DuelPhase.BattleStart)
return null;
if (AI.HaveSelectedCards())
return null;
IList<ClientCard> selected = new List<ClientCard>();
IList<ClientCard> cards = new List<ClientCard>(_cards);
if (max > cards.Count)
max = cards.Count;
if (HintMsgForEnemy.Contains(hint))
{
IList<ClientCard> enemyCards = cards.Where(card => card.Controller == 1).ToList();
// select enemy's card first
while (enemyCards.Count > 0 && selected.Count < max)
{
ClientCard card = enemyCards[Program.Rand.Next(enemyCards.Count)];
selected.Add(card);
enemyCards.Remove(card);
cards.Remove(card);
}
}
if (HintMsgForDeck.Contains(hint))
{
IList<ClientCard> deckCards = cards.Where(card => card.Location == CardLocation.Deck).ToList();
// select deck's card first
while (deckCards.Count > 0 && selected.Count < max)
{
ClientCard card = deckCards[Program.Rand.Next(deckCards.Count)];
selected.Add(card);
deckCards.Remove(card);
cards.Remove(card);
}
}
if (HintMsgForSelf.Contains(hint)) private bool HintFunction(int hint, int last, int[] except)
{ {
IList<ClientCard> botCards = cards.Where(card => card.Controller == 0).ToList(); for (int i = 500; i <= 500 + last; i++)
// select bot's card first
while (botCards.Count > 0 && selected.Count < max)
{
ClientCard card = botCards[Program.Rand.Next(botCards.Count)];
selected.Add(card);
botCards.Remove(card);
cards.Remove(card);
}
}
if (HintMsgForMaterial.Contains(hint))
{
IList<ClientCard> materials = cards.OrderBy(card => card.Attack).ToList();
// select low attack first
while (materials.Count > 0 && selected.Count < min)
{
ClientCard card = materials[0];
selected.Add(card);
materials.Remove(card);
cards.Remove(card);
}
}
// select random cards
while (selected.Count < min)
{
ClientCard card = cards[Program.Rand.Next(cards.Count)];
selected.Add(card);
cards.Remove(card);
}
if (HintMsgForMaxSelect.Contains(hint))
{
// select max cards
while (selected.Count < max)
{
ClientCard card = cards[Program.Rand.Next(cards.Count)];
selected.Add(card);
cards.Remove(card);
}
}
if (hint == HintMsg.SpSummon && max == 1)
{ {
foreach (ClientCard card in cards) foreach (int ex in except)
{ {
if (card.IsCode(60461804)) if (i == ex)
return new List<ClientCard>(new[] { card }); i++;
} }
if (hint == i)
return true;
} }
return false;
return selected;
}
public override int OnSelectOption(IList<int> options)
{
return Program.Rand.Next(options.Count);
} }
private bool PendulumActivateFunction() private bool PendulumActivateFunction()
...@@ -423,32 +603,17 @@ namespace WindBot.Game.AI.Decks ...@@ -423,32 +603,17 @@ namespace WindBot.Game.AI.Decks
if (Card.Id == 32939238) if (Card.Id == 32939238)
{ {
cards = GetZoneCards(CardLocation.Onfield, Enemy).Where(card => card != null && !card.IsShouldNotBeTarget()).ToList(); cards = GetZoneCards(CardLocation.Onfield, Enemy).Where(card => card != null && !card.IsShouldNotBeTarget()).ToList();
if (cards.Count() > 0) return cards.Count() > 0;
{
AI.SelectNextCard(cards);
return true;
}
return false;
} }
if (Card.Id == 57736667 || Card.Id == 36148308) if (Card.Id == 57736667 || Card.Id == 36148308)
{ {
cards = GetZoneCards(CardLocation.Onfield, Enemy).Where(card => card != null && !card.IsShouldNotBeTarget()).ToList(); cards = GetZoneCards(CardLocation.Onfield, Enemy).Where(card => card != null && !card.IsShouldNotBeTarget()).ToList();
if (cards.Count() > 0) return cards.Count() > 0;
{
AI.SelectCard(cards);
return true;
}
return false;
} }
if (Card.Id == 99013397 || Card.Id == 70423794 || Card.Id == 22147147) if (Card.Id == 99013397 || Card.Id == 70423794 || Card.Id == 22147147)
{ {
cards = GetZoneCards(CardLocation.Onfield, Enemy).Where(card => card != null && !card.IsShouldNotBeTarget() && (card.HasType(CardType.Spell) || card.HasType(CardType.Trap))).ToList(); cards = GetZoneCards(CardLocation.Onfield, Enemy).Where(card => card != null && !card.IsShouldNotBeTarget() && (card.HasType(CardType.Spell) || card.HasType(CardType.Trap))).ToList();
if (cards.Count() > 0) return cards.Count() > 0;
{
AI.SelectCard(cards);
return true;
}
return false;
} }
return DefaultDontChainMyself(); return DefaultDontChainMyself();
} }
...@@ -457,22 +622,12 @@ namespace WindBot.Game.AI.Decks ...@@ -457,22 +622,12 @@ namespace WindBot.Game.AI.Decks
if (Card.Id == 64867422) if (Card.Id == 64867422)
{ {
cards = GetZoneCards(CardLocation.MonsterZone, Enemy).Where(card => card != null && !card.IsShouldNotBeTarget() && card.IsFaceup()).ToList(); cards = GetZoneCards(CardLocation.MonsterZone, Enemy).Where(card => card != null && !card.IsShouldNotBeTarget() && card.IsFaceup()).ToList();
if (cards.Count() > 0) return cards.Count() > 0;
{
AI.SelectCard(cards);
return true;
}
return false;
} }
if (Card.Id == 66947913) if (Card.Id == 66947913)
{ {
cards = GetZoneCards(CardLocation.MonsterZone, Enemy).Where(card => card != null && !card.IsShouldNotBeTarget()).ToList(); cards = GetZoneCards(CardLocation.MonsterZone, Enemy).Where(card => card != null && !card.IsShouldNotBeTarget()).ToList();
if (cards.Count() > 0) return cards.Count() > 0;
{
AI.SelectCard(cards);
return true;
}
return false;
} }
return DefaultDontChainMyself(); return DefaultDontChainMyself();
} }
...@@ -483,8 +638,23 @@ namespace WindBot.Game.AI.Decks ...@@ -483,8 +638,23 @@ namespace WindBot.Game.AI.Decks
private bool ActivateFunction() private bool ActivateFunction()
{ {
IList<ClientCard> cards = new List<ClientCard>();
if (Card.HasType(CardType.Equip) || (Card.HasType(CardType.Pendulum) && Card.Location == CardLocation.Hand && ActivateDescription == 1160)) if (Card.HasType(CardType.Equip) || (Card.HasType(CardType.Pendulum) && Card.Location == CardLocation.Hand && ActivateDescription == 1160))
return false; return false;
if (EnemyCardTarget(Card, true, CardLocation.Onfield, new[] { CardType.Spell, CardType.Trap }, new[] { CardPosition.FaceUp }))
return GetZoneCards(CardLocation.Onfield, Enemy).Any(card => card != null && (card.HasType(CardType.Spell) || card.HasType(CardType.Trap)) && card.IsFaceup() && !card.IsShouldNotBeTarget());
if (EnemyCardTarget(Card, true, CardLocation.Onfield, new[] { CardType.Spell, CardType.Trap }, new[] { CardPosition.FaceDown }))
return GetZoneCards(CardLocation.Onfield, Enemy).Any(card => card != null && (card.HasType(CardType.Spell) || card.HasType(CardType.Trap)) && card.IsFacedown() && !card.IsShouldNotBeTarget());
if (EnemyCardTarget(Card, true, CardLocation.Onfield, new[] { CardType.Spell, CardType.Trap }, new[] { CardPosition.FaceUp, CardPosition.FaceDown }))
return GetZoneCards(CardLocation.Onfield, Enemy).Any(card => card != null && (card.HasType(CardType.Spell) || card.HasType(CardType.Trap)) && !card.IsShouldNotBeTarget());
if (EnemyCardTarget(Card, true, CardLocation.Onfield, new[] { CardType.Spell, CardType.Trap, CardType.Monster }, new[] { CardPosition.FaceUp }))
return GetZoneCards(CardLocation.Onfield, Enemy).Any(card => card != null && card.IsFaceup() && !card.IsShouldNotBeTarget());
if (EnemyCardTarget(Card, true, CardLocation.Onfield, new[] { CardType.Spell, CardType.Trap, CardType.Monster }, new[] { CardPosition.FaceDown }))
return GetZoneCards(CardLocation.Onfield, Enemy).Any(card => card != null && card.IsFacedown() && !card.IsShouldNotBeTarget());
if (EnemyCardTarget(Card, true, CardLocation.Onfield, new[] { CardType.Spell, CardType.Trap, CardType.Monster }, new[] { CardPosition.FaceUp, CardPosition.FaceDown }))
return GetZoneCards(CardLocation.Onfield, Enemy).Any(card => card != null && !card.IsShouldNotBeTarget());
//优化单卡是怎么想的啊喂(#`O′) //优化单卡是怎么想的啊喂(#`O′)
if (Card.Id == 60461804) if (Card.Id == 60461804)
{ {
...@@ -507,10 +677,10 @@ namespace WindBot.Game.AI.Decks ...@@ -507,10 +677,10 @@ namespace WindBot.Game.AI.Decks
{ {
if (ActivateDescription == Util.GetStringId(84815190, 0)) if (ActivateDescription == Util.GetStringId(84815190, 0))
{ {
List<ClientCard> cards = GetZoneCards(CardLocation.Onfield, Enemy); cards = GetZoneCards(CardLocation.Onfield, Enemy);
cards = cards.Where(tcard => tcard != null && !tcard.IsShouldNotBeTarget()).ToList(); cards = cards.Where(tcard => tcard != null && !tcard.IsShouldNotBeTarget()).ToList();
if (cards.Count <= 0) return false; if (cards.Count <= 0) return false;
AI.SelectCard(cards); //AI.SelectCard(cards);
return true; return true;
} }
else if (ActivateDescription == Util.GetStringId(84815190, 1)) else if (ActivateDescription == Util.GetStringId(84815190, 1))
...@@ -521,6 +691,254 @@ namespace WindBot.Game.AI.Decks ...@@ -521,6 +691,254 @@ namespace WindBot.Game.AI.Decks
} }
return DefaultDontChainMyself(); return DefaultDontChainMyself();
} }
private bool MonsterRepos()
{
if (Duel.Phase == DuelPhase.Main1 && (FilpMonster(Card)) && Card.IsFacedown())
{
return true;
}
else if (Duel.Phase == DuelPhase.Main2)
{
if (BlackmailAttacker(Card, Bot))
{
if (Card.IsFaceup() && Card.IsAttack())
return false;
if (Card.IsFaceup() && Card.IsDefense())
return true;
}
else if (Card.Defense > Card.Attack)
return DefaultMonsterRepos();
else
{
if (Card.IsFaceup() && Card.IsAttack())
return Bot.LifePoints <= 1500 && GetZoneCards(CardLocation.MonsterZone, Enemy).Count(card => card != null && card.Attack < Card.Attack) == 0 && GetZoneCards(CardLocation.MonsterZone, Enemy).Count() > 0 && Card.Attack < 1500;
else
return Bot.LifePoints > 1500 || GetZoneCards(CardLocation.MonsterZone, Enemy).Count(card => card != null && card.Attack < Card.Attack) > 0 || GetZoneCards(CardLocation.MonsterZone, Enemy).Count() == 0 || Card.Attack >= 1500;
}
return false;
}
return false;
}
private bool MonsterSummon()
{
if (DontSummon(Card))
return false;
if (BlackmailAttackerSunmmon(Card))
return DefaultMonsterSummon();
else if (FilpMonster(Card))
return false;
else if (Card.Level > 4 || Bot.LifePoints > 1500)
return DefaultMonsterSummon();
else if (Bot.LifePoints <= 1500 && GetZoneCards(CardLocation.MonsterZone, Enemy).Count(card => card != null && card.Attack < Card.Attack) > 0 || GetZoneCards(CardLocation.MonsterZone, Enemy).Count() == 0 || Card.Attack >= 1500)
return DefaultMonsterSummon();
return false;
}
private bool MonsterSet()
{
if (FilpMonster(Card))
return DefaultMonsterSummon();
if (Card.HasSetcode(0x40)) return false;
return DefaultMonsterSummon() && (Bot.LifePoints <= 1500 || (GetZoneCards(CardLocation.MonsterZone, Bot).Count() == 0 && Bot.LifePoints <= 4000));
}
private bool SPSummonFunction()
{
ClientCard l = Util.GetPZone(0, 0);
ClientCard r = Util.GetPZone(0, 1);
if ((Card == l || Card == r) && l != null && r != null)
{
int lowscales = 0;
int highscales = 0;
if (l.LScale > r.RScale)
{
lowscales = r.RScale;
highscales = l.LScale;
}
else
{
lowscales = l.LScale;
highscales = r.RScale;
}
List<ClientCard> cards = GetZoneCards(CardLocation.Hand, Bot).Where(card => card != null && !DontSummon(card) && card.Level > lowscales && card.Level < highscales).ToList();
p_summoning = true;
return cards.Count() > 0;
}
return true;
}
public override IList<ClientCard> OnSelectCard(IList<ClientCard> _cards, int min, int max, int hint, bool cancelable)
{
if (Duel.Phase == DuelPhase.BattleStart)
return null;
if (AI.HaveSelectedCards())
return null;
IList<ClientCard> selected = new List<ClientCard>();
IList<ClientCard> cards = new List<ClientCard>(_cards);
if (max > cards.Count)
max = cards.Count;
if (p_summoning || ((Card == Util.GetPZone(0, 0) || Card == Util.GetPZone(0, 1)) && hint == HintMsg.SpSummon) && Card.HasType(CardType.Pendulum))
{
List<ClientCard> result = new List<ClientCard>();
List<ClientCard> scards = cards.Where(card => card != null && !DontSummon(card)).ToList();
p_summoning = false;
if (scards.Count > 0) return Util.CheckSelectCount(result, scards, 1, 1);
else if (min == 0) return result;
}
if (HintFunction(hint, 13, new[]{506}) && !cards.Any(card => card != null && card.Controller == 1) && !cards.Any(card => card != null && card.Location != CardLocation.Hand))
{
IList<ClientCard> scards = cards.Where(card => card != null && !card.HasSetcode(0x40)).ToList();
if (scards.Count() < min)
{
IList<ClientCard> scards2 = cards.Where(card => card != null && card.HasSetcode(0x40)).ToList();
if (scards2.Count() > 0)
{
foreach (ClientCard card in scards2)
{
if (scards.Count() < min)
scards.Add(card);
}
}
}
if (scards.Count() >= min)
return Util.CheckSelectCount(scards,cards,min,max);
}
if ((HintFunction(hint, 13, new[]{501, 506, 508, 509}) || hint == 573) && cards.Any(card => card != null && card.Controller == 1) && cards.Any(card => card != null && card.Controller == 0) && !cards.Any(card => card != null && card.Location != CardLocation.Onfield))
{
IList<ClientCard> scards = cards.Where(card => card != null && card.Controller == 1).ToList();
if (scards.Count() < min)
{
IList<ClientCard> scards2 = cards.Where(card => card != null && card.Controller == 0).ToList();
if (scards2.Count() > 0)
{
foreach (ClientCard card in scards2)
{
if (scards.Count() < min)
scards.Add(card);
}
}
}
if (scards.Count() >= min)
return Util.CheckSelectCount(scards,cards,min,max);
}
if ((hint == 503 || hint == 507) && cards.Any(card => card != null && card.Controller == 1) && cards.Any(card => card != null && card.Controller == 0) && cards.Count(card => card != null && (card.Location == CardLocation.Grave || card.Location == CardLocation.Onfield)) == cards.Count())
{
IList<ClientCard> scards = cards.Where(card => card != null && card.Controller == 1).ToList();
if (scards.Count() < min)
{
IList<ClientCard> scards2 = cards.Where(card => card != null && card.Controller == 0).ToList();
if (scards2.Count() > 0)
{
foreach (ClientCard card in scards2)
{
if (scards.Count() < min)
scards.Add(card);
}
}
}
if (scards.Count() >= min)
return Util.CheckSelectCount(scards,cards,min,max);
}
if (HintMsgForEnemy.Contains(hint))
{
IList<ClientCard> enemyCards = cards.Where(card => card.Controller == 1).ToList();
// select enemy's card first
while (enemyCards.Count > 0 && selected.Count < max)
{
ClientCard card = enemyCards[Program.Rand.Next(enemyCards.Count)];
selected.Add(card);
enemyCards.Remove(card);
cards.Remove(card);
}
}
if (HintMsgForDeck.Contains(hint))
{
IList<ClientCard> deckCards = cards.Where(card => card.Location == CardLocation.Deck).ToList();
// select deck's card first
while (deckCards.Count > 0 && selected.Count < max)
{
ClientCard card = deckCards[Program.Rand.Next(deckCards.Count)];
selected.Add(card);
deckCards.Remove(card);
cards.Remove(card);
}
}
if (HintMsgForSelf.Contains(hint))
{
IList<ClientCard> botCards = cards.Where(card => card.Controller == 0).ToList();
// select bot's card first
while (botCards.Count > 0 && selected.Count < max)
{
ClientCard card = botCards[Program.Rand.Next(botCards.Count)];
selected.Add(card);
botCards.Remove(card);
cards.Remove(card);
}
}
if (HintMsgForMaterial.Contains(hint))
{
IList<ClientCard> materials = cards.OrderBy(card => card.Attack).ToList();
// select low attack first
while (materials.Count > 0 && selected.Count < min)
{
ClientCard card = materials[0];
selected.Add(card);
materials.Remove(card);
cards.Remove(card);
}
}
// select random cards
while (selected.Count < min)
{
ClientCard card = cards[Program.Rand.Next(cards.Count)];
selected.Add(card);
cards.Remove(card);
}
if (HintMsgForMaxSelect.Contains(hint))
{
// select max cards
while (selected.Count < max)
{
ClientCard card = cards[Program.Rand.Next(cards.Count)];
selected.Add(card);
cards.Remove(card);
}
}
if (hint == HintMsg.SpSummon && max == 1)
{
foreach (ClientCard card in cards)
{
if (card.IsCode(60461804))
return new List<ClientCard>(new[] { card });
}
}
return selected;
}
public override int OnSelectOption(IList<int> options)
{
return Program.Rand.Next(options.Count);
}
public override CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions) public override CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
{ {
...@@ -610,58 +1028,5 @@ namespace WindBot.Game.AI.Decks ...@@ -610,58 +1028,5 @@ namespace WindBot.Game.AI.Decks
return null; return null;
} }
private bool MonsterRepos()
{
if (Duel.Phase == DuelPhase.Main1 && (FilpMonster(Card)) && Card.IsFacedown())
{
return true;
}
else if (Duel.Phase == DuelPhase.Main2)
{
if (BlackmailAttacker(Card, Bot))
{
if (Card.IsFaceup() && Card.IsAttack())
return false;
if (Card.IsFaceup() && Card.IsDefense())
return true;
}
else if (Card.Defense > Card.Attack)
return DefaultMonsterRepos();
else
{
if (Card.IsFaceup() && Card.IsAttack())
return Bot.LifePoints <= 1500 && GetZoneCards(CardLocation.MonsterZone, Enemy).Count(card => card != null && card.Attack < Card.Attack) == 0 && GetZoneCards(CardLocation.MonsterZone, Enemy).Count() > 0 && Card.Attack < 1500;
else
return Bot.LifePoints > 1500 || GetZoneCards(CardLocation.MonsterZone, Enemy).Count(card => card != null && card.Attack < Card.Attack) > 0 || GetZoneCards(CardLocation.MonsterZone, Enemy).Count() == 0 || Card.Attack >= 1500;
}
return false;
}
return false;
}
private bool MonsterSummon()
{
if (DontSummon(Card))
return false;
if (BlackmailAttackerSunmmon(Card))
return DefaultMonsterSummon();
else if (FilpMonster(Card))
return false;
else if (Card.Level > 4 || Bot.LifePoints > 1500)
return DefaultMonsterSummon();
else if (Bot.LifePoints <= 1500 && GetZoneCards(CardLocation.MonsterZone, Enemy).Count(card => card != null && card.Attack < Card.Attack) > 0 || GetZoneCards(CardLocation.MonsterZone, Enemy).Count() == 0 || Card.Attack >= 1500)
return DefaultMonsterSummon();
return false;
}
private bool MonsterSet()
{
if (FilpMonster(Card))
return DefaultMonsterSummon();
if (Card.HasSetcode(0x40)) return false;
return DefaultMonsterSummon() && (Bot.LifePoints <= 1500 || (GetZoneCards(CardLocation.MonsterZone, Bot).Count() == 0 && Bot.LifePoints <= 4000));
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment