1 of 17

Introducing the AQA AS level computer science Paper 1 Pre-release 2017 material

Plant Growth Simulation – Exploration of the pre-release skeleton program for Python

2 of 17

Learning objectives

  • Run the Plant Growth Simulation

  • Initial Exploration of the pre-release skeleton program for Python

  • Read and discuss the preliminary material

  • Run the skeleton program and identify issues

  • Investigate the skeleton code

  • Make modifications to the skeleton code

3 of 17

Pre-release files

Download the following files from your school’s secure area according your teacher’s instruction:

Electronic Answer document

2017 Electronic Answer Document (EAD) 7516-1D.docx

Preliminary material

7516-1-PM-ComputerScience-AS-5Jun-AM-To E6.pdf

Skeleton Code

Paper1_ASLvl_2017_Python3_Pre.py

Additional file

File.txt

4 of 17

Preliminary material

Read through the preliminary material:

7517-1-PM-Computer Science-A-11Jun25-AM G4002.pdf

Think, pair and share your initial reflections

5 of 17

Run

Run the code: Paper1_ASLvl_2017_Python3_Pre.py

Do not look at the code at this stage. Run the simulation

Spend 10 minutes

Can you identify any areas of the simulation which does not work as you might expect?

6 of 17

Explain how the game works

  • Share your explanation on www.padlet.com
  • Read the explanation of others
  • Add the explanation as a comment at the top of the skeleton code (open the file: Paper1_ASLvl_2017_Python3_Pre.py)

7 of 17

Investigate the code

8 of 17

Investigate the code

View and open the code:

Paper1_ASLvl_2017_Python3_Pre.py

Spend a few minutes perusing the code

What are your initial thoughts?

Discuss with the class

9 of 17

The Game of Life

  • This simulation is based on the Game of Life.
  • The Game of Life is a simulation of life and death on a grid of cells.
  • Each cell can be alive or dead, and its state changes based on the state of its neighbours.
  • The game starts with an initial setup of cells. (some alive and some dead).
  • The grid updates in steps, with each cell's state changing according to the rules specified below
  • Over the time steps patterns can be established.

Rules

  • Each cell has 8 neighbouring cells (adjacent cells in all directions).
  • The state of each cell in the next generation is determined by the following:
  • A live cell with 2 or 3 live neighbours remains alive.
  • A dead cell with exactly 3 live neighbours becomes alive.
  • A live cell with fewer than 2 live neighbours dies owing to isolation

The game of life code is here

It is worth look at as it is a simple version of the plant simulation

.

A live cell with more than 3 live neighbours dies owing to over-crowding.

10 of 17

Complete the structure diagram

Simulation

SimulateOneYear

SimulateSpring

SimulateWinter

11 of 17

Complete the structure diagram

Simulation

InititaliseField

GetHowLongToRun

SimulateOneYear

SimulateSpring

SimulateAutumn

SimulateSummer

SimulateWinter

CountPlants

SeedLands

Display

ReadFile

CreateNewField

12 of 17

Data file

13 of 17

Explain these procedures and functions

Simulation

InitialiseField

ReadFile

CreateNewField

GetHowLongToRun

Add comments to the skeleton code explaining these procedures

14 of 17

Explain these procedures and functions

SimulateOneYear

Display

SimulateWinter

SimulateSpring

SimulateAutumn

SimulateSummer

CountPlants

SeedLands

Add comments to the skeleton code explaining these procedures

15 of 17

Exercise

  1. State the name of an identifier for a list
  2. State the name of an identifier for a variables
  3. State the name of an identifier for a user-defined subroutine that have 0 parameters
  4. State the name of an identifier for a user-defined subroutine that have 1 parameter
  5. State the name of an identifier for a user-defined subroutine that have 2 parameters
  6. State the name of an identifier for a user-defined subroutine that have 3 parameters
  7. State the name of an identifier for a variable that is used to store whole numbers

16 of 17

Exercise

  1. In SimulateSummer, SimulateAutumn, SinmulateWinter, SimulateSpring Explain the need for a nested FOR loop and the role of the Row and Column variables
  2. Why has a named constant FIELDLENGTH been used instead of the numeric value 20 throughout the code?
  3. Look at the SimulateSummer subroutine. Describe how drought is applied.
  4.  Look at the Simulation subroutine. Explain why a WHILE loop has been used rather than a FOR loop.
  5.  State two reasons why subroutines should, ideally, not use global variables

17 of 17

Make

  1. In InitialiseField use Y and y option.
  2. In GetHowLongToRun add in sensible any error checking.
  3. In SimulateAutumn make sure that no plants cannot be added outside of the edges.
  4. In ReadFile need to tell the user if the filename is wrong and gives the user the option to rename the file if it is wrong.
  5. After each year adds up the number of cells in each category, soil, seed and plant.
  6. Get the program to randomly add in cells containing rock.
  7. Add to the model a random scenario for flooding that occurs 1 in every 5 year during summer that damages a quarter of plants.