Comments (3)
Probably partly answered here? #788 (comment)
If your in-memory board state is an sgfmill board, then take the example code there verbatim, with any minor changes you want (e.g. changing query["rules"] = "Chinese"
if you want to use different rules), and once you've created the katago
object (which starts up KataGo's process), call
result = katago.query(board, moves, komi)
If you literally only have a board state, then you can have moves
be the empty list, but it's recommended to use move lists instead of just a board state because otherwise you can't tell if a ko capture is legal or not.
Then you can find the best move like:
sorted_move_infos = sorted(result["moveInfos"], key=lambda x: x["order"]) # sort moves considered by the search in order of most preferred to least preferred
best_move = sorted_move_infos[0]["move"]
And of course you can see a bunch of other stats about the moves in the move infos dicts.
from katago.
Full docs for what fields you can expect in the result
dict, as well as what other fields you can adjust on the query, are in https://github.com/lightvector/KataGo/blob/master/docs/Analysis_Engine.md
from katago.
Note that the example code at https://github.com/lightvector/KataGo/blob/master/python/query_analysis_engine_example.py is probably not the most robust in terms of handling warnings or errors returned by KataGo. Warnings and errors should be nonexistent for queries that are fully proper in the parameters they pass and don't contain illegal board states or illegal moves in the moves list, but it could still be improved a bit. I guess I should improve the example on that.
Also if you come up with any simple improvements for your own use case that you want to share, or there are any additions you think would make a big difference and want to share, feel free to share and I'd be happy to consider augmenting the example code to include them.
from katago.
Related Issues (20)
- Train a weight‘s weight, to predict the value of the next Katago weight HOT 3
- How to use Katago 1.14.1 with time cache? HOT 1
- Issue in training: low visit counts and strange initial conditions(board dimensions, komi settings, piece position) HOT 2
- kata-genmove_analyze with KEYVALUEPAIR not working HOT 1
- A problem building for CUDA HOT 1
- Why does lc0 ship cuda dlls with engine but katago doesn't?
- Minor document questions
- Error checks for kata-raw-human-nn HOT 1
- How to set rules to "twisted cross and eating" for beginner HOT 2
- Throwback HOT 3
- Lack of ability HOT 3
- Katago cannot give a definitive answer for the best move. HOT 2
- Report an error HOT 3
- allowResignation affects humanSL strength?? HOT 4
- Loose ladder
- katago 1.15.1 build failure
- Do you have a plan to create a GUI? HOT 3
- kata-analyze reports a non-human-like move for the preaz_20k human profile HOT 1
- Evaluate the value of moves HOT 2
- KataGo works with old libssl versions only HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from katago.