Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 9894

Python is a dynamically and strongly typed programming language that encourages readability.

5 votes

Handling random with unique chance in Python

Assuming the list of monsters and their rarities doesn't change during gameplay too often, you can precompute the totalchance variable and also a list of the partial sums, that is, the sums of the rar …
Nathan Reed's user avatar
  • 33.7k
2 votes
Accepted

Get a random vector

You can generate a random vector with a given fixed speed by choosing a random point on the unit circle, then scaling by the desired speed: angle = random.uniform(0, 2.0*math.pi) vector = [speed * ma …
Nathan Reed's user avatar
  • 33.7k
8 votes

What is a good algorithm for fractal-based procedural city layout?

There's this GDC talk on procedural building generation from a couple of years ago. It's for creating individual buildings based on a set of templates, but not for creating whole cities (laying out s …
Nathan Reed's user avatar
  • 33.7k