Closed luisesanmartin closed 2 years ago
@kbjarkefur I also just realized that a few more steps are needed for importing and running files committed to GH with a colab notebook (instructions here). I'm going to add this so that participants can import all files to the notebook
It's a fun coding task. Took me 3 hours to finish as-is. I added some basic test cases to each step to check correctness. Not comprehensive so my solution is not guaranteed to be fully correct.
The only liberty I took was with the return value of neighborhood
– instead of the sliced array of arrays, I just returned the top left and bottom right locations marking the neighborhood. I can't explain exactly why I just intuitively did that; perhaps just the light-weight-ness and the consistency of working with indexes?
Here are some notes I took while going through the project:
Option to simplify the task: drop the extension
parameter and fix it at 1
Option to add bonus/advanced material: ask the students to think of ways to optimize program: are there things that can be done faster? E.g. separating the candidate listing and moving distance calculation is a good conceptual model for the first pass but the search can be optimized by starting from the cells closer to the agent then expanding outward (increasing moving distance) and terminating the search for more candidates as soon as the nearest above-threshold location is found.
I personally find the square matrix assumption somewhat arbitrary. It's an assumption that doesn't simplify things much. Maybe there are theory reasons behind it, but I don't see any from a programming point of view.
Minor thing, but can we change the file name to project-1-schelling-model-of-segregation.ipynb
? Otherwise the URL gets so ugly. https://github.com/worldbank/dec-python-course/blob/project1/1-foundations/project-1-schelling-model/Project%201%20-%20Schelling's%20model%20of%20segregation.ipynb
This is my first commit of project 1. I'm still pending to implement test functions for each task, I plan to have it finalized during the week. These are my comments on how the project is now:
neighborhood()
function ourselves (I think that's going to be one of the bottlenecks) and/or change the moving rules to something simpler, like agents moving to any available location at random