This project is a college proyect for the CIIIA, which simulates a traffic 4-way intersection in Unity based in the coordinates over time given by a mesa framework Python simulation.
To run the Python portion of this project, you'll need to install the following Python packages:
-
Flask: A micro web framework for Python.
pip install Flask -
Mesa: A library for agent-based modeling.
pip install mesa -
Matplotlib: A plotting library for Python.
pip install matplotlib -
Numpy: A library for numerical computations in Python.
pip install numpy
To set up the Unity part of the project you need to drag and drop the package EscenaCiudad.unitypackage into a new project's scenes to install it. You'll also need to install the following package:
- Newtonsoft.Json-for-Unity: A JSON serialization library for Unity. To install, follow these steps:
- Open the Unity Package Manager (Window -> Package Manager).
- Add a new extension by package name
- Enter
com.unity.nuget.newtonsoft-jsonas the package name. - Enter
3.2.1as the version (or the latest available version). - Click the "Add" button to install the package.
Make sure to follow the provided link for more detailed installation instructions for Newtonsoft.Json-for-Unity.
-
Clone this repository to your local machine.
-
Navigate to the Python project directory.
-
Run the Python script using the following command:
python Server.py
To run the simulation in Unity you can either use the generated jsons in the package or create your own using the files Semaforo.py and Semaforo_SMART.py which will generate a new simulation file with a preview using matplotlib.
-
Open Unity and load the Unity project from the project directory.
-
Ensure that you've installed the
Newtonsoft.Json-for-Unitypackage following the instructions in the "Requirements" section. -
To switch between the Normal and the Smart Light you can switch the URL in the controller object in Unity