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

Improvement to Territory and Loss Display #555

Closed
jacobm-tech opened this issue Sep 23, 2022 · 37 comments
Closed

Improvement to Territory and Loss Display #555

jacobm-tech opened this issue Sep 23, 2022 · 37 comments
Labels

Comments

@jacobm-tech
Copy link
Contributor

jacobm-tech commented Sep 23, 2022

The current way of displaying the expected territory could use some improvements.

  1. The territory display with grid-size rectangles is visually cluttered, since it looks like there is another grid overlayed over the board lines:

That can actually make it hard to count intersections in such a territory. A smoothly blended territory display would be better. Kivy textures actually enable smoothing the territory easily.

  1. The dead stones are not marked in any way while displaying territory; this is inconsistent with most Go interfaces and makes it much harder to see what's happening. I noted that there already some complaints about this in closed issues. This is probably my biggest issue with the current style.

  2. There is no information on weak stones, which is very useful in other programs; i.e. if the stone's probability of living is 55%, that's typically displayed by having a small mark over it, etc. I find that feature very useful.

I implemented the blended territory and stone ownership display, and will be submitting a pull request. With my implementation, the board looks like this:

Note the blended territory display, the ownership marks on the stones, the dead stones display (they are somewhat transparent and get an opponent's mark), and the weak black stones near the broken ladder, which also have some transparency and small ownership marks.

The teaching display looks similar. Here's KataGo telling you not to play away too soon after 3-3:

Note the red marks on the stones (loss of probability of keeping them) as well as the blended display of lost territory.

Pull request is #556 . The game in the image, BTW, is a broken ladder game between Albert Yen and Eric Yoder which is very interesting and seems to give KataGo at least some trouble.

@HackYardo
Copy link

I like the previous one more. Because a point on a stone makes the stone looks like an "eye", there're many "eyes" on a board, a board is a monster with many eyes... A bit fearful to me... Could KaTrain retains the two display styles rather than deletes the old one?

@sanderland
Copy link
Owner

A trypophobia mode? Seems a bit niche, but we can see if this one can be improved.

One option could be to not draw same color on same color dots. This kind of remove the 50%-100% range of keeping a stone, but looks cleaner.

@jacobm-tech
Copy link
Contributor Author

I have heard of trypophobia somewhere, but I don't have it and it's not something I was considering when implementing this display. I can see the similarity with those images, although I have to say that any Go board is going to have a bit of that effect with the circular stones placed on a grid.

I would not want to lose the 50%-100% range. I find it very useful in analysis to see that a group is getting weak.

I will make a comment later with some of the ideas I had while working on this (I actually went through a bunch of options), possibly, we will be able to come up with a more pleasing display. I am also open to implementing options.

For now, I would like to ask the commenter if the OGS display style, which is similar to most programs, is also unpleasant:

If this is better, perhaps because the marks are not circular, maybe I can come up with some ideas.

@jacobm-tech
Copy link
Contributor Author

Here are some of the alternatives that I considered during implementation.

  1. No marks - stone strength is indicated by transparency, with stones likely to be captured being quite faded. It looks like this:

In my opinion, while pretty, this is not very practical. It is hard to tell dead stones from weak stones, let alone degrees of weakness. But this should be the least phobia-inducing.

  1. Square marks or some other shape:

I would like to know from people who are sensitive to these dotted images if this is better. Personally, I can no longer tell which looks better to me.

  1. OGS-style implementation:

I just mocked this up. It is styled a bit differently from OGS. This is probably the most practical alternative for counting points and telling at a glance what's happening.

@jacobm-tech
Copy link
Contributor Author

I think I remember from a previous issue about territory display that Sander said he does not want to have more options in the program. However, if some of these are phobia-inducing for some, but practical for others, maybe a simple dropdown with options in the "Teaching/Analysis Settings" dialog could be accommodated. In the code, only a few lines would be added.

@HackYardo
Copy link

Thank you very much!

  • Square points are much kinder than circle points.
  • For the three ways, in my opinion, the no-mark way is the most beautiful and the OGS way is the most clear.
  • There is a similiar issue in OGS repo too: Fix score display legibility online-go/online-go.com#1138 People there think the Sabaki way is the best. I think the reason is the Sabaki way is somewhat "discrete" and other ways are somewhat "continuous".
  • The way of KataGo paper(1902.10565@arxiv) is displaying different ownership(area or territory) values via different colors.

After looking all the ways, I believe we can do the thing beautifully and clearly. Here are my suggestions:

  1. Stones are stones, ownership is ownership.
  2. Stones are only two kind: the pre-captured and the non-captured.
  3. Ownership is continuous and depends on a float number produced by KataGo.

@sanderland
Copy link
Owner

sanderland commented Sep 29, 2022

There is a similiar issue in OGS repo too: Fix score display legibility online-go/online-go.com#1138 People there think the Sabaki way is the best. I think the reason is the Sabaki way is somewhat "discrete" and other ways are somewhat "continuous".

Scoring is not ownership though, the 'this stone is 25% likely to be captured' information is what is caught in the (rather messy/overwhelming) squares.

@jacobm-tech
Copy link
Contributor Author

Thanks for the comments, @HackYardo, it's very helpful to have feedback!

  1. I will replace circles with squares in my proposal, I am glad they look better.
  2. I looked at the Sabaki implementation, and it is only appropriate for scoring at the end of the game, not for analyzing during the game. An example with the same game I used:

Here, Black is shown as ahead by 25 points, but in fact Black is behind in the game. This is because all territory that leans Black is scored for him, but there is no way Black will keep all of that territory. It is a pretty display which is easy to read, but it is just not informative or correct before essentially the whole board is settled.

Trying to fix that by varying the territory shading, but having only 2 shades of stones (dead or alive) is also not good, since you will end up with bright living-looking stones inside opponent territory, just because they are not totally dead. For example, the stone on C13 will be bright white, because it could live, but in fact, it probably won't.

The other thing has to do with highlighting squares in a "discrete" way like this:

(this is also done in the Katago paper). The problem is that boundaries are much more visible to human eyes than shading details, so the extra grid produced by these boundary lines overwhelms the information about territory. The lines either need to be blended, or perhaps we can give up the shading and use OGS-style marking.

Anyway, the question for me whether it's possible to include different highlighting styles in Katrain, controlled by an option in some dialogue or by separate buttons (Expected Territory vs. Highlight Score or something like that). That's up to Sander. If we are going to have only one style, I would strongly argue for one that shows stone strength.

@sanderland
Copy link
Owner

Anyway, the question for me whether it's possible to include different highlighting styles in Katrain, controlled by an option in some dialogue or by separate buttons (Expected Territory vs. Highlight Score or something like that). That's up to Sander. If we are going to have only one style, I would strongly argue for one that shows stone strength.

I'm happy to support variations through themes, particularly if they are for small variations on a design (like whether or not to show same-coloured squared on strong stones or not) rather than completely different new styles. However, I think the UI is quite overwhelming already, and want to be careful in adding extra options there, with all the clutter and i18n burden of those.

@jacobm-tech
Copy link
Contributor Author

I added to the pull request the ability to use Theme to change territory display.

  • There is a new value of Theme.STONE_MARKS which can be set to "all", "none", or "weak" (weak is Sander's suggestion of only marking stones which are >50% to be captured).
  • There is Theme.TERRITORY_DISPLAY which can be "marks" (little squares), "blended" (the blended coloring which I implemented above), or "trinary" (the Sabaki-style display).

@sanderland
Copy link
Owner

Awesome work @jacobm-tech ! Will merge soon so I can test it properly.

@sanderland
Copy link
Owner

Merged into 1.12 now

See https://github.com/sanderland/katrain/blob/1.12/THEMES.md for previews of options.

  • Thoughts on defaults?
  • when placing a stone it appears semi-transparent until the analysis comes in, which seems strange
  • white is much less noticable than black in blended mode, particularly in the opening and early middle game

@jacobm-tech
Copy link
Contributor Author

I will open another PR from 1.12 with enhancements and fixes for this feature. I think I see a simple fix for the transparent stone thing.

@jacobm-tech
Copy link
Contributor Author

Transparent stone problem is fixed in the new PR.

I agree that White territory looks a bit wimpy. This is not trivial to fix, since the default board is very light, so that white color is not as visible on it. For now, I have checked in a change to allow setting White and Black territory colors separately:

OWNERSHIP_COLORS = {"B": [0.0, 0.0, 0.0, 0.7], "W": [0.95, 0.95, 1.0, 0.825]}

The alpha of these colors gets multiplied by ownership when drawing the territory. This lets the white color be a bit punchier, and also gives it a very slight blue tint. I think it's an improvement on the default board, but it's hard to judge.

Another thing I am considering is dimming the board slightly when in estimate territory mode. Not sure yet about that one.

@jacobm-tech
Copy link
Contributor Author

I went ahead and added the ability to change board tint when toggling Territory Estimate. Still don't know what to think, my problem when tweaking the appearance of something is that after a few switches back and forth, I lose the ability to judge what I like better. Anybody who wants to look at it can check out blended-territory-enhancements from my fork.

I think all the legions of KaTrain theme designers are going to have to put in some work to get the territory colors to work with their boards and stones.

@jacobm-tech
Copy link
Contributor Author

I experimented with it some more. My conclusions:

  1. Definitely go with setting White and Black territory color separately instead of just alpha. The colors look different on a board, so you shouldn't just treat them symmetrically. The slightly enhanced White color already solves a lot of the problem.
  2. No joy on the idea of dimming the board when estimating territory. It's confusing and doesn't look that good.
  3. I would look for a slightly darker board texture. The problem with just dimming the existing light board texture is that it begins to look pale and greyed out. Darker board textures need to be designed for their brightness.

If there is a web or graphics designer among KaTrain fans, I think we could use some help to optimize this.

@jacobm-tech
Copy link
Contributor Author

I checked in a version with a slightly darker board and tweaked territory colors. Also added Theme.OWNERSHIP_GAMMA, so that the smaller territory certainties become a bit more visible (just like gamma-correcting an image). Please take a look at the result.

@sanderland
Copy link
Owner

new
image

old
image

looks a lot better! of course we may see other themes degrading a bit, but I think we can merge and look at that later

@jacobm-tech
Copy link
Contributor Author

I don't think there is any loss in merging it, you can get to the old behavior just by changing the theme. It could still use some attention from a designer. Also, the black stone texture has some white pixels in it, which become visible on a darker background. I will take a look.

kaorahi pushed a commit to kaorahi/lizgoban that referenced this issue Nov 3, 2022
@sanderland
Copy link
Owner

There is still some strange behaviour where stones turn transparent, especially if they are the last move, but also in other cases. I suspect the transparency may not always 'layer' as expected and affect things drawn on top of it perhaps?

image

I'll release as 0.12.0 regardless, but would appreciate if you looked into this.

@jacobm-tech
Copy link
Contributor Author

Can you give some more details? I don't immediately see a problem in the screenshot, the stone is quite weak, so it gets some transparency. You can set STONE_MIN_ALPHA to 1 in the theme if you don't want any transparency. Or maybe there is some other problem - I'd like to debut it before the release.

@sanderland
Copy link
Owner

I think it was just the ownership changing move by move, and not being used to transparency being used as an indicator of stone weakness.

@milescrawford
Copy link
Contributor

milescrawford commented Dec 1, 2022

The new options do not allow recreating the old style where the shading is done in squares. The new blobby style seems worse to me - the game is a grid, and the shaded grid felt much more natural. Obviously a preference, but I would love it if the previous display was still possible with a theme.

Second, I think there used to be a setting for OWNERSHIP_MAX_ALPHA that seems to have disappeared. The current blended style is very dark, and I can't tone it down in the theme. Edit: nevermind, I see that it is just rolled into OWNERSHIP_COLORS, sorry.

Thanks!

@jacobm-tech
Copy link
Contributor Author

This is very easy to do in the code: the line texture.mag_filter = "nearest" is currently used only for the "blocks" style, but using it with the "blended" style will result in the previous square shading. I don't mind adding this to theme options, if it's OK with Sander.

@sanderland
Copy link
Owner

Sure!

@milescrawford
Copy link
Contributor

I can take a swing at it if you'd like - I can see jacob's pull request, and I did the previous default shading I'm trying to bring back. :)

@milescrawford
Copy link
Contributor

Is it really this simple? How nice if so! #581

Please fire me any comments or requests for improvement.

@milescrawford
Copy link
Contributor

Hmm, I think a bug may have cropped up in the teaching game functionality - maybe when the ownership colors change was made?

Before any of my changes, no .katrain folder at all, this is what the territory display looks like after a teaching undo:
Screen Shot 2022-12-02 at 1 36 37 PM

@jacobm-tech - should we try to work a fix for this into my change or open a new issue?

@jacobm-tech
Copy link
Contributor Author

I think a new issue, I will take a look at it. I remember checking that teaching coloring works, but I must have broken it at some point.

@jacobm-tech
Copy link
Contributor Author

Yes, teaching shading is broken now - it's a one-line thing around line 745, where self.draw_territory_color(grid, loss_color=None) should note have the None - this was a default parameter that got copied into the function call. I will submit a pull request.

The mark on the stone is also very large, because loss can be up to 2 (going from live stone to dead stone) while ownership is up to 1. This needs some thought, since it means that loss shading ends up very saturated for cases when something dies outright, but just dividing the loss by 2 will end up with faint shading elsewhere.

@milescrawford
Copy link
Contributor

@jacobm-tech excellent, I see the new issue. Any comments on my change?

@jacobm-tech
Copy link
Contributor Author

Your change is correct, but I think it needs some more documentation (board pictures in themes.md).

@milescrawford
Copy link
Contributor

milescrawford commented Dec 3, 2022 via email

@milescrawford
Copy link
Contributor

shaded is now an option that restores the old territory display! thanks jacob and sander for reviewing and merging.

kaorahi pushed a commit to kaorahi/lizgoban that referenced this issue Dec 17, 2022
@JoeyNiOvO
Copy link

Why did KaTrain tell that
fatal error
failed to execute script_main

Copy link

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Aug 18, 2024
Copy link

This issue was closed because it has been stalled for 30 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants