Skip to content
Jodoin, Nathan edited this page Nov 4, 2022 · 6 revisions

A brief ordered non-syntactical description of how our program works at the main() function level.

NOTE: For more granular information on specific functionality, click the function name or navigate to that function's page in the sidebar.

  1. The program first checks to ensure the user input a filename for the configuration file as an argument for the program. If no filename is provided, the program exits with an error and prompts the user to try again with a filename as an argument.

  2. The Map struct is instantiated.

  3. fileIO(): The fileIO function reads in the configuration file first to identify the name of the region file, the refresh rate, and the maximum time the simulation should run for. Then, the information is stored in the appropriate data members of the Map struct as zone or zone descendant object or integer data.

  4. Adjacency List Calculation

    1. calcLocalAdjacencies()
      For each zone in the map, local adjacencies are populated.
    2. calcRemoteAdjacencies()
      For each zone in the map, remote adjacencies are populated as required.
  5. Powered State Calculation
    Not a necessary functional component. Our submission for extra functionality. See the functional description for more information.

  6. z_list instantiated

  7. populatedZlist()
    Populate z_list with zones according to zone type.

  8. popZoneSort()
    Sort the z_list populated pointer list data members according to the growth rules.

  9. Update & Display Loop

    1. The program displays a banner including the simulation settings.
    2. Then, while the current frame is not the last frame.
      1. If the current frame is 0 or divisible by the refresh rate, display the region map. (display()
      2. Attempt population updates (updateMap()), and set the boolean change to true if the map changes between the current and next timesteps. If the map does not change between the current and next timestep, change is set to false.
      3. Calculated pollution updates by iterating through the industrial zones in the master list and calling updatePollution() for each industrial zone. This uses BFS to set the pollution values of each zone based on how far away from the current industrial zone it is.
      4. Increment the current frame.
      5. If change is false, break the update and display loop.
  10. Display the final pollution map. (displayPollutedMap())

  11. Begin the analysis loop. (analysis())

  12. Exit the program with a successful return code.

Clone this wiki locally