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


C# Storage.AddScore方法代码示例

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


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

示例1: RunGameIteration

        private static void RunGameIteration(int testTypeNum, Storage storage)
        {
            Game game = new Game(4);
            int?[,] startingBoard = new int?[game.size, game.size];
            for (int i = 0; i < game.size; i++) {
                for (int j = 0; j < game.size; j++) {
                    startingBoard[i, j] = game.Board[i, j];
                }
            }

            //game.DisplayBoard();

            int move = 0;
            int temp = 0; // Means different things dependent on algorithm
            while (game.Running) {
                switch (testTypeNum) {
                    case 0: // Random Simple
                        move = Rand.Next(0, 4);
                        break;
                    case 1: // Random no doubles
                        move = Rand.Next(0, 4);
                        while (move == temp) {
                            move = Rand.Next(0, 4); // Never do the same move twice in a row
                        }
                        temp = move;
                        break;
                    case 2: // Rotate Counter-Clockwise
                        move = (move + 1) % 4;
                        break;
                    case 3: // Rotate Clockwise
                        if (move == 0) move = 4;
                        move = (move - 1) % 4;
                        break;
                    case 4: // Rotate both ways, switching at a constant interval
                        if (temp >= 20)
                            temp = 0;
                        if (temp >= 10)
                            move = (move - 1) % 4;
                        else
                            move = (move + 1) % 4;
                        temp++;
                        break;
                    case 5: // Rotate both ways, switching at a random interval
                        temp = Rand.Next(0, 20);
                        if (temp >= 10) {
                            if (move == 0) move = 4;
                            move = (move - 1) % 4;
                        } else {
                            move = (move + 1) % 4;
                        }
                        break;
                }
                game.MakeMove(move);
            }
            //game.DisplayBoard();
            if (game.Loss) {
                //Console.WriteLine("You lost!");
            } else {
                Console.WriteLine("Something else happened..");
            }
            storage.AddScore(new Score { BestTile = game.CurrentMax, Moves = game.NumberOfMoves, TotalScore = game.TotalScore, Board = game.Board, StartingBoard = startingBoard });
        }
开发者ID:Chrisazy,项目名称:2048Bot,代码行数:62,代码来源:Program.cs


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