-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Add maze order (1 or 0) corresponding to the maze density #101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order is a bit abstract and maybe having an enum for supported values instead of a u8
is we can't support more than 2 values could be good.
Or if you feel like it will be possible to extend the order to any u8
then makes sense to keep it like so. 👍
let (x, y) = (position % width, position / width); | ||
match direction { | ||
Direction::North => (y <= height - 3) | ||
Direction::North => (y < height - 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the -2
here looks a bit magic, perhaps having this in a constant that have a more descriptive name could help the understanding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for some offset used in this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually 3 was weird but size - 2 is actually the range of the indexes (from 0 to size - 1) substracting 1 to ensure we didnt reached the edge yet.
It could be rewrite such as:
let last_index = height - 1;
let one_before_last_index = last_index - 1;
match direction {
Direction::North => (y < one_before_last_index)
...
}
But maybe I could just add some comments to explain it, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment would be fine yeah, was trying to grasp the idea of those indexes. Thanks!
Co-authored-by: notV4l <[email protected]>
Introduced changes
Add a new argument for maze and corridor generations, the density order.
The order of the maze, it must be 0 or 1, the higher the order the less dense the maze will be.
Note: I didnt managed higher orders since the definition is ambiguous and the scaling could be a problem.
Here an example:
Order 0 (current implementation)
Order 1 (new implementation, with the same seed)
Basically, order 1 disallow these patterns (having 2 floors connected diagonally):