public static KeyValuePair <PCard, int> FindMostValuableToGet(PGame Game, PPlayer Player, PPlayer TargetPlayer, bool AllowHandCards = true, bool AllowEquipment = true, bool AllowAmbush = false, bool CanSee = false) { int Cof = Player.TeamIndex == TargetPlayer.TeamIndex ? -1 : 1; int YangToowCof = TargetPlayer.Traffic != null && TargetPlayer.Traffic.Model is P_HsiYooYangToow && !Player.Age.Equals(TargetPlayer.Age) ? 0 : 1; KeyValuePair <PCard, int> HandCardResult = AllowHandCards ? PMath.Max(TargetPlayer.Area.HandCardArea.CardList, (PCard Card) => { if (CanSee) { return(Card.Model.AIInHandExpectation(Game, Player) * YangToowCof + Cof * Card.Model.AIInHandExpectation(Game, TargetPlayer)); } else { return(Cof < 0 ? 0 : 2000 * YangToowCof + 2000 * Cof + PMath.RandInt(0, 10)); } }) : new KeyValuePair <PCard, int>(null, int.MinValue); KeyValuePair <PCard, int> EquipResult = AllowEquipment ? PMath.Max(TargetPlayer.Area.EquipmentCardArea.CardList, (PCard Card) => { return(Card.Model.AIInHandExpectation(Game, Player) + Cof * Card.Model.AIInEquipExpectation(Game, TargetPlayer) - (TargetPlayer.General is P_HuaMulan ? 3500 * Cof : 0)); }) : new KeyValuePair <PCard, int>(null, int.MinValue); KeyValuePair <PCard, int> AmbushResult = AllowAmbush ? PMath.Max(TargetPlayer.Area.AmbushCardArea.CardList, (PCard Card) => { return(Card.Model.AIInHandExpectation(Game, Player) + Cof * Card.Model.AIInAmbushExpectation(Game, TargetPlayer)); }) : new KeyValuePair <PCard, int>(null, int.MinValue); KeyValuePair <PCard, int> Temp = HandCardResult.Value >= EquipResult.Value ? HandCardResult : EquipResult; Temp = Temp.Value >= AmbushResult.Value ? Temp : AmbushResult; if (Temp.Key == null) { return(new KeyValuePair <PCard, int>(null, 0)); } return(Temp); }
public override int AIInHandExpectation(PGame Game, PPlayer Player) { PCard Current = Player.GetEquipment(Type); int Exp = AIInEquipExpectation(Game, Player); int Base = 0; int Basic = 0; if (Player.General is P_HuaXiong) { Base += 1000; } if (Player.General is P_TangYin) { Base += 500; } if (Player.General is P_HuaMulan) { Base += 3500; } if (Player.General is P_LvMeng) { Base += 1000; } if (Current != null && Exp <= Current.Model.AIInEquipExpectation(Game, Player)) { Basic = 500 + Base; } else { Basic = Exp + Base; } return(Math.Max(Basic, base.AIInHandExpectation(Game, Player))); }
public static void Announce(PGame Game, PPlayer Player, string ArchName) { if (Player != null && Player.IsUser && Game.PlayerList.TrueForAll((PPlayer _Player) => _Player.IsAI || _Player.TeamIndex == Player.TeamIndex)) { PNetworkManager.NetworkServer.TellClient(Player, new PAnnounceArchOrder(Player.Index.ToString(), ArchName)); } }
public virtual int AIInHandExpectation(PGame Game, PPlayer Player) { int Basic = 0; if (Player.General is P_YuJi) { Basic += 400 * Point; } if (Player.General is P_WangXu && Point % 3 == 0) { if (Game.Teammates(Player, false).Count > 0) { Basic += 2900; } } if (Player.General is P_ShiQian && Point == 1) { Basic += 5900; } if (Player.General is P_Faraday && Point % 3 == 0) { Basic += 3000; } if (Player.General is P_Gryu && Point % 2 == 0) { Basic += 2500; } if (Player.General is P_ChenSheng && Point % 2 == 1) { Basic += 2500; } return(Basic); }
public override int AIInEquipExpectation(PGame Game, PPlayer Player) { return(500 + 4000 * Player.Area.HandCardArea.CardList.FindAll((PCard Card) => { PCardModel Model = Card.Model; return Model is P_ManTiienKuoHai || Model is P_HsiaoLiTsaangTao || Model is P_ChiaTaoFaKuo; }).Count); }
public static List <PBlock> NextBlocks(PGame Game, PPlayer Player, PBlock StartBlock = null) { if (StartBlock == null) { StartBlock = Player.Position; } List <PBlock> Answer = new List <PBlock>(); PBlock Block = StartBlock; if (!Player.NoLadder) { Block = Block.NextBlock; } if (Player.Traffic != null && Player.Traffic.Model is P_ChiihTuu) { Block = Block.NextBlock; } if (Player.NoLadder) { Answer.Add(Block); } else { for (int i = 0; i < 6; ++i, Block = Block.NextBlock) { Answer.Add(Block); } } return(Answer); }
public override int AIInHandExpectation(PGame Game, PPlayer Player) { int Basic = 0; Basic = Math.Max(Basic, PAiMapAnalyzer.OutOfGameExpect(Game, Player, true, true) - 2000 * (Player.Area.HandCardArea.CardNumber - 1)); return(Math.Max(Basic, base.AIInHandExpectation(Game, Player))); }
private List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player) { return(new List <PPlayer>() { Player }); }
public override void AnnouceInvokeJudge(PGame Game, PPlayer Player, PCard Card) { base.AnnouceInvokeJudge(Game, Player, Card); int Result = Game.Judge(Player, new Func <int>(() => { if (Player.Area.EquipmentCardArea.CardNumber > 0) { return(6); } else { return(5); } })()); if (Result != 6) { if (Player.Area.EquipmentCardArea.CardNumber > 0) { Game.ThrowCard(Player, Player, false, true); } if (Game.GetNextPlayer(Player).Area.AmbushCardArea.CardList.Exists((PCard _Card) => _Card.Model is P_HsienChing)) { Game.CardManager.MoveCard(Card, Player.Area.AmbushCardArea, Game.GetNextPlayer(Game.GetNextPlayer(Player)).Area.AmbushCardArea); } else { Game.CardManager.MoveCard(Card, Player.Area.AmbushCardArea, Game.GetNextPlayer(Player).Area.AmbushCardArea); } } else { Game.CardManager.MoveCard(Card, Player.Area.AmbushCardArea, Game.CardManager.ThrownCardHeap); } }
public int AiChooseResult(PGame Game, PPlayer Player) { List <PPlayer> Enemies = Game.Enemies(Player); List <PPlayer> Teammates = Game.Teammates(Player); if (Teammates.Exists((PPlayer _Player) => _Player.Money <= 500)) { return(1); } else if (Enemies.Exists((PPlayer _Player) => _Player.Money <= 500)) { return(0); } else { if (Enemies.Count > Teammates.Count) { return(0); } else if (Enemies.Count < Teammates.Count) { return(1); } else { return(-1); } } }
public int AIExpect(PGame Game, PPlayer Player, PBlock Block) { int[] dx = { 1, -1, 0, 0 }; int[] dy = { 0, 0, 1, -1 }; int OriginalX = Block.X; int OriginalY = Block.Y; int sum, x, y; sum = PAiMapAnalyzer.HouseValue(Game, Player, Block); for (int i = 0; i < 4; ++i) { x = OriginalX; y = OriginalY; do { x += dx[i]; y += dy[i]; PBlock TempBlock = Game.Map.FindBlockByCoordinate(x, y); if (TempBlock != null) { if (TempBlock.Lord != null) { sum += PAiMapAnalyzer.HouseValue(Game, Player, TempBlock); } } else { break; } } while (true); } return(sum); }
public override void AnnouceInvokeJudge(PGame Game, PPlayer Player, PCard Card) { base.AnnouceInvokeJudge(Game, Player, Card); int Result = Game.Judge(Player, new Func <int>(() => { if (Game.Enemies(Player).Count > Game.Teammates(Player, false).Count&& !(Game.Teammates(Player, false).Exists((PPlayer _Player) => _Player.Money <= 1000))) { return(6); } return(2); })()); if (Result != 2) { Game.LoseMoney(Player, 1000); if (Game.GetNextPlayer(Player).Area.AmbushCardArea.CardList.Exists((PCard _Card) => _Card.Model is P_WevnI)) { Game.CardManager.MoveCard(Card, Player.Area.AmbushCardArea, Game.GetNextPlayer(Game.GetNextPlayer(Player)).Area.AmbushCardArea); } else { Game.CardManager.MoveCard(Card, Player.Area.AmbushCardArea, Game.GetNextPlayer(Player).Area.AmbushCardArea); } } else { Game.CardManager.MoveCard(Card, Player.Area.AmbushCardArea, Game.CardManager.ThrownCardHeap); } }
public override int AIInHandExpectation(PGame Game, PPlayer Player) { int Basic = 1000; int Sum = 0; List <PPlayer> Targets = AIEmitTargets(Game, Player); Targets.ForEach((PPlayer _Player) => { if (!(_Player.Defensor != null && _Player.Defensor.Model is P_YooHsi && Targets.Count > 1)) { int Cof = (_Player.TeamIndex == Player.TeamIndex ? 1 : -1); if (_Player.General is P_LiuJi) { Sum += 1200 * 6 / 5 * Cof; } else { int Choose1 = PAiMapAnalyzer.ChangeFaceExpect(Game, _Player); int Choose2 = _Player.Money <= 1000 ? -30000 : -1000; int Chosen = Math.Max(Choose1, Choose2); Sum += Chosen * Cof; } } }); Sum = Sum * 5 / 6; Basic = Math.Max(Basic, Sum); return(Math.Max(Basic, base.AIInHandExpectation(Game, Player))); }
public List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player) { return(new List <PPlayer>() { FindTarget(Game, Player).Key }); }
/// <summary> /// 用于交给队友有价值的牌和弃置敌人的高价值牌 /// </summary> /// <param name="Game"></param> /// <param name="Player"></param> /// <param name="TargetPlayer"></param> /// <param name="AllowHandCards"></param> /// <param name="AllowEquipment"></param> /// <param name="AllowAmbush"></param> /// <param name="CanSee"></param> /// <returns></returns> public static KeyValuePair <PCard, int> FindMostValuable(PGame Game, PPlayer Player, PPlayer TargetPlayer, bool AllowHandCards = true, bool AllowEquipment = true, bool AllowAmbush = false, bool CanSee = false) { int Cof = Player.TeamIndex == TargetPlayer.TeamIndex ? 1 : -1; KeyValuePair <PCard, int> HandCardResult = AllowHandCards ? PMath.Max(TargetPlayer.Area.HandCardArea.CardList, (PCard Card) => { if (CanSee) { return(Card.Model.AIInHandExpectation(Game, Player)); } else { return(2000 + PMath.RandInt(-10, 10)); } }) : new KeyValuePair <PCard, int>(null, int.MinValue); KeyValuePair <PCard, int> EquipResult = AllowEquipment ? PMath.Max(TargetPlayer.Area.EquipmentCardArea.CardList, (PCard Card) => { return(Card.Model.AIInEquipExpectation(Game, TargetPlayer) + (TargetPlayer.General is P_HuaMulan ? 3500 * Cof : 0)); }) : new KeyValuePair <PCard, int>(null, int.MinValue); KeyValuePair <PCard, int> AmbushResult = AllowAmbush ? PMath.Max(TargetPlayer.Area.AmbushCardArea.CardList, (PCard Card) => { return(Card.Model.AIInAmbushExpectation(Game, TargetPlayer)); }) : new KeyValuePair <PCard, int>(null, int.MinValue); KeyValuePair <PCard, int> Temp = HandCardResult.Value >= EquipResult.Value ? HandCardResult : EquipResult; Temp = Temp.Value >= AmbushResult.Value ? Temp : AmbushResult; if (Temp.Key == null) { return(new KeyValuePair <PCard, int>(null, 0)); } return(Temp); }
/// <summary> /// 牌堆里的牌(未进入弃牌堆或可见区域)的平均收益 /// </summary> /// <param name="Game"></param> /// <param name="Player"></param> /// <returns></returns> public static int Expect(PGame Game, PPlayer Player) { double SingleExpect(PCard Card) { int Base = Card.Model.AIInHandExpectation(Game, Player); return(Base); } double Sum = PMath.Sum(Game.CardManager.CardHeap.CardList.ConvertAll(SingleExpect)); int Count = Game.CardManager.CardHeap.CardNumber; if (Count <= 10) { Sum += PMath.Sum(Game.CardManager.ThrownCardHeap.CardList.ConvertAll(SingleExpect)); Count += Game.CardManager.ThrownCardHeap.CardNumber; } if (Count == 0) { return(0); } else { return((int)Sum / Count); } }
public List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player) { return(new List <PPlayer>() { RoundExpect(Game, Player) >= 1000 && (Player.Defensor == null || !(Player.Defensor.Model is P_ChiiHsingPaao)) ? Player : null }); }
private KeyValuePair <KeyValuePair <PBlock, PBlock>, int> MaxLandPair(PGame Game, PPlayer Player) { int Test = int.MinValue; List <PBlock> LandList = Game.Map.BlockList.FindAll((PBlock Block) => Block.Lord != null && !Block.IsBusinessLand); PBlock Ans1 = null; PBlock Ans2 = null; foreach (PBlock Land1 in LandList) { foreach (PBlock Land2 in LandList) { if (Land1.Index < Land2.Index) { int HouseCount1 = Land1.HouseNumber; int HouseCount2 = Land2.HouseNumber; int ValueBefore = PAiMapAnalyzer.HouseValue(Game, Player, Land1) * HouseCount1 + PAiMapAnalyzer.HouseValue(Game, Player, Land2) * HouseCount2; int ValueAfter = PAiMapAnalyzer.HouseValue(Game, Player, Land1) * HouseCount2 + PAiMapAnalyzer.HouseValue(Game, Player, Land2) * HouseCount1; if (ValueAfter - ValueBefore > Test) { Test = ValueAfter - ValueBefore; Ans1 = Land1; Ans2 = Land2; } } } } return(new KeyValuePair <KeyValuePair <PBlock, PBlock>, int>(new KeyValuePair <PBlock, PBlock>(Ans1, Ans2), Test)); }
public override int AIInEquipExpectation(PGame Game, PPlayer Player) { if (Player.General is P_LiuJi) { return(7000); } return(3000); }
public PCardManager(PGame _Game) { Game = _Game; PlayerAreaList = new List <PPlayerCardArea>(); CardHeap = new PCardArea("牌堆"); ThrownCardHeap = new PCardArea("弃牌堆"); SettlingArea = new PCardArea("结算区"); }
public List<PPlayer> AIEmitTargets(PGame Game, PPlayer Player) { PPlayer Target = PMath.Max(Game.Enemies(Player).FindAll((PPlayer _Player) => _Player.HasHouse && (_Player.Defensor == null || !(_Player.Defensor.Model is P_ChiiHsingPaao)) && !_Player.Area.AmbushCardArea.CardList.Exists((PCard _Card) => _Card.Model.Name.Equals(CardName)) && !(_Player.General is P_LiuJi)), (PPlayer _Player) => PAiMapAnalyzer.MinValueHouse(Game, _Player).Value + PMath.RandInt(0, 10)).Key; return new List<PPlayer>() { Target}; }
public override int AIInHandExpectation(PGame Game, PPlayer Player) { int Basic = 5400; int Test = MaxLandPair(Game, Player).Value; Basic = Math.Max(Basic, Test); return(Math.Max(Basic, base.AIInHandExpectation(Game, Player))); }
private List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player) { if (Player.Tags.ExistTag(P_WuZhao.NvQuanTag.Name) && Player.HasInHand <P_HunShuiMoYoo>()) { return(Game.Enemies(Player)); } return(Game.Teammates(Player)); }
public override int AIInHandExpectation(PGame Game, PPlayer Player) { int Basic = Player.Area.HandCardArea.CardList.Exists((PCard Card) => Card.Type.IsEquipment()) ? 2000 : 0; int Test = 1000 * PMath.Max(Game.Enemies(Player), (PPlayer _Player) => _Player.Area.EquipmentCardArea.CardNumber).Value; Basic = Math.Max(Basic, Test); return(Math.Max(Basic, base.AIInHandExpectation(Game, Player))); }
public override int AIInHandExpectation(PGame Game, PPlayer Player) { int Basic = PAiMapAnalyzer.MaxValueHouse(Game, Player).Value; Basic = Math.Max(1000, PMath.Max(Game.Enemies(Player), (PPlayer _Player) => { return(PAiMapAnalyzer.MaxValueHouse(Game, _Player).Value + Basic); }, true).Value); return(Math.Max(Basic, base.AIInHandExpectation(Game, Player))); }
public List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player) { return(new List <PPlayer>() { PMath.Max(Game.Enemies(Player), (PPlayer _Player) => { return -PAiMapAnalyzer.OutOfGameExpect(Game, _Player); }, true).Key }); }
/// <summary> /// 返回最低价值的房屋 /// </summary> /// <param name="Game"></param> /// <param name="Player">房屋所有者</param> /// <param name="StartFromZero">是否允许土地上实际没有房屋</param> /// <param name="Concentrate">是否优先选取房屋数量少的土地的房屋</param> /// <returns></returns> public static KeyValuePair <PBlock, int> MinValueHouse(PGame Game, PPlayer Player, bool StartFromZero = false, bool Concentrate = false) { KeyValuePair <PBlock, int> Test = PMath.Min(Game.Map.BlockList.FindAll((PBlock Block) => Player.Equals(Block.Lord) && (StartFromZero || Block.HouseNumber > 0)), (PBlock Block) => { return(HouseValue(Game, Player, Block) * 1000 + (Concentrate ? Block.HouseNumber : 0)); }); return(new KeyValuePair <PBlock, int>(Test.Key, Test.Value / 1000)); }
private List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player) { return(new List <PPlayer> { PAiTargetChooser.InjureTarget(Game, Player, Player, (PGame _Game, PPlayer _Player) => { PChiaTaoFaKuoTag ChiaTaoFaKuoTag = _Game.TagManager.FindPeekTag <PChiaTaoFaKuoTag>(PChiaTaoFaKuoTag.TagName); return ChiaTaoFaKuoTag.LordList.Contains(_Player) && Player.TeamIndex != _Player.TeamIndex; }, 1000, Instantiate()) }); }
private List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player) { PPlayer Target = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName).ToPlayer; return(new List <PPlayer>() { Target }); }
public override int AIInHandExpectation(PGame Game, PPlayer Player) { int Basic = 4000; int ShiQian = 0;// Game.Enemies(Player).FindAll((PPlayer _Player) => _Player.General is P_ShiQian).Count; Basic *= Game.Enemies(Player).Count - ShiQian; Basic /= Game.Enemies(Player).Count; return(Math.Max(Basic, base.AIInHandExpectation(Game, Player))); }