I think python camp ended up being pretty educational, even if we didn’t meet all of our goals. The curses version of Leo’s MineCraft-In-Python (aka. PythonCraft) actually ended up pretty well, and we did some actual pretty interesting algorithm coding, and even a little computational complexity. Unfortunately, we wasted pretty much a whole day trying to translate the game into pygame, which would have provided way better graphics. But that ended up being beyond Leo’s capabilities, and although I could have done it for him, that would have defeated the purpose, so we just fell back to the curses version.
Previous version (Alpha 1.3) had the basic world and player, and some pretty good terrain generation, and at some point we added survival mode as well. 1.4 introduced water and npcs (mobs, in Minecraft parlance). Each of these actually involved interesting new algorithm design. In the case of water, the blocks had to “flow”, so that would fill space “gravitationally”. How to do this is actually non-trivial, but after lots of experimenting we more-or-less got it to work. Here’s an image of how water ends up sort of filling a valley. The waters are = signs, and the player is the *. All the water blocks in the valley were originally dropped in the same column, but moved to fill the valley. Notice that there’s room for improvement in the algorithm as it made a sort of pyramid:
Mobs were also very interesting. Leo invented a nice mob placement algorithm so that the would end up mostly in caves (although sometimes on the surface as well), and then we did a nice mob movement algorithm that would make them move toward the player. Of course, there were failures along the way to this as well. Some shots of the results of various “approximations” (aka. major bugs! :-):
But the thing did work out in the end (here the player is being chased through the air by 2 zombies and a creeper — yeah, they can fly … minor bug!):
As before, all the code is in the github repo.
2019-10-11: After much thought, we improved the water flow algorithm in a rather simple way, which ended up greatly improving it. Now water not only tries to flow downward, which is what was causing the pyramids, but also randomly left- or rightward, so that it’s always in a sort of random walk, eventually finding its lowest possible level. As you can see, this has greatly improved things; the water now seeks the lowest space and spreads out, filling space at the bottom, just as normal water does:
This still lacks a bit of reality, in that it won’t hydraulically flow upward through a hole, as there’s no actual water pressure. But at least it doesn’t create weird waster pyramids!