Repository navigation
Add diagonal megatree branching - #556
Numbers633 wants to merge 2 commits into
Conversation
| use super::{VoxelCoords, index, line::LineSegment, voxel_center}; | ||
|
|
||
| /// Branch radius, in absolute hyperbolic distance units. | ||
| const BRANCH_RADIUS: f32 = 0.2; |
There was a problem hiding this comment.
In my opinion, the new diagonal branching makes trees too thick at this branch radius. May be worth reducing this value in the PR.
There was a problem hiding this comment.
I appreciate your desire to add additional functionality to the megatree, but I don't necessarily think that adding diagonal branches like this is important enough to add this level of complexity to megatrees, since it can make the code unmaintainable.
Based on how quickly you produced such a large PR, I have reason to suspect that you used an LLM to create it. I don't really have enough time to review LLM-generated code if the author did not spend enough effort reviewing it first. (I might be wrong about this, though, as you might have just been spending time staging these changes while waiting for other PR to be merged.)
If you're sure this level of complexity in a single PR is necessary, then I strongly urge you to write the code by hand. The process of writing the code can help you get a better sense of whether the code you're writing is maintainable. (If you did handwrite it already, then my recommendation would be to use one git branch to prototype ideas and then re-implement the features in a more maintainable way in another git branch.)
Please note that the direction of the Hypermine project isn't fully decided. I don't really see a strong need for the distribution of megatrees on horohills to match their distribution at the ground plane, so if getting a "reasonable distribution" requires a PR of this level of complexity, then the question would be whether such a slight improvement is worth this level of complexity.
I expect that long-term, we would likely want megastructures to exist that are node-aligned and have paths that extend directly to edge-adjacent and diagonally-adjacent nodes, so logic like this does seem like it could be useful.
There was a problem hiding this comment.
I understand the concern about the amount of complexity introduced here. I used Codex to help implement the diagonal propagation system, and while I've been reviewing the design and testing its behavior, I agree that the implementation has become quite large for a single PR.
My main motivation for diagonal propagation is that it could also support other node-aligned megastructures, rather than just improving megatree distribution in horohills.
I think it would make sense to preserve this branch as a prototype and investigate whether the propagation mechanism can be simplified or separated into smaller, independently reviewable changes.
I'll also reconsider the graph tests you mentioned, since they appear to duplicate an existing invariant.
Would you consider a smaller, reusable diagonal-propagation mechanism worthwhile independently of megatrees, or would you prefer to defer this feature entirely for now?
There was a problem hiding this comment.
That is understandable. While I have personal preferences for using LLMs extremely sparingly (especially in hobby projects), I can't necessarily impose that for this project, especially since I'm not the repo owner. Also, as the AI-mania (hopefully) eventually settles down, and where LLMs have their proper place becomes clearer and less controversial, I wouldn't want Hypermine's development pace to be hampered by arbitrary restrictions. I'm still trying to sort out my own position on all this.
As for your main motivation, that is good to know. I was afraid that the main motivation was to improve the distribution of megatrees in horohills, in which case, it just didn't seem worth it. It does seem like this kind of propagation, or something like it, would be worthwhile. Players build things aligned to chunks, so more frameworks for this seem useful.
Making this a prototype seems worthwhile. I also agree that using a megatree as a guinea pig for this feature is a good idea.
My recommendation is that if you do decide to keep using Codex here, you should review your own changes with the same level of scrutiny that I displayed when reviewing your PRs (and keep the PR as a draft until you have done that). I do highly suggest that you come up with the high-level algorithm for this yourself, though (including the contents of all the structs). I'd be happy to discuss ideas on how to implement this.
There was a problem hiding this comment.
I'll go ahead and convert this PR to a draft until I have simplified the implementation and removed the unnecessary tests.
EDIT: I've also privately experimented with supporting multiple ground planes, but haven't published that work because I didn't trust the implementation enough and wasn't sure if Hypermine should have that feature.
I think keeping experimental implementations separate from production-ready code is a good approach. I'll do something similar with diagonal propagation, using the current implementation as a prototype and working toward a simpler version.
| } | ||
|
|
||
| #[test] | ||
| fn vertex_diagonal_has_all_three_carrier_parents_before_state_generation() { |
There was a problem hiding this comment.
I don't think these tests are needed. It should already be common knowledge in the code-base that if a NodeState exists, so do all of its ancestor NodeStates.
There was a problem hiding this comment.
About 1,000 lines are in the tests, while the actual implementation is about 550 lines in total, including the existing megatree code.
I can go through the newly added tests and remove the unnecessary ones if you want.
I understand that the implementation itself is still fairly large, so I'll also investigate whether the propagation logic can be simplified.
Adds diagonal megatree propagation through edge- and vertex-adjacent graph nodes, in addition to the existing face-connected propagation.
Diagonal branches use carrier signals to propagate through intermediate graph nodes. Signals are sorted and deduplicated so that different crossing orders reach the same destination without generating duplicate tree nodes. Intermediate carrier nodes do not consume the tree's growth budget.
Outgoing directions are selected using bounding-plane relationships derived from the incoming tree parents, preserving the intended 3D propagation behavior.
This is a prerequisite for properly seeding megatrees in horohills, since that requires diagonal propagation to maintain a reasonable distribution of megatrees.
The implementation also adds tests for edge and vertex convergence, deterministic propagation, finite-growth behavior, and isotropy.
Includes a small numerical-stability fix to

LineSegment::distance_to().