sbrl / Minetest-WorldEditAdditions

Extra tools and commands to extend WorldEdit for Minetest
https://worldeditadditions.mooncarrot.space/
Mozilla Public License 2.0
16 stars 3 forks source link

maze config width of wall and path #6

Closed Bastrabun closed 4 years ago

Bastrabun commented 4 years ago

Could you add a parameter to separately let us configure the width/thickness of walls and pathways?

Like when we want to have a maze with walls 3 blocks thick and a pathway 2 blocks wide?

sbrl commented 4 years ago

Heya! Thanks for the request, @Bastrabun! Indeed, I've been thinking about this already. I've tought of 2 options so far:

  1. Implement a wall / corridor width / height setting (hard)
  2. Implement a generic //scale <scale_factor> <axis_1> [<axis_2> [<axis_3>]] (much easier)

Which do you think is the best option?

Personally, I think option 2 is the best, because it will work on not only both kinds of mazes, but other things too. Option 1 would also be complicated to specify in a command - what would the new //maze and //maze3d even look like with all those properties?

Of course, WorldEdit Additions is about adding lots of stuff that might not fit in regular worldedit. However, I'd like to try and do this in a composable manner as possible. I don't know if you've heard of the _Unix Philosophy_, but that's the kinda the thing I'm aiming for. It's basically this:

Each command should do 1 thing, and 1 thing well.

By following this philosophy, I hope to develop a set of extension commands that are useful on their own, but exponentially more powerful when combined together :smiley:

Bastrabun commented 4 years ago

I'd prefer 1st option, because you could set walls' and paths' width separately. On 2nd option you can only choose to have pathway and walls of the same width, right? Regarding the parameters, one would haave to specify only wall width and pathway width, since height is determined by the WE edges.

But still, there is also the optional seed, which is also an integer. You'd have to start working with something like //maze default:stone Since all of them are optional but integer, one would need some sort of way to know whether the parameter is meant to be the width oft the walls or the seed?

I did not look towards the 3d maze though and I agree, the paramters should be somewhat similar.

I don't see how this is accomplished using the given WE commands and it seems to be maze-specific, that's why I thought a parameter solution would be nice.

In the worldedit basic package, there is already a scale command called stretch, which does what you call scale. It is not maze-specific and useful under many other circumstances. I already made experiments with making a maze and then stretching it. It does work, within the abovementioned constraints.

sbrl commented 4 years ago

Ah, I see! Thanks for the explanation @Bastrabun. And that's interesting to know about //stretch - I took a look the other day and couldn't find it lol.

Thinking about it, you're right. Let's implement option 1. What about this?


//maze <node_name> <seed> <wall_width>x<wall_height> <path_width>x<path_height>
//maze3d <node_name> <seed> <wall_width>x<wall_height>x<wall_depth> <path_width>x<path_height>x<path _depth>
sbrl commented 4 years ago

Hrm. Looking into it further, this is actually pretty complicated. It's probably going to look more like this:

//maze <node_name> <seed> <path_length> <path_width>

...where the length is how far it will jump at once (the grid size), and the width is the width of the path.

I've got an initial implementation of the core algorithm, but it has a few nasty bugs in it that I'm still scratching my head over.

I haven't even started to consider the 3d version yet :P

sbrl commented 4 years ago

Fixed it! Here's an example output from the core generator:

###############################################################################
#                             ###             ###     ###     ###             #
#                             ###             ###     ###     ###             #
#                             ###             ###     ###     ###             #
#                             ###             ###     ###     ###             #
#                             ###             ###     ###     ###             #
#     ###################     ###########     ###     ###     ###########     #
#     ###################     ###########     ###     ###     ###########     #
#     ###################     ###########     ###     ###     ###########     #
#             ###     ###                             ###                     #
#             ###     ###                             ###                     #
#             ###     ###                             ###                     #
#             ###     ###                             ###                     #
#             ###     ###                             ###                     #
#     ###     ###     ###     ###################     ###########     #########
#     ###     ###     ###     ###################     ###########     #########
#     ###     ###     ###     ###################     ###########     #########
#     ###             ###     ###                                             #
#     ###             ###     ###                                             #
#     ###             ###     ###                                             #
#     ###             ###     ###                                             #
#     ###             ###     ###                                             #
###############################################################################

....now to implement the update to the minetest command.

Note that the path width must always be at least 1 less than the path length.

Currently crashes may be observed too if the size of the maze isn't a multiple of the right value for the given path width & length chosen - rounding down is on my todo list.

sbrl commented 4 years ago

screenshot_20200503_161739

Before we close this issue though, we need to tackle the 3d maze generator......

.....then I'll make a proper release.

For now, you can update by doing git pull if you cloned this repo with git.

sbrl commented 4 years ago

Ok, I think we have //maze3d upgraded too!

The documentation has been upgraded too. Let me know if you find any issues or (gasp!) crashes, @Bastrabun :smiley_cat:

If you do find an issue, I'll need a seed to reproduce it.

sbrl commented 4 years ago

I'm closing this now, but feel free to open a new issue if you encounter any issues.

Bastrabun commented 4 years ago

Awesome! I'll test this tonight and provide feedback :)

sbrl commented 4 years ago

Thanks :heart: