/// <summary> /// 将一个玩家移出游戏对其的收益,无卡牌收益嵌套 /// </summary> /// <param name="Game"></param> /// <param name="Player"></param> /// <param name="Including">是否包含其行走阶段</param> /// <returns></returns> public static int OutOfGameExpect(PGame Game, PPlayer Player, bool Including = false, bool IncludingOnly = false) { if (Player.OutOfGame) { return(0); } int Sum = 0; // 一轮其他角色可能造成的过路费收益总和的相反数 if (!IncludingOnly) { PPlayer _Player = Game.NowPlayer; if (Player.Equals(Game.NowPlayer)) { _Player = Game.GetNextPlayer(_Player); } for (; !_Player.Equals(Player); _Player = Game.GetNextPlayer(_Player)) { if (_Player.Equals(Game.NowPlayer) && Game.NowPeriod.IsAfter(PPeriod.WalkingStage)) { continue; } int Temp = 0; List <PBlock> Blocks = NextBlocks(Game, _Player); Blocks.ForEach((PBlock Block) => { int BlockTemp = 0; if (Block.Lord != null && Player.Equals(Block.Lord)) { BlockTemp = Math.Max(0, PAiTargetChooser.InjureExpect(Game, Player, Player, _Player, Block.Toll, Block)); } if (_Player.General is P_Newton) { PBlock PossibleBlock = Game.Map.NextStepBlock(Block, P_Newton.Grx_Next(Game, _Player.Position).Value); if (PossibleBlock.Lord != null && Player.Equals(PossibleBlock.Lord)) { BlockTemp = Math.Min(BlockTemp, Math.Max(0, PAiTargetChooser.InjureExpect(Game, Player, Player, _Player, Block.Toll, Block))); } else { BlockTemp = 0; } } Temp -= BlockTemp; }); Sum += Temp / Math.Max(1, Blocks.Count); } } int SumSelf = 0; if (Including) { List <PBlock> Blocks = NextBlocks(Game, Player); Blocks.ForEach((PBlock Block) => { int BlockTemp = 0; if (Block.Lord != null && Player.TeamIndex != Block.Lord.TeamIndex) { BlockTemp = Math.Max(0, -PAiTargetChooser.InjureExpect(Game, Player, Block.Lord, Player, Block.Toll, Block)); } if (Player.General is P_Newton) { PBlock PossibleBlock = Game.Map.NextStepBlock(Block, P_Newton.Grx_Next(Game, Player.Position).Value); if (PossibleBlock.Lord != null && Player.TeamIndex != PossibleBlock.Lord.TeamIndex) { BlockTemp = Math.Max(BlockTemp, Math.Max(0, -PAiTargetChooser.InjureExpect(Game, Player, Block.Lord, Player, Block.Toll, Block))); } else { BlockTemp = 0; } } SumSelf += BlockTemp; }); SumSelf /= Math.Max(1, Blocks.Count); } return(Sum + SumSelf); }
/// <summary> /// AI计算从一个点开始走的期望 /// </summary> /// <param name="Game">游戏句柄</param> /// <param name="Player">玩家句柄</param> /// <param name="Block">起点的格子</param> /// <param name="Banned">被禁止投出的骰子点数(用于唐寅的技能【浪子】)</param> /// <param name="IncludePassMoney">计算是否包括经过奖励(用于计算前进收益)</param> /// <returns></returns> public static int StartFromExpect(PGame Game, PPlayer Player, PBlock Block, int Banned = 0, bool IncludePassMoney = true) { PBlock CurrentBlock = Block; if (!Player.NoLadder) { CurrentBlock = CurrentBlock.NextBlock; } if (Player.Traffic != null && Player.Traffic.Model is P_ChiihTuu) { CurrentBlock = CurrentBlock.NextBlock; } if (Player.NoLadder) { return(Expect(Game, Player, CurrentBlock)); } int Expectation = 0; int NewtonTargetStep = (Player.General is P_Newton ? P_Newton.Grx_Next(Game, Block).Value : 0); for (int i = 6; i >= 1; --i) { if (Banned == i) { continue; } int SingleExpect = Expect(Game, Player, CurrentBlock); if (NewtonTargetStep > 0) { SingleExpect = Math.Max(SingleExpect, Expect(Game, Player, Game.Map.NextStepBlock(CurrentBlock, NewtonTargetStep))); } Expectation += SingleExpect; if (IncludePassMoney) { if (CurrentBlock.GetMoneyPassSolid != 0) { int Disaster = Block.GetMoneyPassSolid; if (Disaster < 0 && -Disaster <= 1000 && Player.Traffic != null && Player.Traffic.Model is P_NanManHsiang) { Disaster = 0; } else if (Disaster < 0 && Player.Defensor != null && Player.Defensor.Model is P_YinYangChing) { Disaster = 0; } Expectation += i * Disaster; } if (CurrentBlock.GetMoneyPassPercent != 0) { int Disaster = PMath.Percent(Player.Money, CurrentBlock.GetMoneyPassPercent); if (Disaster < 0 && -Disaster <= 1000 && Player.Traffic != null && Player.Traffic.Model is P_NanManHsiang) { Disaster = 0; } else if (Disaster < 0 && Player.Defensor != null && Player.Defensor.Model is P_YinYangChing) { Disaster = 0; } Expectation += i * Disaster; } if (CurrentBlock.GetCardPass != 0) { Expectation += i * 2000 * CurrentBlock.GetCardPass; } if (CurrentBlock.BusinessType.Equals(PBusinessType.Altar) && CurrentBlock.Lord != null && CurrentBlock.Lord.TeamIndex != Player.TeamIndex) { Expectation -= 1000; } } CurrentBlock = Block.NextBlock; } Player.Area.AmbushCardArea.CardList.ForEach((PCard Card) => { if (Card.Model is P_TsaaoMuChiehPing Cao) { Expectation += Cao.AIExpect(Game, Player, Block); } }); return(Expectation / (Banned > 0 ? 5 : 6)); }