Grid Walks and Direction Vectors
Move with dx, dy and stay in bounds.
Walking on a Grid
Many simulations happen on a grid of rows and columns. A token starts somewhere and moves cell by cell following directions. 🗺️
Track Row and Column
Hold your position as a (r, c) pair. Row indexes the line top to bottom and column indexes left to right.
r, c = 0, 0All lessons in this course
- Model State and Step Forward
- Grid Walks and Direction Vectors
- Cycle Detection in Simulations
- Tame the Tricky Edge Cases