SimulateAutumn - AS 2017

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

The Code

static void SimulateAutumn(char[,] Field)
{
    for (int Row = 0; Row < FIELDLENGTH; Row++)
    {
        for (int Column = 0; Column < FIELDWIDTH; Column++)
        {
            if (Field[Row, Column] == PLANT)
            {
                SeedLands(Field, Row - 1, Column - 1);
                SeedLands(Field, Row - 1, Column);
                SeedLands(Field, Row - 1, Column + 1);
                SeedLands(Field, Row, Column - 1);
                SeedLands(Field, Row, Column + 1);
                SeedLands(Field, Row + 1, Column - 1);
                SeedLands(Field, Row + 1, Column);
                SeedLands(Field, Row + 1, Column + 1);
            }
        }
    }
}

Explanation