Git Product home page Git Product logo

Comments (3)

lightvector avatar lightvector commented on July 30, 2024

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.

lightvector avatar lightvector commented on July 30, 2024

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.

lightvector avatar lightvector commented on July 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.