當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。