update katago and merge

This commit is contained in:
Sander Land committed 2020-04-12 13:11:14 +02:00
commit 96e8fc2080
10 files changed
+121 -387

No files matched your search

+4
View File
@@ -9,6 +9,10 @@ log.txt
*.sgf
sgfout
my
# debug
outdated_log.txt
# too big
models/b20*.gz
+4 -4
View File
@@ -1,4 +1,4 @@
KataGo v1.3.3
KataGo v1.3.5
https://github.com/lightvector/KataGo
-----------------------------------------------------
@@ -7,7 +7,7 @@ USAGE:
FIRST:
Run this to make sure KataGo is working, with a neural net file.
katago.exe benchmark -model <NEURALNET>.bin.gz -config gtp_example.cfg
katago.exe benchmark -model <NEURALNET>.bin.gz
(download neural nets here if you don't have one: https://d3dndmfyhecmj0.cloudfront.net/g170/neuralnets/index.html)
On OpenCL, it should also cause KataGo to tune for your GPU. Then, the benchmark will report stats about speed and threads. You can configure gtp_example.cfg to use that many numSearchThreads to get good performance.
@@ -19,7 +19,7 @@ katago.exe genconfig -model <NEURALNET>.bin.gz -output gtp_custom.cfg
NEXT:
This command will run the KataGo engine proper. Feed this command to any program GUI program to launch KataGo's engine:
katago.exe gtp -model <NEURALNET>.bin.gz -config gtp_example.cfg
katago.exe gtp -model <NEURALNET>.bin.gz
Or if you generated a config yourself:
katago.exe gtp -model <NEURALNET>.bin.gz -config gtp_custom.cfg
@@ -40,6 +40,6 @@ Extensive testing across different OSs and versions and compilers has not been d
-----------------------------------------------------
TUNING FOR PERFORMANCE:
You will very likely want to tune some of the parameters in `gtp_example.cfg` for your system for good performance, including the number of threads, fp16 usage (CUDA only), NN cache size, pondering settings, and so on. You can also adjust things like KataGo's resign threshold or utility function. Most of the relevant parameters should be be reasonably well documented directly inline in that config.
You will very likely want to tune some of the parameters in `default_gtp.cfg` for your system for good performance, including the number of threads, fp16 usage (CUDA only), NN cache size, pondering settings, and so on. You can also adjust things like KataGo's resign threshold or utility function. Most of the relevant parameters should be be reasonably well documented directly inline in that config.
There are other a few notes about usage and performance at : https://github.com/lightvector/KataGo
+80 -64
View File
@@ -30,7 +30,7 @@ reportAnalysisWinratesAs = BLACK
# Make the bot never assume that its pass will end the game, even if passing would end and "win" under Tromp-Taylor rules.
# Usually this is a good idea when using it for analysis or playing on servers where scoring may be implemented non-tromp-taylorly.
# Defaults to true! Uncomment and set to false to disable this.
conservativePass = true
# conservativePass = true
# When using territory scoring, self-play games continue beyond two passes with special cleanup
# rules that may be confusing for human players. This option prevents the special cleanup phases from being
@@ -55,7 +55,7 @@ maxVisits = 500
# number of visits, and thread contention will reduce efficiency, so cross-position parallelization is preferable
# to numSearchThreads, but numSearchThreads is preferable if you want to reduce latency, and have individual
# searches complete faster by doing fewer of them at a time.
numSearchThreads = 2
numSearchThreads = 1
# GPU Settings-------------------------------------------------------------------------------
@@ -68,110 +68,126 @@ nnMutexPoolSizePowerOfTwo = 17
# Randomize board orientation when running neural net evals?
nnRandomize = true
# How many threads should there be to feed positions to the neural net?
# Server threads are indexed 0,1,...(n-1) for the purposes of the below GPU settings arguments
# that specify which threads should use which GPUs.
# NOTE: This parameter is probably ONLY useful if you have multiple GPUs, since each GPU will need a thread.
# If you're tuning single-GPU performance, use numSearchThreads instead.
numNNServerThreadsPerModel = 1
# TO USE MULTIPLE GPUS:
# Set this to the number of GPUs you have and/or would like to use...
# AND if it is more than 1, uncomment the appropriate CUDA or OpenCL section below.
# numNNServerThreadsPerModel = 1
# CUDA GPU settings--------------------------------------
# These only apply when using CUDA as the backend for inference.
# (For GTP, we only ever have one model, when playing matches, we might have more than one, see match_example.cfg)
# These only apply when using the CUDA version of KataGo.
# Default behavior tries to guess the 'best' GPU or device
# You will want to uncomment and adjust one or more of these lines to take advantage of a multi-gpu machine
# cudaDeviceToUse = 0 #use device 0 for all server threads (numNNServerThreadsPerModel) unless otherwise specified per-model or per-thread-per-model
# cudaDeviceToUseModel0 = 3 #use device 3 for model 0 for all threads unless otherwise specified per-thread for this model
# cudaDeviceToUseModel1 = 2 #use device 2 for model 1 for all threads unless otherwise specified per-thread for this model
# cudaDeviceToUseModel0Thread0 = 3 #use device 3 for model 0, server thread 0
# cudaDeviceToUseModel0Thread1 = 2 #use device 2 for model 0, server thread 1
# IF USING ONE GPU: optionally uncomment and change this if the GPU you want to use turns out to be not device 0
# cudaDeviceToUse = 0
# IF USING TWO GPUS: Uncomment these two lines (AND set numNNServerThreadsPerModel above):
# cudaDeviceToUseThread0 = 0 # change this if the first GPU you want to use turns out to be not device 0
# cudaDeviceToUseThread1 = 1 # change this if the second GPU you want to use turns out to be not device 1
# IF USING THREE GPUS: Uncomment these three lines (AND set numNNServerThreadsPerModel above):
# cudaDeviceToUseThread0 = 0 # change this if the first GPU you want to use turns out to be not device 0
# cudaDeviceToUseThread1 = 1 # change this if the second GPU you want to use turns out to be not device 1
# cudaDeviceToUseThread2 = 2 # change this if the third GPU you want to use turns out to be not device 2
# You can probably guess the pattern if you have four, five, etc. GPUs.
# KataGo will automatically use FP16 or not based on the compute capability of your NVIDIA GPU. If you
# want to try to force a particular behavior though you can uncomment these lines and change them
# to "true" or "false". E.g. it's using FP16 but on your card that's giving an error, or it's not using
# FP16 but you think it should.
# cudaUseFP16 = auto
# cudaUseNHWC = auto
# Uncomment these on NVIDIA devices with FP16 tensor cores for probably a speedup, at the cost of introducing some precision loss in the nn calculation.
# cudaUseFP16 = true
# cudaUseNHWC = true
# OpenCL GPU settings--------------------------------------
# These only apply when using OpenCL as the backend for inference.
# (For GTP, we only ever have one model, when playing matches, we might have more than one, see match_example.cfg)
# Default behavior tries to guess the 'best' GPU or device
# You will want to uncomment and adjust one or more of these lines to take advantage of a multi-gpu machine
# openclDeviceToUse = 0 #use device 0 for all server threads (numNNServerThreadsPerModel) unless otherwise specified per-model or per-thread-per-model
# openclDeviceToUseModel0 = 3 #use device 3 for model 0 for all threads unless otherwise specified per-thread for this model
# openclDeviceToUseModel1 = 2 #use device 2 for model 1 for all threads unless otherwise specified per-thread for this model
# openclDeviceToUseModel0Thread0 = 3 #use device 3 for model 0, server thread 0
# openclDeviceToUseModel0Thread1 = 2 #use device 2 for model 0, server thread 1
# These only apply when using the OpenCL version of KataGo.
# Uncomment to tune OpenCL for every board size separately, rather than only the largest possible size
# openclReTunePerBoardSize = true
# IF USING ONE GPU: optionally uncomment and change this if the best device to use is guessed incorrectly.
# The default behavior tries to guess the 'best' GPU or device on your system to use, usually it will be a good guess.
# openclDeviceToUse = 0
# IF USING TWO GPUS: Uncomment these two lines and replace X and Y with the device ids of the devices you want to use.
# It might NOT be 0 and 1, some computers will have many OpenCL devices. You can see what the devices are when
# KataGo starts up - it should print or log all the devices it finds.
# (AND also set numNNServerThreadsPerModel above)
# openclDeviceToUseThread0 = X
# openclDeviceToUseThread1 = Y
# IF USING THREE GPUS: Uncomment these three lines and replace X and Y and Z with the device ids of the devices you want to use.
# It might NOT be 0 and 1 and 2, some computers will have many OpenCL devices. You can see what the devices are when
# KataGo starts up - it should print or log all the devices it finds.
# (AND also set numNNServerThreadsPerModel above)
# openclDeviceToUseThread0 = X
# openclDeviceToUseThread1 = Y
# openclDeviceToUseThread2 = Z
# You can probably guess the pattern if you have four, five, etc. GPUs.
# Root move selection and biases------------------------------------------------------------------------------
# Uncomment and edit any of the below values to change them from their default.
# Not all of these parameters are applicable to analysis, some are only used for actual play
# Temperature for the early game, randomize between chosen moves with this temperature
chosenMoveTemperatureEarly = 0.5
# chosenMoveTemperatureEarly = 0.5
# Decay temperature for the early game by 0.5 every this many moves, scaled with board size.
chosenMoveTemperatureHalflife = 19
# chosenMoveTemperatureHalflife = 19
# At the end of search after the early game, randomize between chosen moves with this temperature
chosenMoveTemperature = 0.10
# chosenMoveTemperature = 0.10
# Subtract this many visits from each move prior to applying chosenMoveTemperature
# (unless all moves have too few visits) to downweight unlikely moves
chosenMoveSubtract = 0
# chosenMoveSubtract = 0
# The same as chosenMoveSubtract but only prunes moves that fall below the threshold, does not affect moves above
chosenMovePrune = 1
# Use dirichlet noise for the root node policy?
rootNoiseEnabled = false
# Dirichlet noise alpha is set to this divided by number of legal moves. 10.83 produces an alpha of 0.03 on an empty 19x19 board.
rootDirichletNoiseTotalConcentration = 10.83
# Proportion of root policy that is noise
rootDirichletNoiseWeight = 0.25
# chosenMovePrune = 1
# Number of symmetries to sample (WITH replacement) and average at the root
rootNumSymmetriesToSample = 1
# rootNumSymmetriesToSample = 1
# Using LCB for move selection?
useLcbForSelection = true
# useLcbForSelection = true
# How many stdevs a move needs to be better than another for LCB selection
lcbStdevs = 5.0
# lcbStdevs = 5.0
# Only use LCB override when a move has this proportion of visits as the top move
minVisitPropForLCB = 0.15
# minVisitPropForLCB = 0.15
# Internal params------------------------------------------------------------------------------
# Uncomment and edit any of the below values to change them from their default.
# Scales the utility of winning/losing
winLossUtilityFactor = 1.0
# winLossUtilityFactor = 1.0
# Scales the utility for trying to maximize score
staticScoreUtilityFactor = 0.10
dynamicScoreUtilityFactor = 0.30
# staticScoreUtilityFactor = 0.10
# dynamicScoreUtilityFactor = 0.30
# Adjust dynamic score center this proportion of the way towards zero, capped at a reasonable amount.
dynamicScoreCenterZeroWeight = 0.20
dynamicScoreCenterScale = 0.75
# dynamicScoreCenterZeroWeight = 0.20
# dynamicScoreCenterScale = 0.75
# The utility of getting a "no result" due to triple ko or other long cycle in non-superko rulesets (-1 to 1)
noResultUtilityForWhite = 0.0
# noResultUtilityForWhite = 0.0
# The number of wins that a draw counts as, for white. (0 to 1)
drawEquivalentWinsForWhite = 0.5
# drawEquivalentWinsForWhite = 0.5
# Exploration constant for mcts
# adjusted from 0.9 / 0.6 to be more exploratory
cpuctExploration = 2
cpuctExplorationLog = 0.9
# cpuctExploration = 0.9
# cpuctExplorationLog = 0.4
# FPU reduction constant for mcts
fpuReductionMax = 0.2
rootFpuReductionMax = 0.1
# fpuReductionMax = 0.2
# rootFpuReductionMax = 0.1
# Use parent average value for fpu base point instead of point value net estimate
fpuUseParentAverage = true
# fpuUseParentAverage = true
# Amount to apply a downweighting of children with very bad values relative to good ones
valueWeightExponent = 0.5
# valueWeightExponent = 0.5
# Slight incentive for the bot to behave human-like with regard to passing at the end, filling the dame,
# not wasting time playing in its own territory, etc, and not play moves that are equivalent in terms of
# points but a bit more unfriendly to humans.
rootEndingBonusPoints = 0.5
# rootEndingBonusPoints = 0.5
# Make the bot prune useless moves that are just prolonging the game to avoid losing yet
rootPruneUselessMoves = true
# rootPruneUselessMoves = true
# How big to make the mutex pool for search synchronization
mutexPoolSize = 2048
# mutexPoolSize = 8192
# How many virtual losses to add when a thread descends through a node
numVirtualLossesPerThread = 1
# numVirtualLossesPerThread = 1
BIN
View File
Binary file not shown.
-305
View File
@@ -1,305 +0,0 @@
# Example config for C++ (non-python) gtp bot
# RUNNING ON AN ONLINE SERVER OR IN A REAL TOURNAMENT OR MATCH:
# If you plan to do so, you may want to read through the "Rules" section
# below carefully for proper handling of komi and handicap games and end-of-game cleanup
# and various other details.
# NOTES ABOUT PERFORMANCE AND MEMORY USAGE:
# You will likely want to tune one or more the following:
#
# numSearchThreads:
# The number of CPU threads to use. If your GPU is powerful, it can actually be much higher than
# the number of cores on your processor because you will need many threads to feed large enough
# batches to make good use of the GPU.
#
# The "./katago benchmark" command can help you tune this parameter, as well as to test out the effect
# of changes to any of the other parameters below!
#
# nnMaxBatchSize:
# The maximum GPU batch size. Should often be at least as large as numSearchThreads.
# Larger won't do anything, but also won't hurt except use a little bit more GPU memory.
# Smaller can be fine if you have more than one GPU, since the GPUs will be sharing the work
# of servicing the CPU threads.
#
# cudaUseFP16 and cudaUseNHWC:
# These have a good chance of improving peformance at larger threads/batch sizes if
# you are using the CUDA implementation with an NVIDIA GPU with FP16 tensor cores.
#
# nnCacheSizePowerOfTwo:
# This controls the NN Cache size, which is the primary RAM/memory use.
# Increase this if you don't mind the memory use and want better performance for searches with
# tens of thousands of visits or more. Decrease this if you want to limit memory usage.
#
# If you're someone who is happy to do a bit of math - each neural net entry takes very
# approximately 1.5KB, except when using whole-board ownership/territory visualizations, each
# entry will take very approximately 3KB. The number of entries is (2 ** nnCacheSizePowerOfTwo),
# for example 2 ** 18 = 262144.
#
# OTHER NOTES:
# If you have more than one GPU, take a look at "OpenCL GPU settings" or "CUDA GPU settings" below.
#
# If using OpenCL, you will want to verify that KataGo is picking up the correct device!
# (e.g. some systems may have both an Intel CPU OpenCL and GPU OpenCL, if KataGo appears to pick
# the wrong one, you correct this by specifying "openclGpuToUse" below).
#
# You may also want to adjust "maxVisits", "ponderingEnabled", "resignThreshold", and possibly
# other parameters depending on your intended usage.
# Logs------------------------------------------------------------------------------------
# Where to output log?
logFile = gtp.log
# Logging options
logAllGTPCommunication = true
logSearchInfo = true
logToStderr = false
# KataGo will display some info to stderr on GTP startup
# Uncomment this to suppress that and remain silent
# startupPrintMessageToStderr = false
# Chat some stuff to stderr, for use in things like malkovich chat to OGS.
# ogsChatToStderr = true
# Configure the maximum length of analysis printed out by lz-analyze and other places.
# Controls the number of moves after the first move in a variation.
# analysisPVLen = 9
# Report winrates for chat and analysis as (BLACK|WHITE|SIDETOMOVE).
# Default is SIDETOMOVE, which is what tools that use LZ probably also expect
# reportAnalysisWinratesAs = SIDETOMOVE
# Default rules------------------------------------------------------------------------------------
# See https://lightvector.github.io/KataGo/rules.html for a description of the rules.
# These rules are defaults and can be changed mid-run by several custom GTP commands.
# See https://github.com/lightvector/KataGo/blob/master/docs/GTP_Extensions.md for those commands.
koRule = SIMPLE # Simple ko rules (triple ko = no result)
# koRule = POSITIONAL # Positional superko
# koRule = SITUATIONAL # Situational superko
# scoringRule = AREA # Area scoring
scoringRule = TERRITORY # Territory scoring (uses a sort of special computer-friendly territory ruleset)
# taxRule = NONE # All surrounded empty points are scored
taxRule = SEKI # Eyes in seki do NOT count as points
# taxRule = ALL # All groups are taxed up to 2 points for the two eyes needed to live
multiStoneSuicideLegal = false #Is multiple-stone suicide legal? (Single-stone suicide is always illegal).
hasButton = false # Set to true when area scoring to award 0.5 points to the first pass.
whiteHandicapBonus = 0 # In handicap games, give white no compensation for black's handicap stones (Tromp-taylor, NZ, JP)
# whiteHandicapBonus = N-1 # In handicap games, give white N-1 points for black's handicap stones (AGA)
# whiteHandicapBonus = N # In handicap games, give white N points for black's handicap stones (Chinese)
# Bot behavior---------------------------------------------------------------------------------------
# Resignation -------------
# Resignation occurs if for at least resignConsecTurns in a row,
# the winLossUtility (which is on a [-1,1] scale) is below resignThreshold.
allowResignation = true
resignThreshold = -0.999
resignConsecTurns = 3
# Handicap -------------
# Assume that if black makes many moves in a row right at the start of the game, then the game is a handicap game.
# This is necessary on some servers and for some GUIs and also when initializing from many SGF files, which may
# set up a handicap games using repeated GTP "play" commands for black rather than GTP "place_free_handicap" commands.
# However, it may also lead to incorrect understanding of komi if whiteHandicapBonus is used and a server does NOT
# have such a practice.
# Defaults to true! Uncomment and set to false to disable this behavior.
# assumeMultipleStartingBlackMovesAreHandicap = true
# Makes katago dynamically adjust to play more aggressively in handicap games based on the handicap and the current state of the game.
# Comment to disable this and make KataGo play the same always.
dynamicPlayoutDoublingAdvantageCapPerOppLead = 0.04
# Instead of setting dynamicPlayoutDoublingAdvantageCapPerOppLead, you can uncomment these and set this to a value from -2.0 to 2.0
# to set KataGo's aggression to a FIXED level.
# Negative makes KataGo behave as if it is much weaker than the opponent, preferring to play defensively
# Positive makes KataGo behave as if it is much stronger than the opponent, prefering to play aggressively or even overplay slightly.
# playoutDoublingAdvantage = 0.0
# Controls which side dynamicPlayoutDoublingAdvantageCapPerOppLead or playoutDoublingAdvantage applies to.
playoutDoublingAdvantagePla = WHITE
# Passing and cleanup -------------
# Make the bot never assume that its pass will end the game, even if passing would end and "win" under Tromp-Taylor rules.
# Usually this is a good idea when using it for analysis or playing on servers where scoring may be implemented non-tromp-taylorly.
# Defaults to true! Uncomment and set to false to disable this.
# conservativePass = true
# When playing under territory scoring, encourage the bot to fill dame before passing.
# This is NOT absolutely guaranteed to work, and possibly in some rare pathological situations will make the bot
# play a bad move, losing points. However, it also acts as a safeguard against things like a situation when the opponent must
# eventually make a protective move and lose 1 point, where the bot might otherwise assume that the score would be counted as such,
# yet without filling the dame to force the opponent to actually make the move.
# Defaults to true! Uncomment and set to false to disable this.
# fillDameBeforePass = true
# When using territory scoring, self-play games continue beyond two passes with special cleanup
# rules that may be confusing for human players. This option prevents the special cleanup phases from being
# reachable when using the bot for GTP play.
# Defaults to true! Uncomment and set to false if you want KataGo to be able to enter special cleanup.
# For example, if you are testing it against itself, or against another bot that has precisely implemented the rules
# documented at https://lightvector.github.io/KataGo/rules.html
# preventCleanupPhase = true
# Search limits-----------------------------------------------------------------------------------
# If provided, limit maximum number of root visits per search to this much. (With tree reuse, visits do count earlier search)
maxVisits = 2500
# If provided, limit maximum number of new playouts per search to this much. (With tree reuse, playouts do not count earlier search)
# maxPlayouts = 300
# If provided, cap search time at this many seconds (search will still try to follow GTP time controls)
# maxTime = 60
# Ponder on the opponent's turn?
ponderingEnabled = false
# Same limits but for ponder searches if pondering is enabled
# maxVisitsPondering = 1000
# maxPlayoutsPondering = 1000
# maxTimePondering = 60
# Number of seconds to buffer for lag for GTP time controls
lagBuffer = 1.0
# Number of threads to use in search
numSearchThreads = 4
# Play a little faster if the opponent is passing, for friendliness
searchFactorAfterOnePass = 0.50
searchFactorAfterTwoPass = 0.25
# Play a little faster if super-winning, for friendliess
searchFactorWhenWinning = 0.40
searchFactorWhenWinningThreshold = 0.95
# GPU Settings-------------------------------------------------------------------------------
# Maximum number of positions to send to GPU at once. Note that you will also need to increase numSearchThreads
# to make use of this, as every thread in KataGo is synchronous, so with 1 thread max batch will only be 1 anyways.
nnMaxBatchSize = 16
# Cache up to 2 ** this many neural net evaluations in case of transpositions in the tree.
nnCacheSizePowerOfTwo = 20
# Size of mutex pool for nnCache is 2 ** this
nnMutexPoolSizePowerOfTwo = 16
# Randomize board orientation when running neural net evals?
nnRandomize = true
# If provided, force usage of a specific seed for nnRandomize instead of randomizing
# nnRandSeed = abcdefg
# How many threads should there be to feed positions to the neural net?
# Server threads are indexed 0,1,...(n-1) for the purposes of the below GPU settings arguments
# that specify which threads should use which GPUs.
# NOTE: This parameter is probably ONLY useful if you have multiple GPUs, since each GPU will need a thread.
# If you're tuning single-GPU performance, use numSearchThreads instead.
numNNServerThreadsPerModel = 1
# CUDA GPU settings--------------------------------------
# These only apply when using CUDA as the backend for inference.
# (For GTP, we only ever have one model, when playing matches, we might have more than one, see match_example.cfg)
# Default behavior tries to guess the 'best' GPU or device
# You will want to uncomment and adjust one or more of these lines to take advantage of a multi-gpu machine
# cudaDeviceToUse = 0 #use device 0 for all server threads (numNNServerThreadsPerModel) unless otherwise specified per-model or per-thread-per-model
# cudaDeviceToUseModel0 = 3 #use device 3 for model 0 for all threads unless otherwise specified per-thread for this model
# cudaDeviceToUseModel1 = 2 #use device 2 for model 1 for all threads unless otherwise specified per-thread for this model
# cudaDeviceToUseModel0Thread0 = 3 #use device 3 for model 0, server thread 0
# cudaDeviceToUseModel0Thread1 = 2 #use device 2 for model 0, server thread 1
# Uncomment these on NVIDIA devices with FP16 tensor cores for probably a speedup, at the cost of introducing some precision loss in the nn calculation.
# cudaUseFP16 = true
# cudaUseNHWC = true
# OpenCL GPU settings--------------------------------------
# These only apply when using OpenCL as the backend for inference.
# (For GTP, we only ever have one model, when playing matches, we might have more than one, see match_example.cfg)
# Default behavior tries to guess the 'best' GPU or device
# You will want to uncomment and adjust one or more of these lines to take advantage of a multi-gpu machine
# openclDeviceToUse = 0 #use device 0 for all server threads (numNNServerThreadsPerModel) unless otherwise specified per-model or per-thread-per-model
# openclDeviceToUseModel0 = 3 #use device 3 for model 0 for all threads unless otherwise specified per-thread for this model
# openclDeviceToUseModel1 = 2 #use device 2 for model 1 for all threads unless otherwise specified per-thread for this model
# openclDeviceToUseModel0Thread0 = 3 #use device 3 for model 0, server thread 0
# openclDeviceToUseModel0Thread1 = 2 #use device 2 for model 0, server thread 1
# Uncomment to tune OpenCL for every board size separately, rather than only the largest possible size
# openclReTunePerBoardSize = true
# Root move selection and biases------------------------------------------------------------------------------
# If provided, force usage of a specific seed for various things in the search instead of randomizing
# searchRandSeed = hijklmn
# Temperature for the early game, randomize between chosen moves with this temperature
chosenMoveTemperatureEarly = 0.5
# Decay temperature for the early game by 0.5 every this many moves, scaled with board size.
chosenMoveTemperatureHalflife = 19
# At the end of search after the early game, randomize between chosen moves with this temperature
chosenMoveTemperature = 0.10
# Subtract this many visits from each move prior to applying chosenMoveTemperature
# (unless all moves have too few visits) to downweight unlikely moves
chosenMoveSubtract = 0
# The same as chosenMoveSubtract but only prunes moves that fall below the threshold, does not affect moves above
chosenMovePrune = 1
# Use dirichlet noise for the root node policy?
rootNoiseEnabled = false
# Dirichlet noise alpha is set to this divided by number of legal moves. 10.83 produces an alpha of 0.03 on an empty 19x19 board.
rootDirichletNoiseTotalConcentration = 10.83
# Proportion of root policy that is noise
rootDirichletNoiseWeight = 0.25
# Number of symmetries to sample (WITH replacement) and average at the root
rootNumSymmetriesToSample = 1
# Using LCB for move selection?
useLcbForSelection = true
# How many stdevs a move needs to be better than another for LCB selection
lcbStdevs = 5.0
# Only use LCB override when a move has this proportion of visits as the top move
minVisitPropForLCB = 0.15
# Internal params------------------------------------------------------------------------------
# Scales the utility of winning/losing
winLossUtilityFactor = 1.0
# Scales the utility for trying to maximize score
staticScoreUtilityFactor = 0.10
dynamicScoreUtilityFactor = 0.30
# Adjust dynamic score center this proportion of the way towards zero, capped at a reasonable amount.
dynamicScoreCenterZeroWeight = 0.20
dynamicScoreCenterScale = 0.75
# The utility of getting a "no result" due to triple ko or other long cycle in non-superko rulesets (-1 to 1)
noResultUtilityForWhite = 0.0
# The number of wins that a draw counts as, for white. (0 to 1)
drawEquivalentWinsForWhite = 0.5
# Exploration constant for mcts
cpuctExploration = 0.9
cpuctExplorationLog = 0.6
# FPU reduction constant for mcts
fpuReductionMax = 0.2
rootFpuReductionMax = 0.1
# Use parent average value for fpu base point instead of point value net estimate
fpuUseParentAverage = true
# Amount to apply a downweighting of children with very bad values relative to good ones
valueWeightExponent = 0.5
# Slight incentive for the bot to behave human-like with regard to passing at the end, filling the dame,
# not wasting time playing in its own territory, etc, and not play moves that are equivalent in terms of
# points but a bit more unfriendly to humans.
rootEndingBonusPoints = 0.5
# Make the bot prune useless moves that are just prolonging the game to avoid losing yet
rootPruneUselessMoves = true
# How big to make the mutex pool for search synchronization
mutexPoolSize = 8192
# How many virtual losses to add when a thread descends through a node
numVirtualLossesPerThread = 1
+3 -3
View File
@@ -30,11 +30,11 @@ Installation for Linux/Mac users
* This assumed you have a working Python 3.6/3.7 installation as a default. If your default is python 2, use pip3/python3. Kivy currently does not have a release for Python 3.8.
* Git clone or download the repository.
* pip install kivy
* Put your katago binary in the `KataGo/` directory or change the `engine.command` field in `config.json` to your KataGo v1.3+ binary.
* Put your KataGo binary in the `KataGo/` directory or change the `engine.command` field in `config.json` to your KataGo v1.3.5+ binary.
* Compiled binaries and source code can be found [here](https://github.com/lightvector/KataGo/releases).
* You will need to `chmod +x katago` your binary if your download it.
* You will need to `chmod +x katago` your binary if you downloaded it.
* Executables for Mac are not available, so compiling from source code is required there.
* Start the app by running `python katrain.py`. Note that the program can be slow to initialize the first time, due to kata's gpu tuning.
* Start the app by running `python katrain.py`. Note that the program can be slow to initialize the first time, due to KataGo's GPU tuning.
Options
-------
-3
View File
@@ -112,9 +112,6 @@ class Move:
outdated_evaluation, outdated_details = self.outdated_evaluation
if outdated_evaluation and outdated_evaluation > self.evaluation and outdated_evaluation > self.evaluation + 0.05:
text += f"(Was considered last move as {outdated_evaluation:.0%})\n"
if outdated_evaluation > self.evaluation + 0.15:
with open("outdated_log.txt", "a") as f:
f.write(f"logs.append({repr(outdated_details)})\n")
points_lost = self.player_sign * (prev_best_score - score)
if points_lost > 0.5:
text += f"Estimated point loss: {points_lost:.1f}\n"
+22 -8
View File
@@ -52,6 +52,7 @@ class EngineControls(GridLayout):
self.outstanding_analysis_queries = [] # allows faster interaction while kata is starting
self.kata = None
self.query_time = {}
self.game_counter = 0
def show_error(self, msg):
print(f"ERROR: {msg}")
@@ -96,7 +97,7 @@ class EngineControls(GridLayout):
raise
msg, *args = self.message_queue.get()
def play(self, move, faster=False):
def play(self, move, faster=False, analysis_priority=None):
try:
mr = self.board.play(move)
except IllegalMoveException as e:
@@ -104,7 +105,7 @@ class EngineControls(GridLayout):
return
self.update_evaluation()
if not mr.analysis_ready: # replayed old move
self._request_analysis(mr, faster=faster)
self._request_analysis(mr, faster=faster, priority=self.game_counter if analysis_priority is None else analysis_priority)
return mr
def show_evaluation_stats(self, move):
@@ -217,10 +218,11 @@ class EngineControls(GridLayout):
self.update_evaluation()
def _do_init(self, board_size, komi=None):
self.game_counter += 1 # prioritize newer games
self.board_size = board_size
self.komi = float(komi or Config.get("board").get(f"komi_{board_size}", 6.5))
self.board = Board(board_size)
self._request_analysis(self.board.root)
self._request_analysis(self.board.root, priority=self.game_counter)
self.redraw(include_board=True)
self.ready = True
if self.ai_lock.active:
@@ -246,19 +248,22 @@ class EngineControls(GridLayout):
self.info.text = "Wait for initial analysis to complete before doing a board-sweep or refinement"
return
played_moves = self.board.moves
if mode == "extra":
visits = sum([d["visits"] for d in current_move.analysis]) + self.visits[0][1]
self.info.text = f"Performing additional analysis to {visits} visits"
self._request_analysis(current_move, visits=visits)
self._request_analysis(current_move, visits=visits,priority=self.game_counter - 1_000)
return
elif mode == "sweep":
analyze_moves = [Move(coords=(x, y)).gtp() for x in range(self.board_size) for y in range(self.board_size) if (x, y) not in stones]
visits = self.visits[self.ai_fast.active][2]
self.info.text = f"Refining analysis of entire board to {visits} visits"
priority = self.game_counter - 1_000_000_000
else: # mode=='refine':
analyze_moves = [a["move"] for a in current_move.analysis]
visits = current_move.analysis[0]["visits"] + self.visits[1][2]
self.info.text = f"Refining analysis of candidate moves to {visits} visits"
priority = self.game_counter - 1_000
for gtpcoords in analyze_moves:
self._send_analysis_query(
@@ -267,6 +272,7 @@ class EngineControls(GridLayout):
"moves": [[m.bw_player(), m.gtp()] for m in played_moves] + [[current_move.bw_player(True), gtpcoords]],
"includeOwnership": False,
"maxVisits": visits,
"priority": priority,
}
)
@@ -300,16 +306,18 @@ class EngineControls(GridLayout):
if handicap and not "AB" in sgfprops:
self.board.place_handicap_stones(handicap)
analysis_priority = self.game_counter - 1_000_000
placements = [Move(player=pl, sgfcoords=(mv, self.board_size)) for pl, player in enumerate(Move.PLAYERS) for mv in sgfprops.get("A" + player, [])]
for placement in placements: # free handicaps
self.board.play(placement) # bypass analysis
if handicap or placements:
self._request_analysis(self.board.current_move) # ensure next move analysis works
self._request_analysis(self.board.current_move, priority=analysis_priority) # ensure next move analysis works
moves = [Move(player=Move.PLAYERS.index(p.upper()), sgfcoords=(mv, self.board_size)) for p, mv in sgfmoves]
for move in moves:
self.play(move, faster=faster and move != moves[-1])
self.play(move, faster=faster and move != moves[-1], analysis_priority=analysis_priority)
if rewind:
self.board.rewind()
@@ -345,12 +353,18 @@ class EngineControls(GridLayout):
else: # early on / root / etc
self.outstanding_analysis_queries.append(copy.copy(query))
def _request_analysis(self, move, faster=False, visits=0):
def _request_analysis(self, move, faster=False, visits=0, priority=0):
faster_fac = 5 if faster else 1
move_id = move.id
moves = self.board.moves
fast = self.ai_fast.active
query = {"id": str(move_id), "moves": [[m.bw_player(), m.gtp()] for m in moves], "includeOwnership": True, "maxVisits": max(visits, self.visits[fast][1] // faster_fac)}
query = {
"id": str(move_id),
"moves": [[m.bw_player(), m.gtp()] for m in moves],
"includeOwnership": True,
"maxVisits": max(visits, self.visits[fast][1] // faster_fac),
"priority": priority,
}
if self.debug:
print(f"sending query for move {move_id}: {str(query)[:80]}")
self._send_analysis_query(query)
+4
View File
@@ -165,6 +165,8 @@
ai_auto: ai_auto
ai_fast: ai_fast
ai_lock: ai_lock
load: load
save: save
auto_undo: auto_undo
undo: undo
ai_move: ai_move
@@ -269,10 +271,12 @@
size_hint: 1, 0.05
StyledButton:
text: 'Save'
id: save
size_hint: 0.5, 1
on_press: info.text = root.output_sgf()
StyledButton:
text: 'Load'
id: load
size_hint: 0.5, 1
on_press: root.action("analyze-sgf",info.text)
GridLayout:
+4
View File
@@ -238,6 +238,10 @@ class KaTrainGui(BoxLayout):
self.controls.ai_balance.label.trigger_action(duration=0)
elif keycode[1] == "o":
self.controls.ownership.label.trigger_action(duration=0)
elif keycode[1] == "l":
self.controls.load.trigger_action(duration=0)
elif keycode[1] == "k":
self.controls.save.trigger_action(duration=0)
return True