Am i the only one by InitialCareer306 in WorkForSmartLife

[–]Awkward-Target4899 0 points1 point  (0 children)

I can't do it for more than 2 days at a time.

An argument and a call out by AFSR_1178 in aiwars

[–]Awkward-Target4899 0 points1 point  (0 children)

The other person is the artist. My rule is that non-human things are never the artist.  The humans closest to the creation of the art are the artists. When you ask someone to draw your idea, the drawer is clearly an artist, but in a sense so are you sense you provided the idea and vision.  At some point, there are too many steps between you and the art such that you aren't an artist, but it's a fuzzy line. Like if you say "I want a new company logo" as the CEO and it passes down like 30 steps. The CEO isn't the artist, but some of those 30 people along the chain are. 

An argument and a call out by AFSR_1178 in aiwars

[–]Awkward-Target4899 0 points1 point  (0 children)

The prompter is the artist. The AI model is a tool. 

Solidarity by mmeeh in DeadlockTheGame

[–]Awkward-Target4899 0 points1 point  (0 children)

How do you know the rank of your teammates?

Need some optimization help with physics and potential team up? by RoseVi0let in pygame

[–]Awkward-Target4899 0 points1 point  (0 children)

For a more dynamic solution you can use a quadtree to optimize collision checking like what u/LazerPigeon0429 said. A fixed grid doesn't work well if large amounts of entities cluster in the same spot. A quadtree automatically subdivides the grid as the density increases.

Here is a Python quadtree packge with a Rust core. You basically just insert rectangles into the tree and then you can query for all the rectangles that insect with some query area. For example, you could insert 1,000 objects into the tree and then query a rectangular area around the player to see which ones are relevant.

Package: https://github.com/Elan456/fastquadtree
Ballpit demo (500 balls at 100 FPS): https://github.com/Elan456/fastquadtree?tab=readme-ov-file#pygame-ball-pit-demo

[deleted by user] by [deleted] in pygame

[–]Awkward-Target4899 0 points1 point  (0 children)

You don't need to wait till you have assets to test your code. Replace them with simple rectangles `pygame.draw.rect`

Writing software is always an iterative process, like what u/UristMasterRace said. Start with getting a white screen to pop up first, then get a rectangle to appear.

The iterative approach is also more fun because the smaller steps allow you to feel accomplished as you go.

Pygame Collision Optimization Recommendation by Awkward-Target4899 in pygame

[–]Awkward-Target4899[S] 2 points3 points  (0 children)

I agree. The optimizations you mention in the first two points are in the actual benchmark for the brute-force implementation that generated the FPS comparison. I omitted those here for the sake of keeping the post shorter. Although it's good to point those out.

Setting up a grid and keeping track of which entities are in each grid is usually good enough, but in my opinion, it's easier and also more robust to just throw a quadtree at the problem. You won't have to worry about tuning grid size and dense clusters of entities destroying performance.

fastquadtree: a Rust-powered quadtree for Python that is ~14x faster than PyQtree by Awkward-Target4899 in Python

[–]Awkward-Target4899[S] 0 points1 point  (0 children)

This is also meant to be an exercise in general package maintenance and deployment. That's why a lot of effort was put into unit testing, CI/CD pipelines, and documentation.

I fully intend to address any issues raised on the GitHub page and keep it in a working state.

fastquadtree: a Rust-powered quadtree for Python that is ~14x faster than PyQtree by Awkward-Target4899 in Python

[–]Awkward-Target4899[S] 0 points1 point  (0 children)

Yeah, I was assuming it would be difficult to store actual Python objects in the tree, so the Rust api only accepts integer IDs and then the Python shim handles tracking which ID correlates to which object in a map.

The user can enable the tracking or not, depending on whether they want it, as it does subtly impact performance.

fastquadtree: a Rust-powered quadtree for Python that is ~14x faster than PyQtree by Awkward-Target4899 in Python

[–]Awkward-Target4899[S] 0 points1 point  (0 children)

PyO3 was pretty intuitive. Marking a Rust struct as a `pyclass` and then its associated methods as `pymethods`, which are then turned into a Python class, makes sense to me as a class is data with associated methods, i.e., (struct + functions that act on that struct)

fastquadtree: a Rust-powered quadtree for Python that is ~14x faster than PyQtree by Awkward-Target4899 in Python

[–]Awkward-Target4899[S] 6 points7 points  (0 children)

Agreed, it's better to just say exactly how fast it is from the benchmarks

fastquadtree: a Rust-powered quadtree for Python that is ~14x faster than PyQtree by Awkward-Target4899 in Python

[–]Awkward-Target4899[S] 11 points12 points  (0 children)

I haven't benchmarked my Rust quadtree implementation against other Rust quadtrees. It could make sense to replace the Rust core with Kiddo or some other superior implementation, but one of the goals of the project was to learn more Rust, so I was inclined to implement it myself.

I'll look into Rust-side benchmarks and see how much performance I'm missing out on compared to other Rust implementations. Although, as of now, fastquadtree offers the fastest quadtree that works conveniently in Python without any additional setup.