You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: public/logs/music/dying-light-ost.txt
+2-6Lines changed: 2 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,8 @@
1
-
# Dying Light Original Soundtrack
2
-
3
-
# Dying Light Original Soundtrack
4
-
5
1
The original soundtrack for the 2015 survival horror hit **Dying Light**, composed by the legendary Polish composer **Pawel Blaszczak**.
6
2
7
3
## About Pawel Blaszczak
8
4
9
-
Pawel Blaszczak is a renowned Polish video game music composer who has been active in the industry since 1997. He is best known for his work with **Techland**, where he served as Sound Director for many years.
5
+
Pawel Blaszczak is a renowned Polish video game music composer who has been active in the industry since 1997. He is best known for his work with **Techland**, where he served as Sound Director for many years.
10
6
11
7
His impressive portfolio includes:
12
8
- **Call of Juarez** series
@@ -34,4 +30,4 @@ The soundtrack is famous for its transition between the rhythmic, synth-heavy da
34
30
It is truly one of the best video game OSTs out there. It doesn't just provide background noise; it defines the identity of the game. The way it fits the atmosphere is nothing short of perfect.
Copy file name to clipboardExpand all lines: public/posts/quadtree-algorithm-spatial-indexing.txt
+142-6Lines changed: 142 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -60,14 +60,150 @@ A robust Quadtree implementation relies on three core components:
60
60
| :--- | :--- | :--- |
61
61
| **1. Insert** | Add a point | Check if point is within Boundary. If not, return false. |
62
62
| **2. Check Capacity** | Room available? | If points < Capacity, add to list. Return true. |
63
-
| **3. Subdivide** | Split! | If points == Capacity, create 4 children. Move current points to children? (Depends on implementation). |
63
+
| **3. Subdivide** | Split! | If points == Capacity, create 4 children. Move current points to children. |
64
64
| **4. Query** | Find neighbors | Define a "Search Range". Only check nodes that intersect with this range. |
65
65
66
-
### The "Query" Optimization
67
-
68
-
The real magic happens during the `query`. Instead of checking all $N$ points, the Quadtree traverses the tree. If a node's boundary doesn't intersect with your search range, you prune the entire branch.
66
+
## Part 4: The Lifecycle (The "Breathe" of the Tree)
67
+
68
+
If you watch a Quadtree simulation, you'll see the boxes constantly flickering. This is the tree "breathing" as it adapts to movement.
69
+
70
+
### The Subdivision-Collapse Loop
71
+
72
+
A Quadtree is never static. As objects move, the tree must maintain its efficiency through two opposing forces:
73
+
74
+
1. **The Split (Expansion)**: When a node becomes too dense (exceeding `capacity`), it must subdivide. This prevents the "local $O(N^2)$" problem within that specific box.
75
+
2. **The Merge (Contraction)**: If an area becomes sparse (e.g., a grenade explodes and clears out a room), the four child quadrants should be destroyed. Their remaining points are moved back up to the parent.
76
+
77
+
**Why merge?** Because traversing deep branches of an empty tree is a waste of CPU cycles. We want the tree to be as shallow as possible while still keeping individual node counts low. In many real-time simulations (like the one below), we simply **rebuild the entire tree** every frame. This implicitly handles both splitting and merging, as the new tree only exists where particles currently reside.
78
+
79
+
## Part 5: The Go Implementation
80
+
81
+
I speak Go. Here is how you implement a production-ready, type-safe Quadtree in Golang:
82
+
83
+
```go
84
+
package spatial
85
+
86
+
// Point represents a 2D coordinate with optional metadata
87
+
type Point struct {
88
+
X, Y float64
89
+
Data interface{}
90
+
}
91
+
92
+
// Rectangle defines a boundary (Center X, Y and Half-Dimensions W, H)
func (qt *Quadtree) Query(rangeRect Rectangle, found []Point) []Point {
154
+
if !qt.Boundary.Intersects(rangeRect) {
155
+
return found
156
+
}
157
+
158
+
for _, p := range qt.Points {
159
+
if rangeRect.Contains(p) {
160
+
found = append(found, p)
161
+
}
162
+
}
163
+
164
+
if qt.Divided {
165
+
found = qt.NW.Query(rangeRect, found)
166
+
found = qt.NE.Query(rangeRect, found)
167
+
found = qt.SW.Query(rangeRect, found)
168
+
found = qt.SE.Query(rangeRect, found)
169
+
}
170
+
171
+
return found
172
+
}
173
+
174
+
// Example Main function for local execution
175
+
func main() {
176
+
// 1. Define the world boundary (Center 200, 200 with 200 half-width/height)
177
+
boundary := Rectangle{200, 200, 200, 200}
178
+
179
+
// 2. Initialize the Quadtree with a capacity of 4 points per node
180
+
qt := NewQuadtree(boundary, 4)
181
+
182
+
// 3. Insert some random points
183
+
points := []Point{
184
+
{100, 100, "Point A"},
185
+
{105, 110, "Point B"},
186
+
{110, 105, "Point C"},
187
+
{120, 120, "Point D"},
188
+
{300, 300, "Point E"}, // This will be in a different quadrant
189
+
}
190
+
191
+
for _, p := range points {
192
+
qt.Insert(p)
193
+
}
194
+
195
+
// 4. Query a specific area (Center 100, 100 with 50 half-width/height)
196
+
searchRange := Rectangle{100, 100, 50, 50}
197
+
found := qt.Query(searchRange, []Point{})
198
+
199
+
fmt.Printf("Found %d points in search range:\n", len(found))
200
+
for _, p := range found {
201
+
fmt.Printf("- %s at (%.2f, %.2f)\n", p.Data, p.X, p.Y)
202
+
}
203
+
}
204
+
```
69
205
70
-
## Part 4: The Deductions (The Performance Verdict)
206
+
## Part 6: The Deductions (The Performance Verdict)
71
207
72
208
By shifting from $O(N^2)$ to $O(N \log N)$ or even $O(\log N)$ for localized queries, the Quadtree transforms the impossible into the trivial.
73
209
@@ -104,4 +240,4 @@ The Quadtree is a masterclass in **Spatial Hashing**. It teaches us that the bes
104
240
105
241
Whether you're building a 2D bullet hell, a map of the stars, or an image compression algorithm (where quadrants of the same color are merged), the Quadtree is your most reliable spatial ally.
106
242
107
-
You can check a visual implementation of this in my **Knowledge Graph** or any of my generative art projects that rely on particle proximity!
243
+
You can check a visual implementation of this in my **[Quadtree Simulation](/apps/quadtree-sim)** app or any of my generative art projects that rely on particle proximity!
0 commit comments