どうぶつしょうぎの棋譜を普通の将棋と同様の棋譜で残すと、以下の難点がある。
・本将棋のように数字+漢字表記の数字、という形では無い。
・本将棋のように駒を漢字一文字で表せない
第一段落に反するけど、いや普通に書けるんだぜ、という話もある。
[A-C][1-4](雛|鶏|麒|象|獅)という具合。
それでもこれじゃ読みづらいからxmlにしてみる、柔軟だしね。
さて、どういう仕様にしようか、という感じですが、こんな風に考えている。
<?xml version='1.0' encoding='UTF-8'?> <kifu sente="Fx" gote="chrome" start="124567890"> <te te_id="1" which="sente" from="b3" to="b2" touch="0"/> <te te_id="2" which="gote" from="c1" to="b2" touch="60"/> <te te_id="3" which="sente" from="a4" to="b3" touch="60"/> </kifu>
sente="先手名" gote="後手名" te_id="その手数" which="先/後のどちらなのか" from="移動元マス" to="移動先マス" touch="開始時から手を打つまでにかかった時間" あとは打たれたらの空要素を増やしていく感じ/kifuがあったら対局終了
時間切れか投了かとかも入れた方がいいだろうかどうだろう、ちょっとまだ分からない。 それとあと持ち駒から打った時にどういう風に書き換えるかも要注意。 気をつける点はこれぐらいかな。 棋譜の素晴らしさは情報が少ないのに、再現率が高い事だしその流れをきちんと汲まなければ。
追記(20089-11-19).<kifu>の要素にtype="doubutsu"またはtype="lion"みたいな感じにして、動物将棋の棋譜であることを明示するようにするかな。
追記(20089-11-19).上記のxmlを作るようなphpスクリプトメモ
<?php $dom = new domDocument('1.1', 'UTF-8'); $kifu = $dom->appendChild($dom->createElement('kifu')); $kifu->setAttribute('sente', "Fx"); $kifu->setAttribute('gote', "chrome"); $kifu->setAttribute('start', "1234567890"); $kifu->setAttribute('type', "lion"); $te[] = $kifu->appendChild($dom->createElement('te')); $te[0]->setAttribute('te_id', "1"); $te[0]->setAttribute('which', "sente"); $te[0]->setAttribute('from', "b3"); $te[0]->setAttribute('to', "b2"); $te[0]->setAttribute('touch', "0"); $te[] = $kifu->appendChild($dom->createElement('te')); $te[1]->setAttribute('te_id', "2"); $te[1]->setAttribute('which', "gote"); $te[1]->setAttribute('from', "c1"); $te[1]->setAttribute('to', "b2"); $te[1]->setAttribute('touch', "60"); $te[] = $kifu->appendChild($dom->createElement('te')); $te[2]->setAttribute('te_id', "3"); $te[2]->setAttribute('which', "sente"); $te[2]->setAttribute('from', "a4"); $te[2]->setAttribute('to', "b3"); $te[2]->setAttribute('touch', "85"); $dom->formatOutput = true; echo $dom->saveXML();追記(2009-11-19 18:00:).
上のコードをより汎用的に
<?php class XMLKifu { var $dom, $kifu, $te; // コンストラクタ function __construct() { $this->dom = new domDocument('1.0', 'UTF-8'); $this->dom->formatOutput = true; $this->kifu = $this->dom->appendChild($this->dom->createElement('kifu')); $this->te = array(); } function output() { echo $this->dom->saveXML(); } function set_sente($name) { $this->kifu->setAttribute('sente', $name); } function set_gote($name) { $this->kifu->setAttribute('gote', $name); } function set_start($utime) { $this->kifu->setAttribute('start', $utime); } function set_type($type) { $this->kifu->setAttribute('type', $type); } function append_te($from, $to, $touch) { $te_id = count($this->te); if ($te_id % 2 == 0) { $user_type = "sente"; } else { $user_type = "gote"; } $this->te[$te_id] = $this->kifu->appendChild($this->dom->createElement('te')); $this->te[$te_id]->setAttribute('te_id', $te_id); $this->te[$te_id]->setAttribute('which', $user_type); $this->te[$te_id]->setAttribute('from', $from); $this->te[$te_id]->setAttribute('to', $to); $this->te[$te_id]->setAttribute('touch', $touch); } function update_te($te_id, $elemname, $value) { } } $xk = new XMLKifu(); $xk->set_sente('Fx'); $xk->set_gote('chrome'); $xk->set_start('1234567890'); $xk->set_type('lion'); $xk->append_te('b3', 'b2', 0); $xk->append_te('c1', 'b2', 60); $xk->append_te('a4', 'b4', 85); $xk->output();追記(2009-11-30 13:24).
ちゃんと棋譜を書いてみたら凄く読みやすかった ▲A2雛 △同象 ▲A3雛打 ここに来てXMLKifu、頓挫の予感 同象とかつい笑っちゃうけどw
[...] Lounge Landscape Just another WordPress weblog « 動物将棋の棋譜を再現するにあたって動物将棋棋譜XMLを思案 [...]
返信削除