Skip to content
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

topography sublibrary #1836

Merged
merged 2 commits into from
Jun 2, 2024
Merged

topography sublibrary #1836

merged 2 commits into from
Jun 2, 2024

Conversation

kostmo
Copy link
Member

@kostmo kostmo commented May 11, 2024

Towards #1043.

The eventual goal of this sublibrary split is to have a self contained library that can compose 2D grids of arbitrary content (perhaps colored pixels, or boolean values). This could be useful outside of the swarm game.

I would also like to write unit tests for the structure recognizer that are independent of the Entity type.

Major Changes

Direction module

  • Moved Swarm.Language.Syntax.Direction to swarm-util, since both swarm-lang and swarm-topology depend on it, but not on each other.
  • Removed the re-export of direction things from Swarm.Language.Syntax

Structure module

The Swarm.Game.Scenario.Topography.Structure module has been split into two:

  • Swarm.Game.Scenario.Topography.Structure
  • Swarm.Game.Scenario.Topography.Structure.Type

The former retains the YAML parsing logic. The latter is agnostic of Entity type and the palette.
At some future point, I might want to move the YAML parsing to this sublibrary while still retaining independence of Entity type.

Structure recognizer

The structure recognizer is independent of the content of Cells (i.e. it does not need to know what an Entity is), except:

  1. during initialization
  2. when retrieving the original cell content after recognition

Type parameters for three kinds of data have been added to the recognizer:

  1. Cell/PCell
  2. Entity
  3. EntityName

Eventually it may be possible to eliminate one or two of these type parameters, with some refactoring.

@kostmo kostmo mentioned this pull request May 12, 2024
@kostmo kostmo force-pushed the feature/structure-grid-expansion branch 2 times, most recently from d7ec853 to 4632462 Compare May 12, 2024 03:43
@kostmo kostmo changed the title topography sublibrary [WIP] topography sublibrary May 12, 2024
@kostmo kostmo force-pushed the feature/structure-grid-expansion branch from 4632462 to 9649d74 Compare May 25, 2024 23:01
@kostmo kostmo changed the base branch from feature/structure-grid-expansion to main June 1, 2024 19:17
@kostmo kostmo force-pushed the refactor/topography-sublibrary branch from 0243f3b to 6073826 Compare June 1, 2024 19:23
@kostmo kostmo force-pushed the refactor/topography-sublibrary branch 9 times, most recently from 2d21acd to db04995 Compare June 1, 2024 23:09
@kostmo kostmo added the Z-Refactoring This issue is about restructuring the code without changing the behaviour to improve code quality. label Jun 2, 2024
@kostmo kostmo force-pushed the refactor/topography-sublibrary branch from db04995 to 37b8842 Compare June 2, 2024 11:22
@kostmo kostmo marked this pull request as ready for review June 2, 2024 11:22
@kostmo kostmo requested a review from byorgey June 2, 2024 11:22
@kostmo kostmo changed the title [WIP] topography sublibrary topography sublibrary Jun 2, 2024
@kostmo kostmo force-pushed the refactor/topography-sublibrary branch from 37b8842 to 90a6360 Compare June 2, 2024 20:37
@kostmo kostmo added the merge me Trigger the merge process of the Pull request. label Jun 2, 2024
@mergify mergify bot merged commit ca4a2b8 into main Jun 2, 2024
11 checks passed
@mergify mergify bot deleted the refactor/topography-sublibrary branch June 2, 2024 20:54
@kostmo kostmo added the CHANGELOG Once merged, this PR should be highlighted in the changelog for the next release. label Jul 7, 2024
@kostmo kostmo removed the CHANGELOG Once merged, this PR should be highlighted in the changelog for the next release. label Jul 7, 2024
mergify bot pushed a commit that referenced this pull request Jul 14, 2024
Builds upon #1836.

This PR moves functions that are independent of `Entity` type into a new module within `swarm-topography`, alongside most of the other structure recognizer code.  Notably, this allows removal of the `AhoCorasick` dependency from the `swarm-scenario` sublibrary.
mergify bot pushed a commit that referenced this pull request Aug 12, 2024
Builds upon #1836.

Most importantly in this PR, the `Swarm.Game.Scenario.Topography.Structure.Recognition.Tracking` module is made generic in its `Entity` parameter, and is now able to be moved from the `swarm-engine` sublibrary to the `swarm-topology` sublibrary.

I've also introduced an intermediate `RecognitionState` record inside `StructureRecognizer` to distinguish between the stateful and read-only elements.

The `AhoCorasick` dependency is now reduced to only one sublibrary.
mergify bot pushed a commit that referenced this pull request Aug 13, 2024
Builds upon #1836.

Ultimately, this allows us to move the final remaining module, `Precompute.hs`, into the `swarm-topology` sublibrary to live alongside the rest of the structure recognizer code.

## Also in this PR
* improve logging details for shape recognition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request. Z-Refactoring This issue is about restructuring the code without changing the behaviour to improve code quality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants