Git Product home page Git Product logo

Comments (9)

na2hiro avatar na2hiro commented on August 30, 2024 1

20170223_2.kif.txt: na2hiro/Kifu-for-JS#31 により報告

from json-kifu-format.

denden1025 avatar denden1025 commented on August 30, 2024 1

明解なご返答ありがとうございます。不明確な点がクリアーになりました。恥ずかしながらjavascriptのオブジェクトで「"promote": null」という表記ができる事を知りませんでした。

JSONKifuFormat 簡単で良さそうですね。既に作り込んでしまっていますが、ぜひ試してみます。

from json-kifu-format.

mfujiwara avatar mfujiwara commented on August 30, 2024 1

初めまして。読み込めない棋譜がありましたのでご報告します。
棋譜をgistにアップいたしました。
https://gist.github.com/mfujiwara/e055a889650ab0d5fc331659d2553e7a

上記の棋譜は毎日新聞が公開している棋譜からコメント部分のみ削除したものです。
二日制の将棋の場合、封じ手から開封までの間だけ封じ手という手が存在するようです。
http://mainichi.jp/feature/shougi/mai/meijinsen_20180508_M7_10034.kif

ご対応いただけますと幸甚です。
どうぞよろしくお願いいたします。

from json-kifu-format.

mizar avatar mizar commented on August 30, 2024 1

読めない棋譜がありましたので報告します。

勝ち宣言周りの書式(1行に勝ち宣言と棋譜コメントを並べる %KACHI,'* -5000 win のような表記)の問題かもしれません。逆に、以下の棋譜は現状問題ないようです。

(追記) Kifu-for-JS (json-kifu-format) へ棋譜を読み込ませる際、

%KACHI,'* -5000 win
T4

の部分を

%KACHI
T4
'* -5000 win

のように加工することで、正常に読み込むことが出来そうです。

from json-kifu-format.

na2hiro avatar na2hiro commented on August 30, 2024 1

@mfujiwara とても遅くなって申し訳ありませんが、今回のリリースで封じ手に対応しました。ご報告ありがとうございました。

@mizar 詳しい情報ありがとうございます。指し手と時間の間にコメントが来る例に対応していませんでしたので対応しました。

Kifu for JS 2.1.3 https://github.com/na2hiro/Kifu-for-JS/releases/tag/v2.1.3 及びjson-kifu-format 1.2.3にて修正されましたコードが利用可能です。

from json-kifu-format.

denden1025 avatar denden1025 commented on August 30, 2024

はじめまして。突然失礼致します。主にperlと釣りの個人ブログを運営しているwebkoza.com の denden と申します。
JKFの仕様に付いて確認があり、場違いの可能性を顧みずコメントさせてください。

友人同士で手軽にスマフォのブラウザ上でネット対局ができるサービスを作りました。もちろんブラウザサイドはjavascriptです。開発の最後に棋譜の保存/展開機能を実装することを思い付き、調べた所na2hiroさんのJKFにたどり着きました。この素晴らしい仕様が広まれば良いと思っています。
上記機能を作り込む過程で正しい仕様の定義について下記2つの疑問が生じましたので念のため確認させてください。

READMEに「promote? Bool 成るかどうか true:成, false:不成, 無いかnull**:どちらでもない**」
とありますが、「Kif for JS example」を使用した時、棋譜のmoves ARRAYに下記の(1)が存在すると「棋譜エラー」となります。「null」を最初「空文字」と勝手に思ってやってみたのですが、「空文字」は「false」になるので「不成」となるということでしょうか。また、下記の(2)が存在すると「不成」と表示されます。
parse結果として「どちらでもない=成れない手」を期待する場合、promote オブジェクト自体が存在しなければ期待通りになります。READMEの「無い」がこれに該当するのでしょうか。

(1)ーー棋譜エラー
{
"move": { "to": { "x": 8, "y": 4 }, "from": { "x": 8, "y": 3 },
"color": 1,
"piece": "FU",
"promote":
}
(2)ーー不成?
{
"move": { "to": { "x": 8, "y": 4 }, "from": { "x": 8, "y": 3 },
"color": 1,
"piece": "FU",
"promote":""
}

from json-kifu-format.

na2hiro avatar na2hiro commented on August 30, 2024

初めまして,JKFに興味を持っていただいてありがとうございます.

無いかnull,というのは次のようなJSONのことを意図しています.

プロパティがない
{
  "move": { "to": { "x": 8, "y": 4 }, "from": { "x": 8, "y": 3 },
  "color": 1,
  "piece": "FU"
}
値がnull
{
  "move": { "to": { "x": 8, "y": 4 }, "from": { "x": 8, "y": 3 },
  "color": 1,
  "piece": "FU",
  "promote": null
}

"promote":""はJKFとしては不正な値ですが,JavaScript上で空文字列はfalsyなのでJKFPlayerの実装でfalseと捉えてしまったかもしれません(本当は不正な値として弾くべき).

また,true, false, 無いまたはnullの3種類の使い分けが明確に書いてありませんが,これは将棋連盟の正式な棋譜表記における"成" "不成" "(何も書かない)"にそれぞれ対応しています.具体的には次のように説明できます.

  • その駒の動きで成るか成らないか,指し手が選択できる場合: truefalse
  • その駒の動きで成りようがない場合(玉金や成駒が動いた.3段目以内でない.駒打ちなど): 無いまたはnull

この例の場合,"☖8四歩"と飛車先の歩を突く手でしたらプロパティがないまたは値がnullの例が正しいです.

from json-kifu-format.

na2hiro avatar na2hiro commented on August 30, 2024

ところで,もし,正しいJKFを出力したいのでしたら,このリポジトリ内にあるJKFPlayerを利用すると良いです.json-kifu-format-1.2.0.min.jsをscriptタグで読み込んで使う場合,次のようにすることで正式なJKFが出力できます.

var player = new JSONKifuFormat.JKFPlayer({
  header: {
    "先手":"藤井聡太",
    /*対局者名などのメタ情報*/
  },
  moves:[{}]
});
player.inputMove({color: 0, from: {x: 7, y: 7}, to: {x: 7, y: 6}, piece: "FU"})
player.inputMove({color: 1, from: {x: 3, y: 3}, to: {x: 3, y: 4}, piece: "FU"})
...
player.inputMove({color: 0, to: {x: 5, y: 5}, piece: "KA"}) // 駒打ち
...
var JKFString = player.toJKF();

from json-kifu-format.

na2hiro avatar na2hiro commented on August 30, 2024

from json-kifu-format.

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.