Skip to content

Commit

Permalink
1.12.1 (#584)
Browse files Browse the repository at this point in the history
* Restore shaded territory display as a themeable option (#581)

* Add shaded territory theme

* fix max alpha docs

* Document new theme option, improve screenshots and md

* Fix detail about number of examples.

* Bump pillow from 9.0.1 to 9.3.0 (#579)

Bumps [pillow](https://github.com/python-pillow/Pillow) from 9.0.1 to 9.3.0.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
- [Commits](python-pillow/Pillow@9.0.1...9.3.0)

---
updated-dependencies:
- dependency-name: pillow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump certifi from 2020.12.5 to 2022.12.7 (#588)

Bumps [certifi](https://github.com/certifi/python-certifi) from 2020.12.5 to 2022.12.7.
- [Release notes](https://github.com/certifi/python-certifi/releases)
- [Commits](certifi/python-certifi@2020.12.05...2022.12.07)

---
updated-dependencies:
- dependency-name: certifi
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Teaching loss fix (#587)

* Loss during teaching games was not displayed.

* Loss during teaching games was not displayed.

* First version with working fixes.

* Enables loss coloring when undoing a move in a teaching game.

* Enables loss coloring when undoing a move in a teaching game.

* Enables loss coloring when undoing a move in a teaching game.

* Enables loss coloring when undoing a move in a teaching game.

* fix bug, weak default

* no transparency default

* low transparency default

* new katago

* linux exe

* black

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Miles Crawford <miles@milescrawford.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jacob Minsky <35696962+jacobm-tech@users.noreply.github.com>
Co-authored-by: Sander Land <sander.land@cognite.com>
Co-authored-by: Sander Land <sander@chatdesk.com>
  • Loading branch information
6 people authored Jan 9, 2023
1 parent 695f852 commit fc038ef
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 44 deletions.
19 changes: 13 additions & 6 deletions THEMES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,37 @@ Version 1.7 brings basic support for themes, and 1.9 extends it to include keybo

* KaTrain supports different styles of display of expected territory:
* Blended style colors the board with an intensity proportional to the likelihood of a player controlling that territory at the end of the game.
* Shaded style behaves the same as Blended, but uses square shades similar to
the Katago paper.
* In the Marks style, each point of the board is marked with a square of size which is proportional to ownership likelihood.
* The Blocks style divides the whole board into black, white, and neutral territory, based on a likelihood threshold. This style is appropriate as a counting aid, but may be misleading before endgame if much of the territory is unsettled.
* Marks can also appear on stones to indicate the likelihood of these stones living at the end of the game. Three styles are supported:
* All stones can be marked, with the color of the mark indicating the expected ownership and the size of the mark indicating certainty.
* Weak stones only - marks will appear only on stones which are over 50% likely to die before the end of the game.
* No stone marks.
* Stones can also be made transparent based on their strength.

| <img src="https://raw.githubusercontent.com/jacobm-tech/katrain/blended-territory-display/themes/blended-all.png" width="400px"/><br><span style="font-weight:normal">Blended style, all stones marked</span> | <img src="https://raw.githubusercontent.com/jacobm-tech/katrain/blended-territory-display/themes/marks-weak.png" width="400px"/><br><span style="font-weight:normal">Marks on intersections, weak stones marked</span> |
|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://raw.githubusercontent.com/jacobm-tech/katrain/blended-territory-display/themes/blocks-none.png" width="400px"/><br>Territory blocks, no stones marked | <img src="https://raw.githubusercontent.com/jacobm-tech/katrain/blended-territory-display/themes/blended-weak.png" width="400px"/><br>Blended territory, weak stones marked |
| <img src="./themes/blended-all.png" width="400"/> <br> Blended style, all stones marked| <img src="./themes/shaded-all.png" width="400"/> <br> Shaded style, all stones marked |
| --- | ---|
| <img src="./themes/blocks-none.png" width="400"/> <br> Territory blocks, no stones marked | <img src="./themes/blended-weak.png" width="400"/> <br> Blended territory, weak stones marked |
| <img src="./themes/marks-weak.png" width="400"/> <br> Marks on intersections, weak stones marked | <img src="./themes/shaded-no-alpha.png" width="400"/> <br> Shaded, no stone alpha |

<sup>The game used in the screenshots is [Albert Yen vs. Eric Yoder](https://www.usgo.org/news/2022/03/members-edition-midwest-open-round-2-the-broken-ladder-game).</sup>

The stone marks and territory style are independent; the table above presents 4 possible variants out of 9.
The stone marks, transparency, and territory style are independent; the table above presents a collection of possible variants.
The relevant variables are:
```
TERRITORY_DISPLAY = "blended" | "marks" | "blocks"
TERRITORY_DISPLAY = "blended" | "shaded" | "marks" | "blocks"
STONE_MARKS = "all" | "weak" | "none"
OWNERSHIP_MAX_ALPHA = 0.7
OWNERSHIP_COLORS = {"B": [0.0, 0.0, 0.10, 0.75], "W": [0.92, 0.92, 1.0, 0.800]}
BLOCKS_THRESHOLD = 0.6
MARK_SIZE = 0.42 # as fraction of stone size
STONE_MIN_ALPHA = 0.5
```

The colors are specified as RGB values and a maximum alpha transparency.

## Installation

* To install a theme, simply unzip the theme.zip to your .katrain folder.
Expand Down
Binary file modified katrain/KataGo/katago
Binary file not shown.
Binary file modified katrain/KataGo/katago.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion katrain/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"anim_pv_time": 0.5,
"debug_level": 0,
"lang": "en",
"version": "1.11.3",
"version": "1.12.1",
"load_fast_analysis": false,
"load_sgf_rewind": true
},
Expand Down
2 changes: 1 addition & 1 deletion katrain/core/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PROGRAM_NAME = "KaTrain"
VERSION = "1.12.0"
VERSION = "1.12.1"
HOMEPAGE = "https://github.com/sanderland/katrain"
CONFIG_MIN_VERSION = "1.11.0" # keep config files from this version
ANALYSIS_FORMAT_VERSION = "1.0"
Expand Down
37 changes: 22 additions & 15 deletions katrain/gui/badukpan.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ def draw_stone(
alpha = Theme.STONE_MIN_ALPHA + (1.0 - Theme.STONE_MIN_ALPHA) * abs(ownership)
else:
alpha = Theme.STONE_MIN_ALPHA
else:
(owner, other) = ("B", "W") # prevent errors in unused unset vars
Color(1, 1, 1, alpha)
Rectangle(
pos=(self.gridpos[y][x][0] - stone_size, self.gridpos[y][x][1] - stone_size),
Expand All @@ -251,11 +253,12 @@ def draw_stone(
mark_color = *Theme.STONE_COLORS[owner][:3], 1.0
other_color = *Theme.STONE_COLORS[other][:3], 1.0
outline_color = tuple(map(lambda y: sum(y) / float(len(y)), zip(*(mark_color, other_color))))
if loss is not None:
mark_color = *Theme.EVAL_COLORS[self.trainer_config["theme"]][1][:3], loss
else:
assert loss is not None
mark_color = *Theme.EVAL_COLORS[self.trainer_config["theme"]][1][:3], 1
outline_color = mark_color

mark_size = Theme.MARK_SIZE * abs(ownership if ownership else loss) * self.stone_size * 2.0
mark_size = Theme.MARK_SIZE * abs(ownership if ownership else min(1, loss)) * self.stone_size * 2.0
Color(*mark_color)
Rectangle(
pos=(
Expand Down Expand Up @@ -419,7 +422,7 @@ def calculate_stone_size(self, grid_size):

def initialize_gridpos(self):
self.gridpos = [[None for x in range(len(self.initial_gridpos_x))] for y in range(len(self.initial_gridpos_y))]
#[[None]*len(self.initial_gridpos_x)]*len(self.initial_gridpos_y)
# [[None]*len(self.initial_gridpos_x)]*len(self.initial_gridpos_y)
for y in range(len(self.initial_gridpos_y)):
for x in range(len(self.initial_gridpos_x)):
self.gridpos[y][x] = [self.initial_gridpos_x[x], self.initial_gridpos_y[y]]
Expand Down Expand Up @@ -638,7 +641,9 @@ def draw_board_contents(self, *_args):
evalscale = min(1, max(0, realized_points_lost / points_lost))
placements = node.placements
for m in node.moves + placements:
new_move = (current_node.move and m.coords == current_node.move.coords) and not current_node.ownership
new_move = (
current_node.move and m.coords == current_node.move.coords
) and not current_node.ownership
if has_stone.get(m.coords) and not drawn_stone.get(m.coords): # skip captures, last only for
move_eval_on = not all_dots_off and show_dots_for.get(m.player) and i < show_n_eval
if move_eval_on and points_lost is not None:
Expand Down Expand Up @@ -742,9 +747,9 @@ def draw_board_contents(self, *_args):

def draw_territory(self, grid, loss_color=None):
if Theme.TERRITORY_DISPLAY == "marks":
self.draw_territory_marks(grid, loss_color=None)
self.draw_territory_marks(grid, loss_color)
else:
self.draw_territory_color(grid, loss_color=None)
self.draw_territory_color(grid, loss_color)

def draw_territory_marks(self, grid, loss_color=None):
board_size_x, board_size_y = self.katrain.game.board_size
Expand All @@ -753,11 +758,11 @@ def draw_territory_marks(self, grid, loss_color=None):
if abs(grid[y][x]) < 0.01:
continue
(ix_owner, other) = ("B", "W") if grid[y][x] > 0 else ("W", "B")
Color(
*Theme.STONE_COLORS[ix_owner][:3],
1.0
)
rect_size = Theme.MARK_SIZE * abs(grid[y][x]) * self.stone_size * 2.0
if loss_color is None:
Color(*Theme.STONE_COLORS[ix_owner][:3], 1.0)
else:
Color(*loss_color[:3], 1.0)
rect_size = Theme.MARK_SIZE * min(1.0, abs(grid[y][x])) * self.stone_size * 2.0
Rectangle(
pos=(
self.gridpos[y][x][0] - rect_size / 2,
Expand Down Expand Up @@ -789,9 +794,11 @@ def draw_territory_color(self, grid, loss_color=None):
alpha = 0
else:
alpha = abs(grid[y_coord][x_coord])
if alpha > 1:
alpha = 1
if Theme.TERRITORY_DISPLAY == "blocks":
alpha = 1 if alpha > Theme.BLOCKS_THRESHOLD else 0
alpha = alpha**(1.0/Theme.OWNERSHIP_GAMMA)
alpha = alpha ** (1.0 / Theme.OWNERSHIP_GAMMA)

x_coord = max(0, min(x_coord, board_size_x - 1))
y_coord = max(0, min(y_coord, board_size_y - 1))
Expand All @@ -801,12 +808,12 @@ def draw_territory_color(self, grid, loss_color=None):
pixel = Theme.OWNERSHIP_COLORS[ix_owner][:4]
pixel[3] *= alpha
else:
pixel = *loss_color, min(1.0, alpha)
pixel = *loss_color, Theme.HINTS_ALPHA * alpha
pixel = tuple(map(lambda p: int(p * 255), pixel))
idx = 4 * y * (board_size_x + 2) + x * 4
bytes[idx : idx + 4] = pixel

if Theme.TERRITORY_DISPLAY == "blocks":
if Theme.TERRITORY_DISPLAY == "blocks" or Theme.TERRITORY_DISPLAY == "shaded":
texture.mag_filter = "nearest"
texture.blit_buffer(bytes, colorfmt="rgba", bufferfmt="ubyte")
Color(1, 1, 1, 1)
Expand Down
25 changes: 13 additions & 12 deletions katrain/gui/popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ class BaseConfigPopup(QuickConfigGui):
"20 block model": "https://github.com/lightvector/KataGo/releases/download/v1.4.5/g170e-b20c256x2-s5303129600-d1228401921.bin.gz",
"30 block model": "https://github.com/lightvector/KataGo/releases/download/v1.4.5/g170-b30c320x2-s4824661760-d1229536699.bin.gz",
"40 block model": "https://github.com/lightvector/KataGo/releases/download/v1.4.5/g170-b40c256x2-s5095420928-d1229425124.bin.gz",
"18 'nested residual block' model": "https://github.com/lightvector/KataGo/releases/download/v1.12.0/b18c384nbt-uec.bin.gz",
}
MODEL_DESC = {
"Fat 40 block model": "https://d3dndmfyhecmj0.cloudfront.net/g170/neuralnets/g170e-b40c384x2-s2348692992-d1229892979.zip",
Expand All @@ -479,22 +480,22 @@ class BaseConfigPopup(QuickConfigGui):

KATAGOS = {
"win": {
"OpenCL v1.11.0": "https://github.com/lightvector/KataGo/releases/download/v1.11.0/katago-v1.11.0-opencl-windows-x64.zip",
"Eigen AVX2 (Modern CPUs) v1.11.0": "https://github.com/lightvector/KataGo/releases/download/v1.11.0/katago-v1.11.0-eigenavx2-windows-x64.zip",
"Eigen (CPU, Non-optimized) v1.11.0": "https://github.com/lightvector/KataGo/releases/download/v1.11.0/katago-v1.11.0-eigen-windows-x64.zip",
"OpenCL v1.11.0 (bigger boards)": "https://github.com/lightvector/KataGo/releases/download/v1.11.0/katago-v1.11.0-opencl-windows-x64+bs29.zip",
"OpenCL v1.12.0": "https://github.com/lightvector/KataGo/releases/download/v1.12.0/katago-v1.12.0-opencl-windows-x64.zip",
"Eigen AVX2 (Modern CPUs) v1.12.0": "https://github.com/lightvector/KataGo/releases/download/v1.12.0/katago-v1.12.0-eigenavx2-windows-x64.zip",
"Eigen (CPU, Non-optimized) v1.12.0": "https://github.com/lightvector/KataGo/releases/download/v1.12.0/katago-v1.12.0-eigen-windows-x64.zip",
"OpenCL v1.12.0 (bigger boards)": "https://github.com/lightvector/KataGo/releases/download/v1.12.0/katago-v1.12.0-opencl-windows-x64+bs29.zip",
},
"linux": {
"OpenCL v1.11.0": "https://github.com/lightvector/KataGo/releases/download/v1.11.0/katago-v1.11.0-opencl-linux-x64.zip",
"Eigen AVX2 (Modern CPUs) v1.11.0": "https://github.com/lightvector/KataGo/releases/download/v1.11.0/katago-v1.11.0-eigenavx2-linux-x64.zip",
"Eigen (CPU, Non-optimized) v1.11.0": "https://github.com/lightvector/KataGo/releases/download/v1.11.0/katago-v1.11.0-eigen-linux-x64.zip",
"OpenCL v1.11.0 (bigger boards)": "https://github.com/lightvector/KataGo/releases/download/v1.11.0/katago-v1.11.0-opencl-linux-x64+bs29.zip",
"OpenCL v1.12.0": "https://github.com/lightvector/KataGo/releases/download/v1.12.0/katago-v1.12.0-opencl-linux-x64.zip",
"Eigen AVX2 (Modern CPUs) v1.12.0": "https://github.com/lightvector/KataGo/releases/download/v1.12.0/katago-v1.12.0-eigenavx2-linux-x64.zip",
"Eigen (CPU, Non-optimized) v1.12.0": "https://github.com/lightvector/KataGo/releases/download/v1.12.1/katago-v1.12.0-eigen-windows-x64.zip",
"OpenCL v1.12.0 (bigger boards)": "https://github.com/lightvector/KataGo/releases/download/v1.12.0/katago-v1.12.0-opencl-linux-x64+bs29.zip",
},
"just-descriptions": {
"CUDA v1.11.0 (Windows)": "https://github.com/lightvector/KataGo/releases/download/v1.11.0/katago-v1.11.0-cuda11.2-windows-x64.zip",
"CUDA v1.11.0 (Linux)": "https://github.com/lightvector/KataGo/releases/download/v1.11.0/katago-v1.11.0-cuda11.1-linux-x64.zip",
"Cuda/TensorRT v1.11.0 (Windows)": "https://github.com/lightvector/KataGo/releases/download/v1.11.0/katago-v1.11.0-trt8.2-cuda11.2-windows-x64.zip",
"Cuda/TensorRT v1.11.0 (Linux)": "https://github.com/lightvector/KataGo/releases/download/v1.11.0/katago-v1.11.0-trt8.2-cuda11.1-linux-x64.zip",
"CUDA v1.12.0 (Windows)": "https://github.com/lightvector/KataGo/releases/download/v1.12.0/katago-v1.12.0-cuda11.2-windows-x64.zip",
"CUDA v1.12.0 (Linux)": "https://github.com/lightvector/KataGo/releases/download/v1.12.0/katago-v1.12.0-cuda11.1-linux-x64.zip",
"Cuda/TensorRT v1.12.0 (Windows)": "https://github.com/lightvector/KataGo/releases/download/v1.12.0/katago-v1.12.1-trt8.2-cuda11.2-windows-x64.zip",
"Cuda/TensorRT v1.12.0 (Linux)": "https://github.com/lightvector/KataGo/releases/download/v1.12.0/katago-v1.12.1-trt8.2-cuda11.1-linux-x64.zip",
},
}

Expand Down
13 changes: 6 additions & 7 deletions katrain/gui/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ class Theme:
EVAL_DOT_TEXTURE = "dot.png"
LAST_MOVE_TEXTURE = "inner.png"
TOP_MOVE_TEXTURE = "topmove.png"
BOARD_TEXTURE = "board.png"
BOARD_TEXTURE = "wood6.jpg"
BOARD_TEXTURE = "wood6.jpg" # "board.png"
GRAPH_TEXTURE = "graph_bg.png"
# sounds
STONE_SOUNDS = [f"stone{i}.wav" for i in [1, 2, 3, 4, 5]]
Expand Down Expand Up @@ -123,14 +122,14 @@ class Theme:
POLICY_ALPHA = 0.5
OWNERSHIP_COLORS = {"B": [0.0, 0.0, 0.10, 0.75], "W": [0.92, 0.92, 1.0, 0.800]}
OWNERSHIP_GAMMA = 1.33
STONE_MIN_ALPHA = 0.7 # the minimal alpha for dead/weak stones
STONE_MIN_ALPHA = 0.85 # the minimal alpha for dead/weak stones

TERRITORY_DISPLAY = "blended" # other possibilities are "marks" and "blocks"
TERRITORY_DISPLAY = "blended" # other possibilities are "marks", "blocks" or "shaded"
BLOCKS_THRESHOLD = 0.3 # in "blocks" mode, territory which is this likely to be
# a certain player's gets his color
STONE_MARKS = "all" # all: always display marks on stones
# none: no marks on stones, indicate ownership by transparency only
# weak: draw marks only on stones likely (>50%) to be captured
STONE_MARKS = "weak" # all: always display marks on stones
# none: no marks on stones, indicate ownership by transparency only (if STONE_MIN_ALPHA < 1.0)
# weak: draw marks only on stones likely (>50%) to be captured
MARK_SIZE = 0.42 # stone mark size as fraction of stone size

HINTS_LO_ALPHA = 0.6
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
certifi==2020.12.5
certifi==2022.12.7
chardet==3.0.4
docutils==0.16
ffpyplayer==4.3.2
idna==2.10
Kivy==2.1.0
Kivy-Garden==0.1.4
kivymd==0.104.1
Pillow==9.0.1
Pillow==9.3.0
Pygments==2.7.4
requests==2.25.0
urllib3==1.26.5
Binary file added themes/shaded-all.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added themes/shaded-no-alpha.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fc038ef

Please sign in to comment.