飞扬围棋论坛

 找回密码
 注册
搜索
查看: 9880|回复: 3

如何用接口调用 leela的形势判断(拍照数子)

[复制链接]
发表于 2020-3-19 15:03 | 显示全部楼层 |阅读模式

leela 自带的形势判断(数目功能)如何用命令行调取呢,例如腾讯的形势判断和拍照数子功能
想要做到上传一张棋谱然后返回棋子的形势判断,终局的时候可以数目
想请飞扬的大神教下鄙人😊

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

 楼主| 发表于 2020-3-20 11:07 | 显示全部楼层
尝试一:利用sgftools工具进行分析

链接:https://bitbucket.org/mkmatlock/sgftools/src/default/

这个文档里没写有算分的介绍
但是我看python里有对应的test_score.py
下面是代码:
  1. from sgftools.gotools import Goban, import_sgf
  2. from sgftools.score import score
  3. import numpy as np
  4. import unittest

  5. def to_pattern(s):
  6.     pat = np.array([[int(c) for c in l.strip()] for l in s.split("\n")])
  7.     return pat.T


  8. class TestScoring(unittest.TestCase):
  9.     def test_score_unfinished(self):
  10.         sgf = import_sgf('test/data/test_9x9.sgf')
  11.         goban = Goban(sgf).perform_all()
  12.         position = goban.pattern()
  13.         black,white,occ = score(position)

  14.         coloring = to_pattern("""020000000
  15.                                  000221000
  16.                                  022211000
  17.                                  121100020
  18.                                  010012210
  19.                                  000002100
  20.                                  000122100
  21.                                  000121100
  22.                                  000020000""")
  23.         self.assertEqual(black, 15)
  24.         self.assertEqual(white, 15)
  25.         np.testing.assert_array_almost_equal(occ, coloring)

  26.     def test_score_with_uncaptured(self):
  27.         sgf = import_sgf('test/data/test_9x9_finished_with_stones.sgf')
  28.         goban = Goban(sgf).perform_all()
  29.         position = goban.pattern()
  30.         black,white,occ = score(position)

  31.         coloring = to_pattern("""220021112
  32.                                  221221122
  33.                                  222211222
  34.                                  121112222
  35.                                  111112212
  36.                                  111112111
  37.                                  111122100
  38.                                  222121122
  39.                                  222221110""")
  40.         self.assertEqual(black, 37)
  41.         self.assertEqual(white, 39)
  42.         np.testing.assert_array_almost_equal(occ, coloring)


  43.     def test_score(self):
  44.         sgf = import_sgf('test/data/test_9x9_finished.sgf')
  45.         goban = Goban(sgf).perform_all()
  46.         position = goban.pattern()
  47.         black,white,occ = score(position)

  48.         coloring = to_pattern("""222221112
  49.                                  222221122
  50.                                  222211222
  51.                                  121112222
  52.                                  111112212
  53.                                  111112111
  54.                                  111122111
  55.                                  222121111
  56.                                  222221111""")
  57.         self.assertEqual(black, 41)
  58.         self.assertEqual(white, 40)
  59.         np.testing.assert_array_almost_equal(occ, coloring)
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-20 13:56 | 显示全部楼层
houroad 发表于 2020-3-20 11:07
尝试一:利用sgftools工具进行分析

链接:https://bitbucket.org/mkmatlock/sgftools/src/default/

方法一结果:失败原因:sgftools可以对棋谱进行分析,得出leela的下发

但是,只想要数子的结果,虽然有score.py 但是调用不起来,文档也没有介绍
倒是有一个sgf2pdf文件,可以把sgf转换成pdf格式
就太鸡肋了,因为我用canvas的绘图也可以转成png格式等
。。。
这种方法就先搁置了,对python不是太了解,并不能看懂score.py中的意思

