当前位置: 首页>>代码示例>>C#>>正文


C# GameState.SetDice方法代码示例

本文整理汇总了C#中GameState.SetDice方法的典型用法代码示例。如果您正苦于以下问题:C# GameState.SetDice方法的具体用法?C# GameState.SetDice怎么用?C# GameState.SetDice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameState的用法示例。


在下文中一共展示了GameState.SetDice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResignHint

        public override ResignHint ResignHint(GameState gamestate, bool has_moved)
        {
            int lost_with_single, lost_with_gammon, lost_with_backgammon;

            if (gamestate.GameType == GameType.Match)
            {
                int opp_score = gamestate.Score(1 - gamestate.PlayerOnTurn);
                lost_with_backgammon = Math.Min(gamestate.MatchTo, opp_score + gamestate.Cube.Value * 3);
                lost_with_gammon = Math.Min(gamestate.MatchTo, opp_score + gamestate.Cube.Value * 2);
                lost_with_single = Math.Min(gamestate.MatchTo, opp_score + gamestate.Cube.Value);
            }
            else
            {
                lost_with_backgammon = gamestate.Cube.Centered ? gamestate.Stake : Math.Min(gamestate.Limit, gamestate.Stake * gamestate.Cube.Value * 3);
                lost_with_gammon = gamestate.Cube.Centered ? gamestate.Stake : Math.Min(gamestate.Limit, gamestate.Stake * gamestate.Cube.Value * 2);
                lost_with_single = gamestate.Cube.Centered ? gamestate.Stake : Math.Min(gamestate.Limit, gamestate.Stake * gamestate.Cube.Value);
            }

            if (!has_moved)
            {
                // Dice not rolled yet
                EvaluationInfo eval_info = resign_gnubg.Eval(gamestate);

                /*Console.WriteLine(eval_info.Win);
                Console.WriteLine(eval_info.WinGammon);
                Console.WriteLine(eval_info.WinBackgammon);
                Console.WriteLine(eval_info.LoseGammon);
                Console.WriteLine(eval_info.LoseBackgammon);
                Console.WriteLine(eval_info.Lose);*/

                if (eval_info.LoseBackgammon > 0.995)
                    return new ResignHint(ResignValue.Backgammon);

                if (eval_info.LoseGammon > 0.995 && (eval_info.LoseBackgammon <= 0.0000001))// || (int)capped_loss >= 2))
                    return new ResignHint(ResignValue.Gammon);

                if (eval_info.Lose > 0.995 && ((eval_info.LoseGammon <= 0.0000001 && eval_info.LoseBackgammon <= 0.0000001)))// || (int)capped_loss >= 1))
                    return new ResignHint(ResignValue.Single);

                if (eval_info.Lose > 0.995 && lost_with_single == lost_with_gammon && lost_with_single == lost_with_backgammon && lost_with_gammon == lost_with_backgammon)
                    return new ResignHint(ResignValue.Single);

                if (eval_info.Lose > 0.995 && lost_with_single == lost_with_gammon)
                    return new ResignHint(ResignValue.Single);
            }
            else
            {
                // The optimal move has been made, change the turn to opp to see the effect of the move on eval
                int player_on_roll = gamestate.PlayerOnRoll;
                int player_on_turn = gamestate.PlayerOnTurn;
                int[] dice = new int[2];
                Array.Copy(gamestate.Dice, dice, 2);

                gamestate.ChangeTurn();

                EvaluationInfo eval_info = resign_gnubg.Eval(gamestate);

                /*Console.WriteLine(eval_info.Win);
                Console.WriteLine(eval_info.WinGammon);
                Console.WriteLine(eval_info.WinBackgammon);
                Console.WriteLine(eval_info.LoseGammon);
                Console.WriteLine(eval_info.LoseBackgammon);
                Console.WriteLine(eval_info.Lose);*/

                gamestate.SetDice(dice[0], dice[1]);
                gamestate.PlayerOnTurn = player_on_turn;
                gamestate.PlayerOnRoll = player_on_roll;

                if (eval_info.WinBackgammon > 0.995)
                    return new ResignHint(ResignValue.Backgammon);

                if (eval_info.WinGammon > 0.995 && (eval_info.WinBackgammon <= 0.0000001))// || (int)capped_loss >= 2))
                    return new ResignHint(ResignValue.Gammon);

                if (eval_info.Win > 0.995 && ((eval_info.WinGammon <= 0.0000001 && eval_info.WinBackgammon <= 0.0000001)))// || (int)capped_loss >= 1))
                    return new ResignHint(ResignValue.Single);

                if (eval_info.Win > 0.995 && lost_with_single == lost_with_gammon && lost_with_single == lost_with_backgammon && lost_with_gammon == lost_with_backgammon)
                    return new ResignHint(ResignValue.Single);

                if (eval_info.Win > 0.995 && lost_with_single == lost_with_gammon)
                    return new ResignHint(ResignValue.Single);
            }

            return new ResignHint(ResignValue.None);
        }
开发者ID:alexhanh,项目名称:Botting-Library,代码行数:86,代码来源:GnuBgHintModule.cs


注:本文中的GameState.SetDice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。