本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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;
}