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

Refactor Display to make it simpler/more robust #570

Open
byorgey opened this issue Jul 20, 2022 · 4 comments
Open

Refactor Display to make it simpler/more robust #570

byorgey opened this issue Jul 20, 2022 · 4 comments
Labels
C-Moderate Effort Should take a moderate amount of time to address. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. Z-Refactoring This issue is about restructuring the code without changing the behaviour to improve code quality. Z-Research This issue requires inventing something new and/or studying research papers for clues.

Comments

@byorgey
Copy link
Member

byorgey commented Jul 20, 2022

There are several things about Display that seem a bit awkward. It definitely feels like there is a better design hiding in there but we haven't been able to figure out what it is yet.

I wonder if that is a good responsibility division - perhaps there is a better abstraction/wrapper for displayable things that have orientation, and their drawing depends on it. 🤔
I am hoping things would get simpler if robots (or later other entities) set the drawn character from their direction map when they are themselves changing their orientation, keeping the source of truth in the robot (or entity).
Caching seems like overengineering to me - I am worried it would just cause bugs.

Originally posted by @xsebek in #556 (comment)

@byorgey byorgey added C-Low Hanging Fruit Ideal issue for new contributors. Z-Refactoring This issue is about restructuring the code without changing the behaviour to improve code quality. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. labels Jul 20, 2022
@xsebek
Copy link
Member

xsebek commented Jul 27, 2022

Funny enough based on coverage, we do not use this functionality even for robots so far:

image

For entities, it makes little sense to have a direction and direction map, since you can not turn them or get their direction or appearance string programmatically. Maybe that could change with #455, but it seems impractical to use direction map.

@byorgey
Copy link
Member Author

byorgey commented Jul 27, 2022

I'm not sure what you mean. That is just the code for handling the "appear" command. Robots certainly do use the functionality of a direction map. That coverage report just means we never test the 5-character variant of the appear command.

@xsebek
Copy link
Member

xsebek commented Jul 28, 2022

What I meant is that we do not currently change the map after the robots are created. So most of the robots just share one map and a few robots could do with singleton maps.

But that could maybe change with a scenario that has shapeshifting robots.

It seems to me that it is a bit hard to use this feature since we do not use it too much.
So it would be even harder to use direction map instead of single character for entities.

@byorgey byorgey added C-Moderate Effort Should take a moderate amount of time to address. and removed C-Low Hanging Fruit Ideal issue for new contributors. labels Oct 29, 2022
@byorgey byorgey added the Z-Research This issue requires inventing something new and/or studying research papers for clues. label May 25, 2023
@byorgey
Copy link
Member Author

byorgey commented Apr 23, 2024

Thinking about this a bit more, perhaps a cleaner solution is to have two types:

  1. EntityDisplay, which is the current type minus the cached orientation.
  2. Display, which would contain simply a character, attribute, priority, and boolean for invisibility.

The point is that each robot or entity could store an EntityDisplay containing all the information about how it should be drawn in various circumstances. When we go to concretely draw a frame, we generate a Display value for each thing to be drawn (possibly by consulting its current orientation, etc.); the Display values for a single cell are then combined according to the Semigroup instance.

While we're at it, perhaps Display could also optionally contain a background color, and we could generate one for each terrain as well. Then we could truly decide how to render each cell by composing a bunch of Display values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Moderate Effort Should take a moderate amount of time to address. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. Z-Refactoring This issue is about restructuring the code without changing the behaviour to improve code quality. Z-Research This issue requires inventing something new and/or studying research papers for clues.
Projects
None yet
Development

No branches or pull requests

2 participants