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


C# Field.GetCell方法代码示例

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


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

示例1: TransformCell

 public int TransformCell(Field pastF, int x, int y)
 {
     int[] ExistingNeighbors = pastF.GetNeighborsInTwoDirections(x, y);
     int nextState = (pastF.GetCell(x, y) + 1) % StatesNumber;
     foreach (int c in ExistingNeighbors)
     {
         if (c == nextState)
             return nextState;
     }
     return pastF.GetCell(x, y);
 }
开发者ID:Talrandel,项目名称:CellarAutomat,代码行数:11,代码来源:OneDimentionalCyclic.cs

示例2: TransformCell

        public int TransformCell(Field pastF, int x, int y)
        {
            int centerCell = pastF.GetCell(x, y);
            // Possible check for -1 value of cell in case of addition all cell's neighbors to array
            //int[] Neighbors = f.GetNeighborsInAllDirections(x, y);
            int northWestCell = pastF.GetCellAtDirection(x, y, Directions.NorthWest);
            int northEastCell = pastF.GetCellAtDirection(x, y, Directions.NorthEast);
            int northCell = pastF.GetCellAtDirection(x, y, Directions.North);
            int southWestCell = pastF.GetCellAtDirection(x, y, Directions.SouthWest);
            int southEastCell = pastF.GetCellAtDirection(x, y, Directions.SouthEast);
            int southCell = pastF.GetCellAtDirection(x, y, Directions.South);
            int westCell = pastF.GetCellAtDirection(x, y, Directions.West);
            int eastCell = pastF.GetCellAtDirection(x, y, Directions.East);

            int[] Neighbors = { northWestCell, northCell, northEastCell, eastCell, southEastCell, southCell, southWestCell, westCell };
            for (int i = 0; i < Neighbors.Length; i++)
            {
                if (Neighbors[i] < 0)
                    Neighbors[i] = 0;
            }

            if (centerCell == 0)
                return 2 * ((northWestCell % 2) ^ (northEastCell % 2)) + northCell % 2;
            else if (centerCell == 1)
                return 2 * ((northWestCell % 2) ^ (southWestCell % 2)) + westCell % 2;
            else if (centerCell == 2)
                return 2 * ((southWestCell % 2) ^ (southEastCell % 2)) + southCell % 2;
            else
                return 2 * ((southEastCell % 2) ^ (northEastCell % 2)) + eastCell % 2;
        }
开发者ID:Talrandel,项目名称:CellarAutomat,代码行数:30,代码来源:VenusSurface.cs

示例3: TransformCell

 public int TransformCell(Field pastF, int x, int y)
 {
     int neighborCount = pastF.GetLiveNeighborCountNeiman(x, y);
     if (neighborCount == 1)
         return 1;
     else
         return pastF.GetCell(x, y);
 }
开发者ID:Talrandel,项目名称:CellarAutomat,代码行数:8,代码来源:NeimanSimple.cs

示例4: TransformCell

 public int TransformCell(Field pastF, int x, int y)
 {
     int neighborCount = pastF.GetLiveNeighborCount(x, y);
     if (neighborCount == 3)
         return 1;
     else if (neighborCount == 2)
         return pastF.GetCell(x, y);
     else
         return 0;
 }
开发者ID:Talrandel,项目名称:CellarAutomat,代码行数:10,代码来源:BaseLife.cs


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