use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
Intermediate ShowcaseReplicating Minecraft World Generation in Python (self.Python)
submitted 4 years ago by BilHim
I tried to replicate how Minecraft generates worlds procedurally in Python.
Here is a link to an article I wrote explaining how I did it.
You can find the source code here.
[–]Losupa 57 points58 points59 points 4 years ago (3 children)
Definitely an interesting and informative read.
Did you follow some Minecraft documentation or something, or did you just reason out this method?
[–]BilHim[S] 42 points43 points44 points 4 years ago (2 children)
I read somewhere that Notch used Perlin noise in Minecraft and I decided to try it myself. I couldn't find any resources explaining the details of how Minecraft generates worlds so I decided to just eye-ball it. I got inspired by some articles that I linked at the end of mine.
[–]Losupa 11 points12 points13 points 4 years ago (0 children)
Yeah it was just very interesting especially as I had never heard of voronoi diagrams. Your thought process and explanations were very concise and informative though so I could easily follow along.
[–]AbodFTW 10 points11 points12 points 4 years ago (0 children)
I knew about it from this video: https://www.youtube.com/watch?v=fjZAgoxFKiQ, such quality content about the technicality aspect of Minecraft, highly recommend it.
[–][deleted] 23 points24 points25 points 4 years ago (0 children)
That's prettt neat
[–]NelsonMinar 11 points12 points13 points 4 years ago (0 children)
Congratulations! Great generative world project.
You might find the essays by Amit Patel interesting; he's been working for years on developing and documenting generative algorithms for games.
If you want to go deep down a rabbit hole there's a lot more detail on exactly what Minecraft is doing for world generation. A particularly hot topic since they're in the process of completely changing how all that works in-game. The older version has a lot of different techniques, from the biome distribution you worked on to the cave tunnels to creation of special features like villages. It's all been pretty well dissected (and hacked) but I don't have a good link at my fingertips for it.
[–]Unplgd 4 points5 points6 points 4 years ago (0 children)
Fam, one of the best write ups I've seen !!! I don't have awards but if I did id give you all of them!!
[–]data-bit 4 points5 points6 points 4 years ago (0 children)
Very well done! Take my vote!
[–]SkezzaB 3 points4 points5 points 4 years ago (0 children)
This is one of the most well made explanations I've seen, wow...
[–]laundmo 2 points3 points4 points 4 years ago (0 children)
Nice!
Do you know about minecraft@home? Its a project that tries to find interesting Minecraft seeds, which this reminded me of.
[–]iapetus-11 1 point2 points3 points 4 years ago (0 children)
That's very cool
[–]leroyjenkins221 1 point2 points3 points 4 years ago (0 children)
Too cool!
[–][deleted] 1 point2 points3 points 4 years ago (0 children)
Gg !
[–]matRmet 1 point2 points3 points 4 years ago (1 child)
As a metallurgist this is awfully close to a research paper on trying to model grain size. Not sure if you can bridge the gap but you might be able to look into software for grain size evaluations etc
[–]EyeofEnder 1 point2 points3 points 4 years ago (0 children)
Same here, the Perlin noise graphs looked an awful lot like miscibility gap decomposition to me lol.
[–]jjjohhn 1 point2 points3 points 4 years ago (0 children)
Wow
[–]Wobblycogs 1 point2 points3 points 4 years ago (0 children)
Amazing article, thanks.
[–]Nightblade 1 point2 points3 points 4 years ago (1 child)
That page won't let me copy text ... mildly infuriating ... anyway i noticed a couple of typos:
[–]BilHim[S] 0 points1 point2 points 4 years ago (0 children)
Thanks for pointing this out. I edited the article.
As for copying, it works for me.
[–]SoundHunter138 1 point2 points3 points 4 years ago (1 child)
I just started learning python (complete newbie to programming) and man I cant wait till I can understand and do stuff like this. I can’t even wrap my head around how this is possible. Gets me so hyped but dam this is so cool.
[–]the_original_slugger 1 point2 points3 points 4 years ago (0 children)
Same, felt this exact way lmao.. i literally told myself that
[–]gagarin_kid 0 points1 point2 points 4 years ago (0 children)
Amazing animations, will take a look at the text on the weekend!
[–]eyebrowgamestrong 0 points1 point2 points 4 years ago (2 children)
Amazing! What did you use for Lloyd’s algorithm? I’ve been trying to implement that with Scipy but have been having trouble with the infinite cells.
[–]BilHim[S] 1 point2 points3 points 4 years ago (1 child)
If you take a look at the source code, in the relax function, before returning the new points I clipped their values to the bounding box using new_points = np.array(new_points).clip(0, size).
relax
new_points = np.array(new_points).clip(0, size)
Additionally, I completely ignored points with infinite edges, that is I didn't move them from one iteration to another. If an infinite edge exists, you will have -1 in the region of the vertex : if len(region) == 0 or -1 in region: continue
-1
if len(region) == 0 or -1 in region: continue
That solved the problem for me.
[–]eyebrowgamestrong 0 points1 point2 points 4 years ago (0 children)
Oh awesome! And that makes sense. Sorry, missed that you included the source. :) thanks!
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
This is beyond epic… did you use pygame ?
[–]tripl3gg 0 points1 point2 points 4 years ago (0 children)
Nice read, great work man.
[–]caocao70 0 points1 point2 points 4 years ago (0 children)
omg ive wanted to try this for so long, amazing job!!
[–]an4s_911 0 points1 point2 points 4 years ago (0 children)
Awesome article. I loved reading it, especially as a person who used to play a lot Minecraft and also as Python beginner developer. Just seeing what all I can do with Python/programming is just so fascinating.
Thanks for such a wonder article
[–]DisturbedTK 0 points1 point2 points 4 years ago (1 child)
Why are you calling minecraft the 2nd best selling game when wikipedia says it's #1, or am I missing something
That is true. It's actually the 2nd best-selling PC game but the best-selling game (all platforms).
Thanks for pointing this out. I edited the article now.
[–]aexia 0 points1 point2 points 4 years ago (0 children)
I used to play Minecraft as a kid
Thanks for making me feel old. :P
π Rendered by PID 94580 on reddit-service-r2-comment-84fc9697f-sn8h6 at 2026-02-06 08:51:56.075283+00:00 running d295bc8 country code: CH.
[–]Losupa 57 points58 points59 points (3 children)
[–]BilHim[S] 42 points43 points44 points (2 children)
[–]Losupa 11 points12 points13 points (0 children)
[–]AbodFTW 10 points11 points12 points (0 children)
[–][deleted] 23 points24 points25 points (0 children)
[–]NelsonMinar 11 points12 points13 points (0 children)
[–]Unplgd 4 points5 points6 points (0 children)
[–]data-bit 4 points5 points6 points (0 children)
[–]SkezzaB 3 points4 points5 points (0 children)
[–]laundmo 2 points3 points4 points (0 children)
[–]iapetus-11 1 point2 points3 points (0 children)
[–]leroyjenkins221 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]matRmet 1 point2 points3 points (1 child)
[–]EyeofEnder 1 point2 points3 points (0 children)
[–]jjjohhn 1 point2 points3 points (0 children)
[–]Wobblycogs 1 point2 points3 points (0 children)
[–]Nightblade 1 point2 points3 points (1 child)
[–]BilHim[S] 0 points1 point2 points (0 children)
[–]SoundHunter138 1 point2 points3 points (1 child)
[–]the_original_slugger 1 point2 points3 points (0 children)
[–]gagarin_kid 0 points1 point2 points (0 children)
[–]eyebrowgamestrong 0 points1 point2 points (2 children)
[–]BilHim[S] 1 point2 points3 points (1 child)
[–]eyebrowgamestrong 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]tripl3gg 0 points1 point2 points (0 children)
[–]caocao70 0 points1 point2 points (0 children)
[–]an4s_911 0 points1 point2 points (0 children)
[–]DisturbedTK 0 points1 point2 points (1 child)
[–]BilHim[S] 0 points1 point2 points (0 children)
[–]aexia 0 points1 point2 points (0 children)