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

Queryable tags for entities #1631

Closed
kostmo opened this issue Nov 16, 2023 · 0 comments · Fixed by #1635
Closed

Queryable tags for entities #1631

kostmo opened this issue Nov 16, 2023 · 0 comments · Fixed by #1635
Assignees
Labels
G-Design An issue having to do with game design. L-Commands Built-in commands (e.g. move, try, if, ...) in the Swarm language. Z-Feature A new feature to be added to the game.

Comments

@kostmo
Copy link
Member

kostmo commented Nov 16, 2023

I would like to categorize entities by custom tags, e.g.:

  • In Greenhouse #1155, I would like to distinguish between entities that are "flowers" vs. "mushrooms"
  • In fishing scenario #1628, I would like to distinguish between entities that are either "junk" or "useful", with perhaps subcategories of "edible" and "inedible".
  • It may be useful to group together multiple entities as different "states" of the same thing, such as an "empty cask" and "water-filled cask", such as in beekeeping scenario #1599.

The implementation should be straightforward; just add a new field in the YAML description of an entity that accepts a list of strings (the "tags").
A new command hasTag : text -> text -> cmd bool that answers whether an entity has a given tag. This would be primarily intended for system robot use, though there is probably opportunity for creative uses as a scenario mechanic for players.

@kostmo kostmo added Z-Feature A new feature to be added to the game. G-Design An issue having to do with game design. L-Commands Built-in commands (e.g. move, try, if, ...) in the Swarm language. labels Nov 16, 2023
@kostmo kostmo self-assigned this Nov 19, 2023
@mergify mergify bot closed this as completed in #1635 Nov 20, 2023
mergify bot pushed a commit that referenced this issue Nov 20, 2023
Closes #1631

## Design

* Entities have a new property: a `Set` of textual tags.
* Two new commands are introduced:
    * `HasTag` checks whether a single entity has a given tag
    * `TagMembers` allows cycling through all members with a given tag
* `TagMembers` may be considered more powerful than `HasTag`, so has its own separate capability (`CTagmembers`).
* A map is computed at scenario initialization to facilitate `TagMembers` lookups.
* Tag names are highlighted in yellow in markdown.

## Demo

    scripts/play.sh -i scenarios/Testing/1631-tags.yaml --autoplay

## Other changes

* Incidentally, changed `knownEntities` from a list to a `Set` so that `Set.member` can be used instead of `elem`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
G-Design An issue having to do with game design. L-Commands Built-in commands (e.g. move, try, if, ...) in the Swarm language. Z-Feature A new feature to be added to the game.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant