示例#1
0
    int Smooth(CellularSimulation <int> .Cell cell)
    {
        int outOfBoundsNeighbors = 8 - cell.CountNeighbors();
        int wallNeighbors        = cell.CountNeighbors((me, other) => other.Value == 1);
        int wallCount            = outOfBoundsNeighbors + wallNeighbors;

        if (wallCount > 4)
        {
            return(1);
        }
        else if (wallCount < 4)
        {
            return(0);
        }
        return(cell.Value);
    }
示例#2
0
    int Tick(CellularSimulation <int> .Cell cell)
    {
        switch (cell.CountNeighbors((x, y) => y.Value == 1))
        {
        case 0:
        case 1:
            return(0);

        case 2:
            return(cell.Value);

        case 3:
            return(1);

        case 4:
        case 5:
        case 6:
        case 7:
        case 8:
        default:
            return(0);
        }
    }