Merge branch 'low_mem' of github.com:sanderland/katrain into low_mem

This commit is contained in:
Sander Land committed 2020-05-06 22:37:41 +02:00
commit a7341adfe3
15 files changed
+13 -100

No files matched your search

BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+5 -2
View File
@@ -58,6 +58,7 @@ but has since grown to include a wide range of features, including:
## Manual
### Play
Under the 'play' tab you can select who is playing black and white.
* Human is simple play with potential feedback, but without auto-undo.
* Teach will give you instant feedback, and auto-undo bad moves to give you a second chance.
@@ -80,6 +81,7 @@ In short, if you are a weaker player you should mostly on large dots that are re
while stronger players can pay more attention to smaller mistakes.
#### AIs
Available AIs, with strength indicating an estimate for the default settings, are:
* **[9p+]** **Default** is full KataGo, above professional level.
@@ -115,7 +117,6 @@ Keyboard shortcuts are shown with **[key]**.
* **[s]**: Equalize: Re-evaluate all currently shown next moves with the same visits as the current top move. Useful to increase confidence in the suggestions with high uncertainty.
* **[d]**: Sweep: Evaluate all possible next moves. This can take a bit of time even though 'fast_visits' is used, but the result is nothing if not colourful.
## Keyboard and mouse shortcuts
In addition to shortcuts mentioned above, there are:
@@ -136,7 +137,6 @@ In addition to shortcuts mentioned above, there are:
* **[Ctrl-n]**: Load SGF from clipboard
* **[space]**: Pass
## Configuration
Configuration is stored in `config.json`. Most settings are now available to edit in the program, but some advanced options are not.
@@ -173,9 +173,12 @@ If you ever need to reset to the original settings, simply re-download the `conf
* The first startup of KataGo can be slow due to GPU tuning, after that it should be much faster.
* The program is running too slowly. How can I speed it up?
* Adjust the number of visits or maximum time allowed in the settings.
* KataGo crashes with out of memory errors, how can I prevent this?
* Try using a lower number for `nnMaxBatchSize` in `KataGo/analysis_config.cfg`, and avoid using the board size 29 version.
## Contributing
* Feedback and pull requests are both very welcome.
* For suggestions and planned improvements, see the 'issues' tab on github.
* You can also contact me on discord (Sander#3278) or [reddit](http://reddit.com/u/sanderbaduk) to give feedback, or simply show your appreciation.
+1 -1
View File
@@ -15,7 +15,7 @@ if True or bot in ["dev", "local"]:
else:
GTP2OGS = "node ../stable-gtp2ogs"
BOT_SETTINGS = f" --maxconnectedgames {MAXGAMES} --maxhandicapunranked 25 --maxhandicapranked 1 --boardsizesranked 19 --boardsizesunranked all --komisranked automatic,5.5,6.5,7.5 --komisunranked all"
if 'beta' in bot:
if "beta" in bot:
BOT_SETTINGS += " --beta"
else:
BOT_SETTINGS += "" # --rankedonly"
+2 -2
View File
@@ -1,9 +1,9 @@
{
"engine": {
"katago": "KataGo/katago-bs",
"katago": "KataGo/katago",
"model": "KataGo/models/b15-1.3.2.txt.gz",
"config": "KataGo/analysis_config.cfg",
"threads": 8,
"threads": 16,
"max_visits": 500,
"fast_visits": 50,
"max_time": 3.0,
+4 -4
View File
@@ -212,7 +212,7 @@ class SGFNode:
@property
def next_player(self):
if "B" in self.properties or "AB" in self.properties: # root or black moved
if "B" in self.properties or "AB" in self.properties: # root or black moved
return "W"
else:
return "B"
@@ -222,7 +222,7 @@ class SGFNode:
if "B" in self.properties or "AB" in self.properties:
return "B"
else:
return "W" # nb root is considered white played if no handicap stones are placed
return "W" # nb root is considered white played if no handicap stones are placed
class SGF:
@@ -239,10 +239,10 @@ class SGF:
if not encoding:
match = re.search(rb"CA\[(.*?)\]", bin_contents)
if match:
encoding = match[1].decode("ascii")
encoding = match[1].decode("ascii", errors="ignore")
else:
encoding = "ISO-8859-1" # default
decoded = bin_contents.decode(encoding=encoding)
decoded = bin_contents.decode(encoding=encoding, errors="ignore")
return cls.parse(decoded)
def __init__(self, contents):
+1
View File
@@ -179,6 +179,7 @@ class ConfigPopup(QuickConfigGui):
if not old_proc:
self.katrain.game.analyze_all_nodes() # old engine was broken, so make sure we redo any failures
self.katrain.update_state()
Clock.schedule_once(restart_engine, 0)
self.katrain.debug_level = self.config["debug"]["level"]
-42
View File
@@ -1,42 +0,0 @@
# This is a stand-alone script that generates a review for an SGF
import json
import sys
import time
from core.common import OUTPUT_INFO
from core.engine import KataGoEngine
from core.game import Game, KaTrainSGF
if len(sys.argv) < 2:
exit(1)
inputfile = sys.argv[1]
with open("config.json") as f:
settings = json.load(f)
sgf_settings = settings["sgf"]
engine_settings = settings["engine"]
game_settings = settings["game"]
trainer_settings = settings["trainer"]
#engine_settings['threads'] = 32
engine_settings["max_time"] = 1000
class Logger:
def log(self, msg, level):
if level <= OUTPUT_INFO:
print(msg)
logger = Logger()
engine = KataGoEngine(logger, engine_settings)
move_tree = KaTrainSGF.parse_file(inputfile)
game = Game(logger, engine, game_settings, move_tree=None, analyze_fast=True)
game.root=move_tree
reverse_nodes = game.root.nodes_in_tree[::-1]
for n in reverse_nodes[::10]:
n.analyze(engine=engine)
while not n.analysis_ready:
time.sleep(0.01)
print(n.single_move,'done')
-49
View File
@@ -1,49 +0,0 @@
# This is a stand-alone script that generates a review for an SGF
import json
import sys
import time
from core.common import OUTPUT_INFO
from core.engine import KataGoEngine
from core.game import Game, KaTrainSGF
if len(sys.argv) < 2:
exit(1)
inputfile = sys.argv[1]
with open("config.json") as f:
settings = json.load(f)
sgf_settings = settings["sgf"]
engine_settings = settings["engine"]
game_settings = settings["game"]
trainer_settings = settings["trainer"]
engine_settings['threads'] = 16
#engine_settings['katago'] = 'KataGo/katago-bs'
engine_settings["max_time"] = 1000
engine_settings["max_visits"] = 50
class Logger:
def log(self, msg, level):
if level <= OUTPUT_INFO:
print(msg)
logger = Logger()
engine = KataGoEngine(logger, engine_settings)
move_tree = KaTrainSGF.parse_file(inputfile)
game = Game(logger, engine, game_settings, move_tree=move_tree, analyze_fast=False)
nodes = game.root.nodes_in_tree
remaining = len(nodes)
while remaining > 0:
remaining = sum(not n.analysis_ready for n in nodes)
print(f"Waiting for {remaining} queries")
time.sleep(0.1)
msg = game.write_sgf(
sgf_settings["sgf_save"],
trainer_config=trainer_settings,
save_feedback=sgf_settings["save_feedback"],
eval_thresholds=trainer_settings["eval_thresholds"],
)