-
Notifications
You must be signed in to change notification settings - Fork 1
Compiler
The compiler is a non-scene element which detects any errors in the current traffic system. If there are errors, the compiler will display said errors in the Build Views error scene and highlight any offending node(s). However, if the compiler does not detect any errors with the current traffic system as it is, it will start the process of repackaging Nodes into Action Points, repackaging Links into Roads, and moving the scene to the Sim View Scene.
To activate the compiler, and the move to the Simulation View, a user only has to press the play button on the upper left hand corner of the Build View.
The Compiler must:
- Determine if the current built traffic system is valid
- If the current built traffic system is invalid, inform the user of the error with visual cues and stay on Build View
- If the current built traffic system is valid, convert nodes and links to appropriate Sim View elements (roads and action points)
- Convert and start Sim View Scene if the traffic system is valid
This part is called when a user presses the compiler button in the Build View. This component calls error checking and gameobject conversion as described below.
This part of the compiler fetches all of the nodes and links. The compiler then removes Build View components and add a controller component. This controller is responsible for adding Sim View components set by the user. The compiler will lastly change the gameobject's name.
This component of the compiler fetches all nodes and determines if nodes are all connected to at least one link (using _isConnected property of the node). If the compiler determines that there is at least one node not connected to another node via link, the compiler will change the respected disconnected node's sprite component to one with orange highlighting as well as will send and error message back to ErrorView.cs to be shown in Build View.
The compiler will also analyze the nodes and determine the initial paths for cars. Currently, pathfinding is implemented using the following algorithm:
-
A link has an impedance/resistance
-
Sum up the impedance of each path, and take the best one
-
Add randomness so that not every car takes the same path
This impedance is calculated regularly, so that path may change.
How a route will be chosen:
Let i be an index for each route that is available between an OD pair.
Let c_i be the cost or impedance of traveling on that route (for now, travel distance)
The probability of taking route i = where is a positive scale parameter that the user should be able to select/modify. Using these probabilities, each vehicle should randomly select one of the paths. The higher the probability, the more likely that path should be selected.
This file contains all the behavior for the compiler and its actions.
In the future, we would like to see if there any way to optimize the compiler's process, as the compiler's computations have the potential to build up with larger systems. Also there may be a need to have a scaling system with links when converting to roads in Sim View. This process should most likely be done in the compilation step.