-
Notifications
You must be signed in to change notification settings - Fork 52
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
structure grid expansion #1826
Merged
Merged
structure grid expansion #1826
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kostmo
force-pushed
the
feature/structure-grid-expansion
branch
3 times, most recently
from
May 10, 2024 08:25
336c132
to
8cd5634
Compare
mergify bot
pushed a commit
that referenced
this pull request
May 10, 2024
This does two main things to simplify the review of #1826: * Add the `truncate` option to structure placement. By default it shall be `true` to maintain the status quo behavior * Extract a `validatePlacement` function to improve readability
kostmo
force-pushed
the
feature/structure-grid-expansion
branch
5 times, most recently
from
May 11, 2024 00:59
f7ae3b6
to
66c9faa
Compare
kostmo
force-pushed
the
feature/structure-grid-expansion
branch
2 times, most recently
from
May 12, 2024 03:32
f227516
to
d7ec853
Compare
kostmo
force-pushed
the
feature/structure-grid-expansion
branch
from
May 12, 2024 03:43
d7ec853
to
4632462
Compare
@kostmo Starting to take a look at this; can you fill in the description with an elevator-pitch version of what this PR is doing? |
byorgey
reviewed
May 13, 2024
src/swarm-scenario/Swarm/Game/Scenario/Topography/Structure/Overlay.hs
Outdated
Show resolved
Hide resolved
kostmo
force-pushed
the
feature/structure-grid-expansion
branch
from
May 25, 2024 23:01
4632462
to
9649d74
Compare
byorgey
approved these changes
May 26, 2024
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.
Looks great!
mergify bot
pushed a commit
that referenced
this pull request
Jun 27, 2024
In the implementation of #1826, I decided to preserve the old truncating behavior as the default. But after some consideration, there's no real use case for the old behavior, so let's take it out to simplify the code.
This was referenced Sep 15, 2024
mergify bot
pushed a commit
that referenced
this pull request
Sep 16, 2024
…dinates (#2127) Fixes a bug from #1826. ## Background Structure definitions can be nested, in that a structure can reference and place multiple "substructures", each with an "offset", to compose something more complicated. Each placement onto a particular "base" structure is a "child". Multiple child placements atop the same base structure are "siblings". It so happened that if a child placement with a "negative" horizontal offset preceded a sibling with non-negative offset, this would result in miscalculated placements. This had to do with the fact that "growing" the "base grid" in the negative direction means that the original "origin" (that the "offset" of subsequent placements are made with respect to) of the base grid must be shifted further right (to somewhere in the middle of the grid), rather than lying on the left edge. Conversely, if negative offsets occurred as later siblings, then the placement would be correct (the bug would not be triggered). ## The fix This fix ensures that sibling placements can be re-ordered without affecting the end result. There were actually two bugs: * changes to the origin offset were not propagated between sibling placements (i.e. across iterations of [`foldlM`](https://github.com/swarm-game/swarm/blob/ab13170f4c3d47e6fb3e44d3ec1c86aa91451575/src/swarm-topography/Swarm/Game/Scenario/Topography/Structure/Assembly.hs#L84)) * the math for computing combined offset (`originDelta` in the `Semigroup` instance of `PositionedGrid`) was incorrect. ## Other changes Also implements a `--refresh` option to the `standalone-topography` test for updating image-based test fixtures. ## Bug repro ``` scripts/play.sh -i data/scenarios/Testing/1780-structure-merge-expansion/sequential-placement.yaml ``` | Before (incorrect) | After (correct) | | --- | --- | | ![broken](https://github.com/user-attachments/assets/47952f83-b877-4fc2-b6b7-8ceb495e8ba0)| ![fixed](https://github.com/user-attachments/assets/907d8872-bff0-4c41-b1c4-8561bf206b4a) | # Refreshing test images ``` scripts/test/run-tests.sh standalone-topography --test-options '--refresh' ```
mergify bot
pushed a commit
that referenced
this pull request
Sep 23, 2024
Builds upon #2127 to fix the remaining issues with #1826. If a structure incorporates sub-placements entailing northwesterly offsets, its "coordinate origin" will be shifted relative to the top-left cell in the grid. This updated coordinate origin should be propagated to parent structures for use when placing it. This includes placement of the main "area" onto the toplevel world map. This is essential when composing a large scene that needs to line up with features generated by the DSL. Another bug fixed in this PR involved incorrect "area" computation within sibling placements when both a "northward" and "westward" offset were used; existing tests only covered each of these directions separately. ## Changes in this PR * Refactoring for readability * Improved naming * Fixed typo `padSouthwest` -> `padNorthwest` * Export some functions for unit tests * Utilize propagated coordinate offset in `WorldDescription` ## Testing ### Unit tests ``` scripts/test/run-tests.sh swarm-unit --test-options '--pattern "Overlay"' ``` ### Scenarios ``` scripts/play.sh -i data/scenarios/Testing/1780-structure-merge-expansion/coordinate-offset-propagation.yaml --hide-goal ``` | Before | After | | --- | --- | | ![Screenshot from 2024-09-22 19-54-13](https://github.com/user-attachments/assets/b7d79232-7435-4cdf-a586-4df4df5cd978) | ![Screenshot from 2024-09-22 19-50-10](https://github.com/user-attachments/assets/4c6a248c-153c-4461-9012-526f59d1ce35) | ``` scripts/play.sh -i data/scenarios/Testing/1780-structure-merge-expansion/simultaneous-north-and-west-offset.yaml --hide-goal ``` | Before | After | | --- | --- | | ![Screenshot from 2024-09-22 19-53-50](https://github.com/user-attachments/assets/2049c905-c283-4c43-adc2-f355ea055ada) | ![Screenshot from 2024-09-22 19-53-07](https://github.com/user-attachments/assets/d120d084-31c6-4a67-855d-e08043a93891) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #1780.
This change allows "child" structures to be placed outside of the bounds of their "parent" map. Until now, any child structures that exceed the bounds of their parent were simply truncated.
Demo