examples:
http://www.chessdb.cn/cdb.php?action=queryall&board=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR%20w%20KQkq%20-%200%201&json=1
http://www.chessdb.cn/cdb.php?action=querypv&board=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR%20w%20KQkq%20-%200%201&json=1
github: https://github.com/noobpwnftw/chessdb
cc @noobpwnftw
There are two more endpoints that may or may not be useful:
http://www.chessdb.cn/cdb.php?action=queue&board=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR%20w%20KQkq%20-%200%201&json=1
This queues the given position(and subsequent positions) for analysis with higher priority.
http://www.chessdb.cn/cdb.php?action=queryscore&board=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR%20w%20KQkq%20-%200%201&json=1
This gives centipawn evaluation score of the given position without other information(useful to draw an eval graph).
Work in progress: https://github.com/ornicar/lila/compare/master...niklasf:chessdb-cn
The queryall endpoint currently responds with a lone {:
curl -v https://www.chessdb.cn/cdb.php\?action\=queryall\&boad\=rnbqkbnr%2Fpppppppp%2F8%2F8%2F8%2F8%2FPPPPPPPP%2FRNBQKBNR%20w%20KQkq%20-%200%201\&json\=1
* Trying 170.33.8.57:443...
* TCP_NODELAY set
* Connected to www.chessdb.cn (170.33.8.57) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
* subject: CN=chessdb.cn
* start date: Jun 18 19:29:10 2019 GMT
* expire date: Sep 16 19:29:10 2019 GMT
* subjectAltName: host "www.chessdb.cn" matched cert's "www.chessdb.cn"
* issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x55854eee3f30)
> GET /cdb.php?action=queryall&boad=rnbqkbnr%2Fpppppppp%2F8%2F8%2F8%2F8%2FPPPPPPPP%2FRNBQKBNR%20w%20KQkq%20-%200%201&json=1 HTTP/2
> Host: www.chessdb.cn
> User-Agent: curl/7.65.1
> Accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 200
< server: nginx
< date: Sat, 22 Jun 2019 20:00:53 GMT
< content-type: text/html; charset=UTF-8
< content-length: 1
< x-frame-options: SAMEORIGIN
< cache-control: no-cache
< pragma: no-cache
< access-control-allow-origin: *
< x-cache: MISS
<
* Connection #0 to host www.chessdb.cn left intact
{%
It seems a typo: boad -> board.
Oh, my bad. Perhaps the server should respond 400?
I'm working on it, it should output a proper json at least.
EDIT:
Done.
Thanks!
Next issue: The Content-Type header must be application/json in order for XHR to work properly. It is currently content-type: text/html; charset=UTF-8.
Fixed.
A few notes on the data:
score field has a range of +-30000, where values above 10000 or below -10000 represents mate score in plies towards their corresponding max value. So a mate in 4 plies for the winning side has a score of 29996, a mate in 4 plies for the losing side has a score of -29996, otherwise they are centipawn evaluations of the playing side.
rank field has three values: 0,1,2. 0 means it's a bad move, 1 means it's a good move, 2 means it's among the best moves.
notes field has the following format: <symbol of rank> (<num1>-<num2>), where the symbol of rank translates to !=2, *=1, ?=0 according to rank field, num1 is the number of explored(known) moves of the position after making the corresponding move at the current position, num2 is the number of rank=2 moves plus the number of rank=1 moves among explored moves.
winrate field is the conversion of centipawn score with this formula: 100 / ( 1 + exp( -centipawn / 330 ) ), a mate score does not have this field.
The decision of each moves' rank is based on an aspiration window scaled by the highest centipawn evaluation of explored moves and the centipawn evaluation is back-propagated from subsequent positions by taking weighted average of scores among their explored moves sieved by a similar aspiration window, which also considers the number of moves being sampled.
Thanks for the explanation.
Meanwhile I am done with most of the plumbing. Deployed to the test server (https://lichess.dev/analysis#explorer, select chessdb.cn after clicking the little gear icon).
Of course that's just the raw data. Still need to present it more nicely and clean up the patch.
Changes: https://github.com/ornicar/lila/compare/master...niklasf:chessdb-cn
There may also a case of "stalemate" in the status field returned.
I'm not quite familiar with GUI coding, here are my thoughts:
winrate is an optional field, it should be declared as winrate?: string;.
Rendering could have be limited to moves that have rank > 0 to filter out junk ones.
Move list could be displayed with two columns: Move and Advantage, where Move shows their SAN notation, Advantage is a horizontal percentage bar that shows winning chances(needs conversion from POV of the playing side to white & black), moves without winrate field have 100% chances of winning/losing.
Really cool API but I'm not sure how to make it useful within lichess analysis tools for now
One quick use case is as a data source to opening explorer, which is partially done so far.
Another is to populate the eval cache, which can in turn provide more analysis results aside fishnet.