-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
456 lines (408 loc) · 19 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
<!--For anyone who modify index.html or index_zh.html, please don't forget to keep the line number relation unchanged. They are aligned line by line.-->
<title>BadukAI</title>
<body style="background-color: #fbf3ea">
<h5 align="right"><a href="index_zh.html">中文版</a></h5>
<h1 align="center">BadukAI</h1>
<span style="text-align: center; display: block">
<img src="icon.png" />
</span>
<p> </p>
<p>This app allows you to play and analyse go/baduk/weiqi with two very strong AIs:</p>
<p>1) <b>Katago</b>:
To my knowledge the first native implementation on android.
You can choose between a 10 blocks network (the latest one from extended training)
and a 20 blocks network (from version 1.5.0).
Moreover you can load a network from your device storage.
The 10 blocks network runs on CPU.
The 20 blocks network is optimized for android and will use HW acceleration if possible.</p>
<p>2) <b>LeelaZero</b>:
You can choose between a 15 blocks network (trained against 40b self-play)
and a 40 blocks network (LZ 287).
Moreover you can load a network from your device storage.
The implementation is optimized for android and will use HW acceleration if possible.</p>
<p>Some examples of performance (nodes per second):</p>
<p></p>
<table border="1">
<tr align="center">
<th>Network</th>
<th>Dimensity 9200+</th>
<th>Snapdragon 8+ Gen 1</th>
<th>Kirin 9000</th>
<th>Snapdragon 888</th>
<th>Dimensity 9000</th>
<th>Dimensity 8100</th>
<th>Dimensity 1100</th>
<th>Snapdragon 778</th>
<th>Snapdragon 768</th>
<th>Snapdragon 855+</th>
</tr>
<tr align="center">
<td>KG 20b</td>
<td>720 </td>
<td>580 </td>
<td>500 </td>
<td>330 </td>
<td>280 </td>
<td>240 </td>
<td>130 </td>
<td>120 </td>
<td>80 </td>
<td>55 </td>
</tr>
<tr align="center">
<td>LZ 15b</td>
<td></td>
<td></td>
<td></td>
<td>1000 </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>200 </td>
</tr>
<tr align="center">
<td>LZ 40b</td>
<td></td>
<td>420 </td>
<td></td>
<td>280 </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>50 </td>
</tr>
</table>
<p>You can either install it from <a href=
"https://play.google.com/store/apps/details?id=net.kir.baduk_ai"
>google play store </a>or you can <a href=
"https://github.com/aki65/aki65.github.io/releases/download/v1.20.0/baduk_ai__arm64-v8a-rel-1.20.apk"
>download 64 bit APK </a>and install it (make sure that installation of thirdparty-apps is allowed in settings). If this APK is not compatible with your device, <a href=
"https://github.com/aki65/aki65.github.io/releases/download/v1.20.0/baduk_ai__armeabi-v7a-rel-1.20.apk"
>download 32 bit APK </a>and install it.</p>
<p> </p>
<span style="text-align: center; display: block">
<img width="300" src="Screenshot_2023-09-02-17-10-41-351_net.kir.baduk_ai.jpg" />
</span>
<p> </p>
<p>The UI is an extension of Alexander Taylor's excellent app "LazyBaduk" (with kind permission from him). Most of it is self-explanatory but some hints may be helpful:</p>
<ul>
<li><a href="#top_row">Top row</a></li>
<li><a href="#settings">Settings</a></li>
<li><a href="#board">Board</a></li>
<li><a href="#control">Control buttons</a></li>
<li><a href="#strength">How to adjust AI's strength for playing against it</a></li>
</ul>
<h3 id="top_row">Top row</h3>
<p>The two bullets in the top-left corner indicate whose turn it is.
You can switch this by tapping on the bullets (if no moves have been played yet).</p>
<p>By tapping the button with the green circle in the top row
you can switch the displaying of analyzed moves on and off.</p>
<p>By tapping the dashed rectangle in the top row you can restrict AI analysis to a region
(which consists of a rectangle plus additional points):
First a dialog pops up, where you can switch the restriction on and off,
enter the coordinates of the additional points
and choose how many subsequent moves must be inside the region.
Afterwards you can define the rectangle on the board by dragging
from its top left corner to the bottom right one.</p>
<h3 id="settings">Settings</h3>
<p>The settings menu in the top right corner allows you to
switch networks, engines and adjust game settings:</p>
<p>The name of the network currently used is displayed in the
first field (LeelaZero) resp. second field (KataGo).
If you tap on this field, a dialog opens which allows you to manage the networks:
You can delete internal networks which you don't intend to use (to save storage)
or you can load network files from your device storage.
For KataGo you can load either standard or optimized networks in this way,
for LeelaZero only optimized networks.
If you want to load an optimized network (which always consists of two files),
you must choose both files, one after the other (necessary because otherwise
the latest android versions won't grant access to both files for BadukAI).
You can find optimized networks
<a href="https://github.com/aki65/aki65.github.io/releases">here</a>.
The most recent KataGo networks for the different sizes are:
<ul>
<li><a href="https://github.com/aki65/aki65.github.io/releases/tag/v1.16.0">
40 blocks (requires app version 1.16 or higher and will run fast on recent Dimensity and all Snapdragon chips except Snapdragon 8 gen 2/3)</a></li>
<li><a href="https://github.com/aki65/aki65.github.io/releases/tag/v1.15.0">
60 blocks (requires app version 1.15 or higher and will run fast on recent Dimensity and all Snapdragon chips except Snapdragon 8 gen 2/3)</a></li>
<li><a href="https://github.com/aki65/aki65.github.io/releases/tag/v1.19.13">
18 blocks (requires app version 1.18.8 or higher and will run fast on recent Snapdragon chips)</a></li>
<li><a href="https://github.com/aki65/aki65.github.io/releases/tag/v1.19.22">
28 blocks (requires app version 1.19.5 or higher and will run fast on recent Snapdragon chips)</a></li>
</ul>
</p>
<p>
By tapping on <b>"Edit config"</b> you can open a dialog for changing the AI engine configuration.
Most parameters are directly passed to AI and can be found in the engine's documentation.
With "useSpecificNpuAccelerator" you can set the NPU accelerator, that BadukAI should use.
By default, BadukAI makes a reasonable choice,
but that will not be optimal for all devices.
So, to optimize performance,
you can try all the available choices and check which one runs fastest.
Be sure there is a NPU on your phone chip.
</p>
<p id="kyu-rank">
If KataGo is active, you can edit the field <b>"kyu-rank"</b> in settings:
If you enter a number between 30 and -8 (denoting 9-dan),
a calibrated bot of roughly this strength (as in KaTrain) will make the AI moves
(full credit to sanderland's great KaTrain project for the underlying algorithms).
For the strength calibration to fit,
you have to use the 20b network (or an external 15b network).
Rank settings above 4-dan have to be taken with a grain of salt:
Strength will increase but not by much, so that -8 will be a lot weaker than 9-dan.
You might want to combine this bot with activating "opening book" to get a human-style fuseki.
</p>
<p>
If you enter anything else than numbers between 30 and -8 in "kyu-rank" (or
nothing at all), full KataGo will be in charge of the AI moves again.
Analysis (via "ponder" or "analyse all") will always be done by full KataGo.
</p>
<p>
With the checkbox <b>"winrate on play"</b> you can toggle whether winrates are also
shown during play (not only in analysis). If ticked, the winrate will be
displayed for all moves of the AI.
</p>
<p>
In the field labelled <b>"moves to show in analysis"</b> you can limit the number of
analyzed moves that are shown on the board.
<p>
By tapping <b>"Set board appearance"</b> you can customize the look of the board by
choosing your own images of board and stones. Moreover, you can toggle the
display of the "next move" marker and the numbering of stones. Additionally,
you can switch to a fun variation of the game called "One color go": All
stones played appear in the same color (the one that you choose in the combobox
"all stones in same color"). This a fun way to train your (shape)
memory. The setting applies only to newly played stones, not to existing
ones. So, if you play a one-colored game and want to see the current
position with both colors, you have to set the "all stones in same color" option to "-",
then jump to the beginning of the game (by tapping on the first segment of
the histogram), then jump back to the end (by tapping on the last segment of
the histogram). In this way you force BadukAI to re-play all the stones, so
that the new setting applies, so that the stones will have normal colors
again.
</p>
<p>
Below you can configure what the <b>area below the board</b> will show:
</p>
<ul>
<li>tree view of all game variations (By long tapping on a node you can open
a dialog to enter a comment. If a node with a comment is selected, the
comment is displayed below the tree view. By tapping slightly above or below
the comment, you can scroll up and down. By double-tapping on the comment,
you can open the dialog to edit the comment).
</li>
<li>histogram of winrate</li>
<li>
histogram of difference between white's winrates in this position and the previous
position, capped at the value (in percent) that you enter in the text
field following ±, i.e. if you enter 10 the histogram will range from -10%
(bottom) to +10% (top)
</li>
<li>
histogram of difference between white's score leads in this position and the previous
position, capped at the value that you enter in the text field following ±
</li>
</ul>
<p>
By tapping <b>"Manage time settings"</b> you can set constraints on thinking time
for yourself and AI: "seconds/move" will be used by AI during play. If you
enter a positive number in the field "visits/move in analysis", then this
number of visits will be executed on each move during "analyse all". Otherwise
the time specified in "seconds/move" will be spent. If you enter a positive number in
"max pondering time per position (in secs)", then the AI will stop analyzing a
position after that amount of time, when you have tapped "ponder". Otherwise it
will analyze until you hit "ponder" again. With "animation speed for variations"
you can adjust how fast BadukAI shows a variation (when you hold your finger on
the analyzed move, see below)
</p>
<p>
By tapping on the combobox besides <b>"rules"</b>, you can customize the rules: There are
seven rule elements ("Ko", "Scoring", ...) that you can set (for a detailed description
of their meaning please refer to
<a href="https://lightvector.github.io/KataGo/rules.html">KataGo's Supported Go Rules</a>).
As a shortcut, you can tap on one of the well-known standard rulesets like "Chinese",
this will adjust all rule elements accordingly.
</p>
<h3 id="board">Board</h3>
<p>
If you touch the board, a preview of the stone to be played will be shown.
You can adjust its position by dragging your finger across the board (stone
position is always 3 lines above your finger). Lifting off your finger
finally places the stone. The 3-line-offset can be switched off in the
settings.
</p>
<p>
You can pan, zoom and rotate the board (by multiples of 90°) with two fingers.
</p>
<p>
The area below the board shows a kind of winrate histogram. The area is
divided into as many segments as moves have been loaded (from sgf) and/or
played. By tapping on a segment you can navigate to the corresponding move,
resp. position. The current position is indicated by a red triangle. If a
position has been analysed by AI the (originally grey) corresponding segment
is coloured black/white such that the size of the white area is proportional
to white's winrate.
</p>
<p>
The histogram always shows a linear sequence of moves (there is just no
space for a complete win-rated game tree). If you load an sgf (either by the
button or by sharing an sgf from another app to BadukAI), the main line of
the sgf will be shown. If you then switch to a variation by tapping "next
var" at a branching position, the histogram will show the move sequence from
game start up to the end of the variation. Similarly, if you enter moves
manually or let the AI generate moves to explore a position, you create a
new variation and the histogram will again show the sequence from game start
to the end of the variation.
</p>
<p>
Even though the histogram shows only one move sequence, the button "save
sgf" will save the complete game tree.
</p>
<p>
When AI analyses a position, the best moves (up to ten) appear below the
winrate histogram in order of quality. While you hold your finger on such a
move, the primary variation following that move is displayed on the board.
If you hold your finger on the first button (named "own") of the row, the
ownership prediction by AI is shown by a transparent overlay on the board.
</p>
<h3 id="control">Control buttons</h3>
<p>
By tapping "ponder" you can make AI analyse the current position: The
winrate in the histogram and the display of the best moves on the board and
below the histogram will be continously updated until you stop analysis by
tapping "ponder" again. If you enter a positive number in "max pondering time per position (in secs)"
in manage time settings, then the analysis will be paused after that amount of time
has been spent on a position (until the position changes).
</p>
<p>
If you tap "analyse all", AI will analyse each position from the current one
to the end of the sequence in the histogram (spending "seconds/move" or
"visits/move in analysis" from the settings on each position). Afterwards
the histogram will show all winrates so that you can detect sudden changes
in the winrate (which hint at mistakes) and have a closer look at these
positions.
</p>
<p>
By tapping "<", ">", "next var" and "back to main" you can navigate through
the game tree. "next var" doesn't change the position, but switches to the
next variation. As a result the circle, which indicates the next move, will
change. If you tap ">" afterwards, you will advance into the chosen
variation. If you are already on the last variation, "next var" will switch
to the first one(the main var). "back to main" will always take you back to the main line
(to the position where your chosen variation left off the main line).
</p>
<p>
If you have loaded an sgf with only set stones (i.e no moves), the
navigation buttons in the second row are useless, so they mutate into
editing buttons: After tapping "add B stone" you can put any number of black
stones on the board (in the same way as you would play them). Same goes for
white stones. After tapping "remove stone" you can place a cross on the
board (in the same way as a stone). By placing it on an existing stone, you
can remove that stone.
</p>
<p>
By tapping the marked editing button again (whichever it is), you can stop
its editing function. In that state, touching the board will play a stone as
usual.
</p>
<p>
To play handicap, just put the handicap stones on the board (as described
above), tap on the white bullet in the top left corner to make it white's
turn, then tap "play W" to let AI play white.
</p>
<p>
After tapping "load sgf", you can not only load sgf files, but also images
of a go board or a part of it. BadukAI will then detect the board and stones
in the image and display the resulting board position. For that to work, you
must tell BadukAI what to look for, more precisely:
</p>
<ul>
<li>
How many horizontal lines does the board fragment in the image contain ?
</li>
<li>
How many vertical lines does the board fragment in the image contain ?
</li>
<li>
Is it a corner or a side ? More generally, which edges are contained in
the image ?
</li>
</ul>
For this tsumego, for example:
<span style="text-align: center; display: block">
<img width="300" src="corner.png" />
</span>
<p>you would have to set the following contents information:</p>
<ul>
<li>7 horizontal lines</li>
<li>9 vertical lines</li>
<li>left and bottom edge</li>
</ul>
And for a full board it's of course: 19 vertical lines, 19 horizontal lines,
all edges.
<p>You can do it in both orders:</p>
<ul>
<li>
First load the image (or take the photo): Then the dialog will re-appear
afterwards with the image displayed on the right. Then edit the contents
information, then tap "Detect stones in image above".
</li>
</ul>
or
<ul>
<li>
First edit the contents information, then check "Detect stones in new
image right after ...", then load the image (or take the photo). Then
BadukAI will analyze the image immediately without showing the dialog
again.
</li>
</ul>
The second way is faster, but only possible if you know the image contents in
advance before seeing the image in the app (for example, if you will take a
photo of a board in front of you).
<p>
After you have loaded a position by detecting stones in an image, you can compare
the detected stones to the image by tapping "show img". The stones will be displayed
in red over the image. So, if there have been any detection errors, they can be easily
corrected by "add W stone", "add B stone" or "remove stone".
</p>
<h3 id="strength">How to adjust AI's strength for playing against it</h3>
<p>For KataGo you can</p>
<ul>
<li>
set the strength approximately to a human rank by using
<a href="#kyu-rank">kyu-rank</a> in settings
</li>
<li>experiment on your own by</li>
<ul>
<li>
loading a weaker network from your storage by tapping on the second
field in settings
</li>
<li>
reduce the amount of analysis by reducing "seconds/move" in manage time settings
</li>
<li>
reduce the amount of analysis even further by setting "maxPlayouts" to a
small number via "Edit config" in settings
</li>
</ul>
</ul>
<p>For LeelaZero you can</p>
<ul>
<li>
reduce the amount of analysis by reducing "seconds/move" in manage time settings
</li>
<li>
reduce the amount of analysis even further by setting "maxPlayouts" to a
small number via "Edit config" in settings
</li>
</ul>
<hr />
<p>If you encounter any problems, please let me know ...</p>
<p><a href="mailto:[email protected]">Andreas Kirmse</a></p>
</body>