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

background passthrough #2264

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kostmo
Copy link
Member

@kostmo kostmo commented Jan 5, 2025

Closes #1662.

This is an attempt at an alternate approach from #1672.

scripts/play.sh --scenario data/scenarios/Testing/1034-custom-attributes.yaml --autoplay --speed 2 --hide-goal

Comparison

scripts/play.sh -i creative --seed 2
Before After
Screenshot from 2025-01-05 11-40-10 Screenshot from 2025-01-05 11-37-49

Overview

This approach required threading an attribute map (aMap) through a lot of places. Fundamentally, it is because we need to arbitrate between an potentially entity-provided background color and a terrain-provided background color late in the rendering pipeline. We need to preserve whether that background originated from an Entity or a Terrain, so that we can prioritize the Entity.

However, we also want to let the Terrain win if we find that, after looking up the color of the Entity in the attribute map, the Entity has no provided background color.

Asciinema recordings

Before

asciicast

After

asciicast

@kostmo kostmo force-pushed the feature/robot-background-passthrough-alternate branch from 2c29e09 to d4f393d Compare January 5, 2025 07:39
@kostmo kostmo force-pushed the feature/robot-background-passthrough-alternate branch from d4f393d to ce1a4e6 Compare January 5, 2025 07:53
@kostmo kostmo changed the title [Experimental] Alternate approach to background passthrough Alternate approach to background passthrough Jan 5, 2025
@kostmo kostmo force-pushed the feature/robot-background-passthrough-alternate branch 3 times, most recently from 8021d76 to c37f6f6 Compare January 5, 2025 19:39
@byorgey
Copy link
Member

byorgey commented Jan 5, 2025

I can't yet put my finger on exactly why, but this seems unnecessarily complicated. It may be due to the fact that there is something inelegant about Display and it needs some refactoring. I will try to give it some thought.

@kostmo kostmo force-pushed the feature/robot-background-passthrough-alternate branch from c37f6f6 to ff2086b Compare January 5, 2025 19:49
@kostmo
Copy link
Member Author

kostmo commented Jan 5, 2025

I can't yet put my finger on exactly why, but this seems unnecessarily complicated. It may be due to the fact that there is something inelegant about Display and it needs some refactoring. I will try to give it some thought.

I think it's related to the fact that terrains and entities are styled with "opaque" attributes, for which the separation into background and foreground colors is only known until after scenario parse time.

@kostmo
Copy link
Member Author

kostmo commented Jan 5, 2025

Also I'd say that some of the complication is due to #2265.

@kostmo kostmo force-pushed the feature/robot-background-passthrough-alternate branch from ff2086b to 2035ea1 Compare January 12, 2025 00:08
@kostmo kostmo changed the title Alternate approach to background passthrough background passthrough Jan 12, 2025
@kostmo
Copy link
Member Author

kostmo commented Jan 12, 2025

I will try to give it some thought.

@byorgey have you come up with anything? Would like to avoid incurring more rebase cost for this PR.

@byorgey
Copy link
Member

byorgey commented Jan 12, 2025

I think the fundamental thing for me is that we shouldn't need to store extra information outside of Display in order to figure out how to draw things --- instead, we should redesign Display so that simply composing a stack of Display values is enough to know how to draw the result.

What if we change Display so it contains not just displayAttr :: Attribute but displayAttrFG :: Attribute and displayAttrBG :: Maybe Attribute? How do we currently handle background attributes?

Edit: more thoughts about a redesign for Display are here:

@kostmo
Copy link
Member Author

kostmo commented Jan 12, 2025

I feel like the problem is less with Display and more with Attribute. Any Attribute can have both/either a foreground and a background color, stored together at one layer of indirection behind a string key. We may have to abandon the Attribute abstraction if we want the Display logic to be cleaner.

@byorgey
Copy link
Member

byorgey commented Jan 13, 2025

I feel like the problem is less with Display and more with Attribute.

Yes, I think you're right. Though when you talk about "abandoning" the Attribute abstraction I guess I'm not sure what you mean, since I don't remember exactly how we use it. Can't we just have some attributes map to foreground + background, and some map to foreground only, and some to background only? It might require adding more attributes and changing which things use which attributes, but I'm not sure we need to abandon it altogether.

@kostmo
Copy link
Member Author

kostmo commented Jan 14, 2025

Can't we just have some attributes map to foreground + background, and some map to foreground only, and some to background only?

That's a possibility, but with the current abstraction, it would rely on respecting a convention for which attributes are allowed to specify background/foreground/both. Ideally we would enforce by construction which layer an attribute pertains to.

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