等我咨询python的朋友后,再来验证这种方法的可行性
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-20 13:57 | 显示全部楼层
方法二:搭建GTP协议平台利用leela进行下棋和计算得分
GTP文档链接:http://www.lysator.liu.se/~gunnar/gtp/
  1. GTP - Go Text Protocol
  2. The Go Text Protocol, GTP, is a text based protocol for communication with computer go programs. It is a modern alternative to the Go Modem Protocol, GMP, and may potentially replace this for use in Go tournaments in the future. It is also intended, through the use of auxiliary programs, to make it easier for go programmers to connect to go servers on the internet and do automatic regression testing.

  3. Current Status
  4. GTP version 1 has been implemented in GNU Go 3.0.0 but the protocol lacks a proper specification. Work is going on to create such a specification for the revised version 2 of GTP.

  5. Mailing List
  6. Discussion about the protocol is taking place on a dedicated mailing list. Follow the link for subscription information and an online archive.

  7. Working Documents
  8. Working documents for the specification of GTP version 2.
  9. New GTP Version 2 Specification Draft, by Gunnar Farnebäck
  10. Revision 2, October 12, 2002
  11. HTML
  12. Postscript
  13. PDF
  14. LaTeX source
  15. Diff of LaTeX source from draft 1 to draft 2
  16. GTP Goals, version 4, by Bill Shubert
  17. Old documents.
  18. Frequently Asked Questions
  19. FAQ
  20. Reference engine code
  21. Reference application code
  22. Sample engine code
  23. This is sample code implementing the engine end of the protocol. Unless otherwise stated, no guarantees are given that the code correctly implements any particular revision of the protocol.
  24. The GNU Go 3.0.0 implementation of GTP is split in three C files: gtp.c, gtp.h, play_gtp.c. The first two contain the generic parts of the code and are available to other programmers for any use. The third file contains code specific to the GNU Go engine and is licensed under the GNU GPL. This is the reference implementation for version 1 of the protocol. Written by Gunnar Farnebäck with help from Daniel Bump and others in the GNU Go development team.
  25. User interfaces
  26. Programs letting a human interact with an engine.
  27. GoGui is a Java client compliant with GTP versions 1 and 2. It also contains a collection of GTP tools for automatic game play, networking, regression testing and more. Licensed under the GNU GPL. Written by Markus Enzenberger.
  28. gGo is a Java client compliant with GTP version 1. It is available free of charge but without source. An older version was distributed under the GNU GPL. Written by Peter Strempel.
  29. Goban is a client for Mac OS X, compliant with GTP version 1. It is available free of charge but without source. There is also a version called FreeGoban, which is distributed under the GNU GPL. Written by Sente Software.
  30. Goben is a client written in C using GTK libraries for graphics. Compliant with GTP versions 1 and 2. Licensed under the GNU GPL. Written by Wayne Myers.
  31. Engine vs. engine applications
  32. Programs to automatically play engines against each other.
  33. twogtp is a perl script for playing two engines against each other. This is distributed with GNU Go. Licensed under the GNU GPL. Written by Teun Burgers and Daniel Bump.
  34. 2ptkgo.pl is another perl script similar to twogtp, but additionally providing a graphical display. This is also distributed with GNU Go. Running it requires perltk and ttgo.pm. Licensed under the GNU GPL. Written by Don Dailey.
  35. twogtp.py is a python script for playing two engines against each other. More feature rich than twogtp. Licensed under the GNU GPL. Written by Inge Wallin and other GNU Go developers.
  36. twogtp.pike is a pike script for playing two engines against each other. This is also distributed with GNU Go and is even more feature rich than twogtp.py. Licensed under the GNU GPL. Written by Paul Pogonyshev and Gunnar Farnebäck.
  37. Server clients
  38. Programs to connect engines to various servers.
  39. gnugoclient is a program which can be used to connect go engines to NNGS and compatible servers. Gnugoclient 3.0 uses version 2 of the protocol and is known to work with at least GNU Go 3.4 and Brown 1.0. Licensed under the GNU GPL. Written by Gunnar Farnebäck.
  40. gtpclient.c is another program to connect go engines to NNGS or IGS. This program is written in C and is so far more limited in functionality than gnugoclient. Written by Tristan Cazenave.
  41. kgsGtp connects GTP version 2 engines to KGS. Written in Java and distributed without source code. Author is Bill Shubert.
  42. Engines
  43. GTP aware engines (i.e. go programs).
  44. GNU Go has had GTP support since development version 2.7.95 and full GTP version 1 support since stable release 3.0.0. GTP version 2 is supported since development version 3.3.10.
  45. Aya supports GTP version 2 since version 5.28, released January 23, 2004.
  46. Indigo supports GTP version 2 since the 2004 release.
  47. Brown is a simple random player with support for GTP version 2.
  48. Andrew Balsa has written C++ versions, with GTP version 2 support, of a number of free older programs. Unfortunately the GTP imlementations are fairly buggy and do not follow the specification well at all.
  49. wallyplus
  50. amigoplus
  51. badukiplus
  52. randyplus
  53. Regression test suites
  54. Collections of test problems in GTP format.
  55. GNU Go contains a big test suite in the regressions directory. Most of the tests use the standardized reg_genmove command but some of them use more specialized private extension commands. Compiled by the entire GNU Go development team.
  56. Computer Go Test Collection 2.0 is another big test collection compiled by Martin Müller and Markus Enzenberger. These tests use only the standardized reg_genmove command.
  57. Semeai Test Suite is a comprehensive set of 722 semeai tests by Ricard Vilà. This suite uses a custom GTP command for solving semeais, see the README file in the test suite for specification of its semantics.
  58. Regression test tools
  59. Tools to run regression tests and present the results.
  60. regress.pike is a regression script used by GNU Go.
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|Archiver|手机版|飞扬围棋网 ( 苏ICP备11029047号-1 )

GMT+8, 2024-3-29 13:16 , Processed in 0.147810 second(s), 20 queries .

since 2003飞扬围棋论坛 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表