Tackling Inefficiency in Code
Was a 3D list the best option? It slowed the time it took to load information.
Before that, how did I add data about the buildings, store them, and retrieve them again the next time I opened the map? I converted the 3D list of information into a Numpy array and then converted this into a .csv file to save on the local drive. Every time I run the program, it can load an existing map from the saved .csv.
Even before that, how did I get the program to draw colors that represented different space types? I got the program to understand click and drag to select multiple cells. I created buttons to mean different space types. So when you click and drag to select multiple cells, and then select a button that represented a space type (building, greens, open space, road, water), it would render the selected cells into this space type.
I drew an entire map that was inspired by Manhattan into the program and got this to save as a .csv.
I gave each selected group of cells a UUID. So when you select a bunch of cells, contiguous or not, and then render them a specific space type, these cells that are now a new space type, have a unique UUID. I then made these cells that have all the same UUID selectable. So when you select a space type with the same UUID, it gets an orange tint indicating selection.
I added more buttons to add input for each space type. So now, you can select a space type and add input. This gets stored in the 3D list which then ends up in a saved .csv. Here comes the inefficiency problem. The 3D list was too slow as I would learn later.
I wrote the code to load up the map with all the stored information as a “Load Map” button. I noticed now that the 3D list load-up was too slow. I changed my code to save all the information directly into the .csv using Pandas.
I introduced the randomize feature to add random values for the loaded map each time it loads.
The hypothetical city was now ready.
I added a “Start Game” button to introduce a new marker that represents a new minority-owned business. You can move the marker around and place it where you like. To reduce complexity for the project’s first phase, I limited the number of markers to just one.
Moving the marker around: I wrote code to drop the marker after the marker shows up upon pressing “Start Game”; and then be able to click on the marker again and move it elsewhere.
The Matrices: I came up with the math to represent the indicators that Jane Jacobs and Kimberley Kinder talk about with reference to planning diverse places. I illustrated these values using a health bar that I displayed on the screen. TADA!
As you move the marker, the program calculates percentages for the two indices: diversity and affordability, and renders them as health bars for the user to use to make his next moves!
Read on to learn more about my future plans for this project!