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

robot background passthrough #1672

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kostmo
Copy link
Member

@kostmo kostmo commented Dec 4, 2023

Closes #1662

Demo

Using:

scripts/play.sh -i creative --seed 2 --autoplay
Before After
image Screenshot from 2023-12-03 23-37-18

Also:

scripts/play.sh -i data/scenarios/Testing/1034-custom-attributes.yaml --autoplay

image

@kostmo kostmo changed the base branch from main to feature/terrain-as-background December 4, 2023 07:29
@kostmo kostmo force-pushed the feature/terrain-as-background branch from 9af3d35 to 6402249 Compare December 9, 2023 01:59
@kostmo kostmo force-pushed the feature/robot-background-passthrough branch from f74bace to fcd9a75 Compare December 9, 2023 03:36
mergify bot pushed a commit that referenced this pull request Dec 12, 2023
Towards #1662

Prerequisite for #1672

To allow a robot-occupied cell to take on the underlying terrain color as the background color of its cell, the terrain color must be representable strictly as a "background".  However, currently, the `dirt`, `stone`, and `grass` terrains are represented by a half-shaded **foreground** glyph upon `black` background.

Currently the ["Medium Shade" unicode character](https://www.compart.com/en/unicode/U+2592) (`▒`) is used  to "blend" a somewhat bright color with a black background, resulting in a moderately dark color in the terminal for `dirt`, `stone`, and `grass`.  However, these same dark colors are not reproducible in the 240-color scheme without this foreground+background blending trick; the closest approximations as a background-only or foreground-only color come out quite a bit lighter.

## Visual comparison

Using:

    scripts/play.sh -i creative --seed 2 --autoplay

| Before | After |
| --- | --- |
| ![Screenshot from 2023-12-03 23-33-15](https://github.com/swarm-game/swarm/assets/261693/edeeaeac-13e0-4641-9822-773fdb20f1d4) | ![Screenshot from 2023-12-03 23-32-36](https://github.com/swarm-game/swarm/assets/261693/ae5a5b5d-aa69-4580-b7e1-85eec21b4aeb) |

## Possible approaches

So, we need to decide whether to:
1. Accept the new lighter colors
2. Choose new, alternative terrain colors that may be darker given the 240-color palette
3. Abandon support for 240 colors and assume "full" color terminals
4. Abandon efforts to passthrough terrain color as background of robot cells
@kostmo kostmo force-pushed the feature/robot-background-passthrough branch from fcd9a75 to 673eeb9 Compare December 17, 2023 00:20
@kostmo kostmo changed the base branch from feature/terrain-as-background to main December 17, 2023 00:20
@kostmo kostmo force-pushed the feature/robot-background-passthrough branch from 673eeb9 to 44af2f6 Compare December 17, 2023 23:26
@kostmo kostmo changed the base branch from main to refactor/grid-and-colors December 17, 2023 23:27
mergify bot pushed a commit that referenced this pull request Dec 18, 2023
This is in preparation for both #1672 and #1650.

* Added some utility methods for color flattening
* The `Grid` type has a new home in `Area.hs` and now derives more instances
* `getTerrainEntityColor` is extracted from the `getDisplayColor` function
* Add a favicon to silence browser warnings
@kostmo kostmo changed the base branch from refactor/grid-and-colors to main December 19, 2023 01:01
@kostmo kostmo force-pushed the feature/robot-background-passthrough branch 5 times, most recently from c83db52 to 2bb17a2 Compare December 19, 2023 07:31
@kostmo kostmo force-pushed the feature/robot-background-passthrough branch from 2bb17a2 to 07fcc24 Compare December 19, 2023 07:38
@kostmo kostmo marked this pull request as ready for review December 19, 2023 07:38
@kostmo kostmo requested a review from byorgey December 19, 2023 07:38
Copy link
Member

@byorgey byorgey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why, but with this PR it seems like all robots now look like Ω. (Edited to add: just kidding, it seems like that is already the case on main. I guess we did not test some previous PR enough... filed #1693 to track this issue.)

What is the advantage of doing this only for robots (as opposed to for entities as well)? It seems like we needed to add various special cases (displayObscured, etc.) to get it to work only for robots, rather than just generically changing the way Displays combine.

mergify bot pushed a commit that referenced this pull request Jan 5, 2024
YAML syntax in this file was actually fixed in #1672, which is not yet merged.
Cherry-pick that fix as well as enhancements to the scenario.
Towards #845.

Aside from fixing the syntax for #1706 (comment), this provides a good "before" example to showcase the fix in #1672.

    scripts/run-tests.sh --test-arguments '--pattern "1034-custom-attributes"'

and

    scripts/play.sh -i data/scenarios/Testing/1034-custom-attributes.yaml --autoplay --speed 1

![Screenshot from 2024-01-04 16-46-53](https://github.com/swarm-game/swarm/assets/261693/5e5a4435-1a36-4f59-bd6f-639c065baf2d)
@kostmo kostmo marked this pull request as draft January 24, 2024 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Robots and entities should take on underlying cell background unless overridden
2 participants