Closed Rapen765 closed 1 month ago
The rand_in_circle function defined in math.py makes more points near the circles's center.
Modify the code code calculating radius r:
# random radius r = radius * random.random()
to this:
# random radius r = radius * math.sqrt(random.random())
The square root of a random number ensures the correct density ( based on https://stackoverflow.com/a/50746409 ).
This change would improve the distribution of points for games that rely on this function, such as when spawning entities within a circle. A more uniform spread can enhance gameplay balance by avoiding the clustering of entities near the center.
Enhancement request:
The rand_in_circle function defined in math.py makes more points near the circles's center.
What should be added/changed?
Modify the code code calculating radius r:
to this:
The square root of a random number ensures the correct density ( based on https://stackoverflow.com/a/50746409 ).
What would it help with?
This change would improve the distribution of points for games that rely on this function, such as when spawning entities within a circle. A more uniform spread can enhance gameplay balance by avoiding the clustering of entities near the center.