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


C# IPlayer.MovePiece方法代码示例

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


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

示例1: ProcessRequest

 public static void ProcessRequest(HttpContextBase context, IPlayer player)
 {
     string boardCode = context.Request.Form["board"];//".......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... zzzzzzzz..";
     string pieceCode = context.Request["piece"]; //"l";
     IBoard board = Board.Parse(boardCode);
     Piece piece = (Piece) Enum.Parse(typeof(Piece), new string(char.ToUpper(pieceCode[0]), 1));
     TetrisMove move = player.MovePiece(board, piece);
     context.Response.ContentType = "text/plain";
     context.Response.Write(string.Format("position={0}&degrees={1}", move.Position, move.Degrees));
 }
开发者ID:1tgr,项目名称:tetris-agent,代码行数:10,代码来源:Handler.ashx.cs

示例2: Test

        private static void Test(IPlayer player, int count)
        {
            Random random = new Random();

            for (int game = 0; game < count; game++)
            {
                IBoard board = Board.Empty;
                Piece pieceCode;
                int[,] rotatedPieceData;
                TetrisMove move;

                do
                {
                    int score;
                    board = board.Collapse(out score);

                    Console.WriteLine(board);
                    Console.WriteLine("---------- {0}", score);

                    int pieceIndex = random.Next(Pieces.Length);
                    pieceCode = Pieces[pieceIndex];

                    try
                    {
                        move = player.MovePiece(board, pieceCode);
                        CollectionAssert.Contains(Board.DegreesOptions, move.Degrees, "Degrees");
                        Assert.GreaterOrEqual(move.Position, 0, "Position");

                        int[,] pieceData = PieceData.All[pieceCode];
                        rotatedPieceData = Board.Rotate(pieceData, move.Degrees);
                        Assert.LessOrEqual(move.Position, 10 - rotatedPieceData.GetLength(1), "Position");
                    }
                    catch (Exception ex)
                    {
                        throw new AssertionException(ex.Message + " Piece is " + pieceCode + ".", ex);
                    }
                } while (Board.TryUpdateBoard(rotatedPieceData, ref board, move.Position, char.ToLower(pieceCode.ToString()[0])));
            }
        }
开发者ID:1tgr,项目名称:tetris-agent,代码行数:39,代码来源:GameTests.cs


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