Commit 250d2b3b authored by mercury233's avatar mercury233

update and fix ai

parent 041d9adc
......@@ -42,8 +42,8 @@
80280737
#extra
99267150
99267150
99267150
50954680
50954680
76774528
76774528
76774528
......
......@@ -7,7 +7,6 @@
45082499
33911264
33911264
33911264
65367484
65367484
24610207
......@@ -15,6 +14,7 @@
24610207
30914564
30914564
30914564
25259669
25259669
25259669
......@@ -23,9 +23,8 @@
94656263
94656263
94656263
34143852
34143852
34143852
40941889
18063928
18063928
18063928
423585
......@@ -36,24 +35,39 @@
53129443
5318639
5318639
78474168
78474168
78474168
11705261
11705261
11705261
40605147
84749824
#extra
45231177
45231177
17881964
17881964
91949988
60992364
60992364
94119480
56832966
56832966
56832966
29669359
71594310
86532744
86532744
86532744
84013237
84013237
84013237
!side
33911264
34143852
34143852
34143852
45231177
60992364
94119480
29669359
71594310
25341652
12014404
!side
78474168
78474168
78474168
......@@ -7,6 +7,7 @@
"duelstart": [
"青眼卡组测试中,渣操是正常情况。",
"超主流是游戏王的一环,不爽不要玩。",
"抄主流是游戏王的一环,不爽不要玩。",
"抄来的卡组不会用,怎么办?"
],
"newturn": [
......
......@@ -2,7 +2,7 @@
"welcome": [
"你好,我是一个机器人。",
"AI功能正在测试中,遇到问题请及时反馈。",
"不要再幻想我会进化成LV6了。不过听说过几天会出现比我强的家伙。"
"新的风暴已经出现,怎么能够停滞不前!我的希望皇卡组和龙骑星爆卡组都得到了加强!"
],
"duelstart": [
"好戏才正要开始呢!",
......
......@@ -45,6 +45,7 @@ namespace MycardBot.Game.AI.Decks
private List<ClientCard> 使用过的青眼亚白龙 = new List<ClientCard>();
ClientCard 使用过的光波龙;
bool 已特殊召唤青眼亚白龙 = false;
public BlueEyesExecutor(GameAI ai, Duel duel)
: base(ai, duel)
......@@ -69,7 +70,7 @@ namespace MycardBot.Game.AI.Decks
AddExecutor(ExecutorType.Activate, (int)CardId.强欲而贪欲之壶, 强欲而贪欲之壶效果);
// 有亚白就跳
AddExecutor(ExecutorType.SpSummon, (int)CardId.青眼亚白龙);
AddExecutor(ExecutorType.SpSummon, (int)CardId.青眼亚白龙, 青眼亚白龙特殊召唤);
// 苏生
AddExecutor(ExecutorType.Activate, (int)CardId.复活之福音, 死者苏生效果);
......@@ -106,22 +107,25 @@ namespace MycardBot.Game.AI.Decks
// 没别的可干
AddExecutor(ExecutorType.Repos, 改变攻守表示);
AddExecutor(ExecutorType.MonsterSet, (int)CardId.太古的白石);
// 优先盖传说白石以期望拿到白龙打开局面
AddExecutor(ExecutorType.MonsterSet, (int)CardId.传说的白石);
AddExecutor(ExecutorType.MonsterSet, (int)CardId.太古的白石);
AddExecutor(ExecutorType.SpellSet, 盖卡);
}
public override bool OnSelectHand()
{
//
return false;
// 随机先后
return Program.Rand.Next(2) > 0;
}
public override void OnNewTurn()
{
// 回合开始时重置亚白龙状况
// 回合开始时重置状况
使用过的青眼亚白龙.Clear();
使用过的光波龙 = null;
已特殊召唤青眼亚白龙 = false;
}
public override IList<ClientCard> OnSelectCard(IList<ClientCard> cards, int min, int max, bool cancelable)
......@@ -542,6 +546,19 @@ namespace MycardBot.Game.AI.Decks
if (ActivateDescription == AI.Utils.GetStringId((int)CardId.太古的白石, 0))
{
Logger.WriteLine("太古白石回收效果.");
if (Duel.Fields[0].HasInHand((int)CardId.抵价购物)
&& !Duel.Fields[0].HasInHand((int)CardId.青眼白龙)
&& !Duel.Fields[0].HasInHand((int)CardId.青眼亚白龙))
{
Logger.WriteLine("回收喂八抽.");
AI.SelectCard((int)CardId.青眼白龙);
return true;
}
if (已特殊召唤青眼亚白龙)
{
Logger.WriteLine("已经跳过亚白龙,下回合再回收.");
return false;
}
if (Duel.Fields[0].HasInHand((int)CardId.青眼白龙)
&& !Duel.Fields[0].HasInHand((int)CardId.青眼亚白龙)
&& Duel.Fields[0].HasInGraveyard((int)CardId.青眼亚白龙))
......@@ -558,14 +575,6 @@ namespace MycardBot.Game.AI.Decks
AI.SelectCard((int)CardId.青眼白龙);
return true;
}
if (Duel.Fields[0].HasInHand((int)CardId.抵价购物)
&& !Duel.Fields[0].HasInHand((int)CardId.青眼白龙)
&& !Duel.Fields[0].HasInHand((int)CardId.青眼亚白龙))
{
Logger.WriteLine("回收喂八抽.");
AI.SelectCard((int)CardId.青眼白龙);
return true;
}
Logger.WriteLine("并没有应该回收的.");
return false;
}
......@@ -588,6 +597,12 @@ namespace MycardBot.Game.AI.Decks
}
}
private bool 青眼亚白龙特殊召唤()
{
已特殊召唤青眼亚白龙 = true;
return true;
}
private bool 太古的白石通常召唤()
{
Logger.WriteLine("白石通常召唤.");
......
namespace WindBot.Game.AI.Decks
{
[Deck("Test", "AI_Test")]
public class DoEverythingExecutor : DefaultExecutor
{
public enum CardId
{
LeoWizard = 4392470,
Bunilla = 69380702
}
public DoEverythingExecutor(GameAI ai, Duel duel)
: base(ai, duel)
{
AddExecutor(ExecutorType.Activate, DontChainMyself);
AddExecutor(ExecutorType.SummonOrSet);
AddExecutor(ExecutorType.SpSummon);
AddExecutor(ExecutorType.Repos, DefaultMonsterRepos);
AddExecutor(ExecutorType.SpellSet);
}
private bool DontChainMyself()
{
return LastChainPlayer != 0;
}
}
}
\ No newline at end of file
......@@ -31,6 +31,7 @@ namespace DevBot.Game.AI.Decks
DimensionalPrison = 70342110,
AssaultModeActivate = 80280737,
FiveHeadedDragon = 99267150,
CrystalWingSynchroDragon = 50954680,
ScrapDragon = 76774528,
StardustDragon = 44508094,
DragunityKnightGaeDearg = 34116027,
......@@ -54,6 +55,7 @@ namespace DevBot.Game.AI.Decks
// Execute monsters
AddExecutor(ExecutorType.Activate, (int)CardId.ScrapDragon, ScrapDragonEffect);
AddExecutor(ExecutorType.Activate, (int)CardId.CrystalWingSynchroDragon, CrystalWingSynchroDragonEffect);
AddExecutor(ExecutorType.Activate, (int)CardId.DragunityPhalanx);
AddExecutor(ExecutorType.Activate, (int)CardId.DragunityKnightVajrayana);
AddExecutor(ExecutorType.Activate, (int)CardId.DragunityArmaMysletainn);
......@@ -62,6 +64,7 @@ namespace DevBot.Game.AI.Decks
// Summon
AddExecutor(ExecutorType.Activate, (int)CardId.DragonsMirror, DragonsMirror);
AddExecutor(ExecutorType.SpSummon, (int)CardId.ScrapDragon, ScrapDragonSummon);
AddExecutor(ExecutorType.SpSummon, (int)CardId.CrystalWingSynchroDragon, CrystalWingSynchroDragonSummon);
AddExecutor(ExecutorType.SpSummon, (int)CardId.StardustDragon);
AddExecutor(ExecutorType.SpSummon, (int)CardId.DragunityKnightVajrayana);
AddExecutor(ExecutorType.SpSummon, (int)CardId.DragunityKnightGaeDearg);
......@@ -157,7 +160,7 @@ namespace DevBot.Game.AI.Decks
needId = (int)CardId.DragunityDux;
else
{
bool hasRealMonster = false;
/*bool hasRealMonster = false;
foreach (ClientCard card in field.GetMonsters())
{
if (card.Id != (int)CardId.AssaultBeast)
......@@ -166,8 +169,8 @@ namespace DevBot.Game.AI.Decks
break;
}
}
if (!hasRealMonster || GetProblematicCard() != null)
needId = (int)CardId.DragunityDux;
if (!hasRealMonster || GetProblematicCard() != null)*/
needId = (int)CardId.DragunityDux;
}
if (needId == -1)
......@@ -338,8 +341,8 @@ namespace DevBot.Game.AI.Decks
private bool ScrapDragonSummon()
{
if (AI.Utils.IsOneEnnemyBetterThanValue(2500, true))
return true;
//if (AI.Utils.IsOneEnnemyBetterThanValue(2500, true))
// return true;
ClientCard invincible = GetProblematicCard();
return invincible != null;
}
......@@ -395,6 +398,18 @@ namespace DevBot.Game.AI.Decks
return true;
}
private bool CrystalWingSynchroDragonSummon()
{
return !Duel.Fields[0].HasInHand((int)CardId.AssaultModeActivate)
&& !Duel.Fields[0].HasInHand((int)CardId.AssaultBeast)
&& !Duel.Fields[0].HasInSpellZone((int)CardId.AssaultModeActivate);
}
private bool CrystalWingSynchroDragonEffect()
{
return LastChainPlayer != 0;
}
private bool DragunityPhalanxSummon()
{
return Duel.Fields[0].HasInHand((int)CardId.DragunityArmaMysletainn);
......
......@@ -13,6 +13,7 @@ namespace DevBot.Game.AI.Decks
CyberDragon = 70095155,
ZwTornadoBringer = 81471108,
ZwLightningBlade = 45082499,
ZwAsuraStrike = 40941889,
SolarWindJammer = 33911264,
PhotonTrasher = 65367484,
StarDrawing = 24610207,
......@@ -30,6 +31,8 @@ namespace DevBot.Game.AI.Decks
MysticalSpaceTyphoon = 5318639,
BreakthroughSkill = 78474168,
SolemnWarning = 84749824,
SolemnStrike = 40605147,
XyzChangeTactics = 11705261,
FlameSwordsman = 45231177,
DarkfireDragon = 17881964,
......@@ -39,6 +42,8 @@ namespace DevBot.Game.AI.Decks
Number61Volcasaurus = 29669359,
GemKnightPearl = 71594310,
Number39Utopia = 84013237,
NumberS39UtopiaOne= 86532744,
NumberS39UtopiatheLightning = 56832966,
MaestrokeTheSymphonyDjinn = 25341652,
GagagaCowboy = 12014404
}
......@@ -49,26 +54,36 @@ namespace DevBot.Game.AI.Decks
// Quick spells
AddExecutor(ExecutorType.Activate, (int)CardId.MysticalSpaceTyphoon, DefaultMysticalSpaceTyphoon);
// Spell cards
AddExecutor(ExecutorType.Activate, (int)CardId.DarkHole, DefaultDarkHole);
AddExecutor(ExecutorType.Activate, (int)CardId.Raigeki, DefaultRaigeki);
AddExecutor(ExecutorType.Activate, (int)CardId.ReinforcementOfTheArmy, ReinforcementOfTheArmy);
AddExecutor(ExecutorType.Activate, (int)CardId.XyzChangeTactics);
// XYZ summons
AddExecutor(ExecutorType.SpSummon, (int)CardId.Number39Utopia);
AddExecutor(ExecutorType.SpSummon, (int)CardId.NumberS39UtopiaOne);
AddExecutor(ExecutorType.SpSummon, (int)CardId.NumberS39UtopiatheLightning);
AddExecutor(ExecutorType.SpSummon, (int)CardId.Number61Volcasaurus, Number61Volcasaurus);
AddExecutor(ExecutorType.SpSummon, (int)CardId.ZwLionArms);
AddExecutor(ExecutorType.SpSummon, (int)CardId.AdreusKeeperOfArmageddon);
AddExecutor(ExecutorType.SpSummon, (int)CardId.Number61Volcasaurus);
// XYZ effects
AddExecutor(ExecutorType.Activate, (int)CardId.Number39Utopia, Number39Utopia);
AddExecutor(ExecutorType.Activate, (int)CardId.NumberS39UtopiaOne);
AddExecutor(ExecutorType.Activate, (int)CardId.NumberS39UtopiatheLightning, NumberS39UtopiatheLightning);
AddExecutor(ExecutorType.Activate, (int)CardId.ZwLionArms, ZwLionArms);
AddExecutor(ExecutorType.Activate, (int)CardId.AdreusKeeperOfArmageddon);
AddExecutor(ExecutorType.Activate, (int)CardId.Number61Volcasaurus);
// Spummon GaiaDragonTheThunderCharger if Volcasaurus or ZwLionArms had been used
AddExecutor(ExecutorType.SpSummon, (int)CardId.GaiaDragonTheThunderCharger);
// Weapons
AddExecutor(ExecutorType.Activate, (int)CardId.ZwTornadoBringer);
AddExecutor(ExecutorType.Activate, (int)CardId.ZwLightningBlade);
AddExecutor(ExecutorType.Activate, (int)CardId.ZwAsuraStrike);
// Spell cards
AddExecutor(ExecutorType.Activate, (int)CardId.DarkHole, DefaultDarkHole);
AddExecutor(ExecutorType.Activate, (int)CardId.Raigeki, DefaultRaigeki);
AddExecutor(ExecutorType.Activate, (int)CardId.ReinforcementOfTheArmy, ReinforcementOfTheArmy);
// Special summons
AddExecutor(ExecutorType.SpSummon, (int)CardId.PhotonTrasher);
......@@ -92,15 +107,17 @@ namespace DevBot.Game.AI.Decks
AddExecutor(ExecutorType.Activate, (int)CardId.TinGoldfish, GoblindberghEffect);
AddExecutor(ExecutorType.Activate, (int)CardId.Kagetokage);
AddExecutor(ExecutorType.Activate, (int)CardId.SummonerMonk, SummonerMonkEffect);
AddExecutor(ExecutorType.Activate, (int)CardId.Honest, Honest);
// Reposition
AddExecutor(ExecutorType.Repos, DefaultMonsterRepos);
AddExecutor(ExecutorType.Repos, MonsterRepos);
// Set and activate traps
AddExecutor(ExecutorType.SpellSet, DefaultSpellSet);
AddExecutor(ExecutorType.Activate, (int)CardId.BreakthroughSkill, BreakthroughSkill);
AddExecutor(ExecutorType.Activate, (int)CardId.SolemnWarning, DefaultTrap);
AddExecutor(ExecutorType.Activate, (int)CardId.SolemnStrike, DefaultTrap);
}
public override bool OnSelectHand()
......@@ -108,6 +125,23 @@ namespace DevBot.Game.AI.Decks
return false;
}
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
{
if (defender.IsMonsterInvincible())
{
if (defender.IsMonsterDangerous() || defender.IsDefense())
return false;
}
if (!(defender.Id == (int)CardId.NumberS39UtopiatheLightning))
{
if (attacker.Attribute == (int)CardAttribute.Light && Duel.Fields[0].HasInHand((int)CardId.Honest))
attacker.RealPower = attacker.RealPower + defender.Attack;
if (attacker.Id == (int)CardId.NumberS39UtopiatheLightning && !attacker.IsDisabled())
attacker.RealPower = 5000;
}
return attacker.RealPower > defender.GetDefensePower();
}
private bool Number39Utopia()
{
if (!HasChainedTrap(0) && Duel.Player == 1 && Duel.Phase == DuelPhase.BattleStart && Card.Overlays.Count > 1)
......@@ -115,6 +149,11 @@ namespace DevBot.Game.AI.Decks
return false;
}
private bool Number61Volcasaurus()
{
return AI.Utils.IsOneEnnemyBetterThanValue(2000, false);
}
private bool ZwLionArms()
{
if (ActivateDescription == AI.Utils.GetStringId((int)CardId.ZwLionArms, 0))
......@@ -140,17 +179,36 @@ namespace DevBot.Game.AI.Decks
private bool InstantFusion()
{
List<ClientCard> monsters = Duel.Fields[0].GetMonsters();
int count = 0;
int count4 = 0;
int count5 = 0;
foreach (ClientCard card in monsters)
{
if (card.Level == 5)
++count;
++count5;
if (card.Level == 4)
++count4;
}
if (count == 1)
if (count5 == 1)
{
AI.SelectCard((int)CardId.FlameSwordsman);
else
return true;
}
else if (count4 == 1)
{
AI.SelectCard((int)CardId.DarkfireDragon);
return true;
return true;
}
return false;
}
private bool NumberS39UtopiatheLightning()
{
return Card.Attack < 5000;
}
private bool Honest()
{
return Duel.Phase != DuelPhase.Main1 || Duel.Turn == 1;
}
private bool GoblindberghFirst()
......@@ -201,6 +259,11 @@ namespace DevBot.Game.AI.Decks
private bool SolarWindJammer()
{
if (!Duel.Fields[0].HasInHand(new List<int> {
(int)CardId.StarDrawing,
(int)CardId.InstantFusion
}))
return false;
AI.SelectPosition(CardPosition.FaceUpDefence);
return true;
}
......@@ -209,5 +272,12 @@ namespace DevBot.Game.AI.Decks
{
return (CurrentChain.Count > 0 && DefaultTrap());
}
private bool MonsterRepos()
{
if (Card.Id == (int)CardId.NumberS39UtopiatheLightning)
return false;
return base.DefaultMonsterRepos();
}
}
}
......@@ -134,7 +134,7 @@ namespace WindBot.Game.AI
protected bool DefaultTrap()
{
return LastChainPlayer == -1 || LastChainPlayer == 1;
return (LastChainPlayer == -1 && Duel.LastSummonPlayer != 0) || LastChainPlayer == 1;
}
protected bool DefaultUniqueTrap()
......
......@@ -47,13 +47,14 @@ namespace WindBot.Game.AI
for (int i = defenders.Count - 1; i >= 0; --i)
{
ClientCard defender = defenders[i];
int value = defender.GetDefensePower();
int def = defender.GetDefensePower();
for (int j = 0; j < attackers.Count; ++j)
{
ClientCard attacker = attackers[j];
attacker.RealPower = attacker.Attack;
if (!OnPreBattleBetween(attacker, defender))
continue;
if (attacker.Attack > value || (attacker.Attack >= value && j == attackers.Count - 1))
if (attacker.RealPower > def || (attacker.RealPower >= def && j == attackers.Count - 1))
return AI.Attack(attacker, defender);
}
}
......
......@@ -24,6 +24,7 @@ namespace WindBot.Game
public int Defense { get; private set; }
public int BaseAttack { get; private set; }
public int BaseDefense { get; private set; }
public int RealPower { get; set; }
public List<int> Overlays { get; private set; }
public int Owner { get; private set; }
public int Controller { get; private set; }
......
......@@ -16,6 +16,7 @@ namespace WindBot.Game
public MainPhase MainPhase { get; set; }
public BattlePhase BattlePhase { get; set; }
public IList<ClientCard> ChainTargets { get; set; }
public int LastSummonPlayer { get; set; }
public Duel()
{
......@@ -24,6 +25,7 @@ namespace WindBot.Game
Fields[0] = new ClientField();
Fields[1] = new ClientField();
ChainTargets = new List<ClientCard>();
LastSummonPlayer = -1;
}
public ClientCard GetCard(int player, CardLocation loc, int index)
......
......@@ -63,6 +63,7 @@ namespace WindBot.Game
m_nextSelector = null;
m_option = -1;
m_position = CardPosition.FaceUpAttack;
Duel.LastSummonPlayer = -1;
if (Duel.Player == 0 && Duel.Phase == DuelPhase.Draw)
{
_dialogs.SendNewTurn();
......@@ -89,6 +90,7 @@ namespace WindBot.Game
/// <param name="player">Player who is currently chaining.</param>
public void OnChaining(ClientCard card, int player)
{
Duel.LastSummonPlayer = -1;
Executor.OnChaining(player,card);
}
......@@ -268,6 +270,7 @@ namespace WindBot.Game
if (ShouldExecute(exec, card, ExecutorType.SpSummon))
{
_dialogs.SendSummon(card.Name);
Duel.LastSummonPlayer = 0;
return new MainPhaseAction(MainPhaseAction.MainAction.SpSummon, card.ActionIndex);
}
}
......@@ -276,6 +279,7 @@ namespace WindBot.Game
if (ShouldExecute(exec, card, ExecutorType.Summon))
{
_dialogs.SendSummon(card.Name);
Duel.LastSummonPlayer = 0;
return new MainPhaseAction(MainPhaseAction.MainAction.Summon, card.ActionIndex);
}
if (ShouldExecute(exec, card, ExecutorType.SummonOrSet))
......@@ -287,6 +291,7 @@ namespace WindBot.Game
return new MainPhaseAction(MainPhaseAction.MainAction.SetMonster, card.ActionIndex);
}
_dialogs.SendSummon(card.Name);
Duel.LastSummonPlayer = 0;
return new MainPhaseAction(MainPhaseAction.MainAction.Summon, card.ActionIndex);
}
}
......
......@@ -51,7 +51,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Game\AI\Decks\BlueEyesExecutor.cs" />
<Compile Include="Game\AI\AIFunctions.cs" />
<Compile Include="Game\AI\CardContainer.cs" />
<Compile Include="Game\AI\CardExecutor.cs" />
......@@ -59,10 +58,12 @@
<Compile Include="Game\AI\CardSelector.cs" />
<Compile Include="Game\AI\DeckAttribute.cs" />
<Compile Include="Game\AI\DecksManager.cs" />
<Compile Include="Game\AI\Decks\BlueEyesExecutor.cs" />
<Compile Include="Game\AI\Decks\BurnExecutor.cs" />
<Compile Include="Game\AI\Decks\DragunityExecutor.cs" />
<Compile Include="Game\AI\Decks\FrogExecutor.cs" />
<Compile Include="Game\AI\Decks\HorusExecutor.cs" />
<Compile Include="Game\AI\Decks\DoEverythingExecutor.cs" />
<Compile Include="Game\AI\Decks\OldSchoolExecutor.cs" />
<Compile Include="Game\AI\Decks\Rank5Executor.cs" />
<Compile Include="Game\AI\Decks\ZexalWeaponsExecutor.cs" />
......@@ -96,9 +97,6 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="Decks\AI_BlueEyes.ydk">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="sqlite3.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......
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