Skip to content

setPoweredState()

Jodoin, Nathan edited this page Nov 5, 2022 · 2 revisions

Disclaimer:

This was originally intended to be a major component of our program functionality, however, the project requirements have no function for the powerplant Chandler and I coded the powerline traversal functionality into the program before the functionality was deemed unnecessary.

Originally, our intention was to only allow zone growth from zones adjacent to powerlines that were powered, or those which were directly adjacent to a powerplant. However, this paradigm was counter to the ruleset provided for the assignment and we wanted to get the required functionality done first, so we tabled the rest of the functionality.

How it works

On initialization, for each powerplant from which this function is called, the powerplant uses recursive DFS to traverse local adjacencies and do one of two things.

  1. Base Case: If there are no more undiscovered zones in the queue, return up the stack.

  2. Normal Case: for each current zone in the discovery queue, check adjacent zones and do the following:

    1. If the adjacent zone is a powerline, powered_road, or powerplant, add it to the discovery queue.
    2. Set the adjacent zone's powered state to true.

Clone this wiki locally