進まないな。

30年?前頃は、駒が移動できるかを、只管、こんなコードを書いていた。
先手、後手も別にあったから、当然、自分でも理解出来なくなって、管理不能。

function TPieceList.IsMovableBishop(wx, wy, sx, sy: Integer): Boolean;
var
  i: integer;
  snx: integer;
  sny: integer;
begin
  if Abs(wx-sx) = Abs(wy-sy) then begin
    Result := true;
    if sy<wy then
      sny := -1
    else if sy > wy then
      sny := 1
    else sny := 0;
    if sx<wx then
      snx := -1
    else if sx> wx then
      snx := 1
    else snx := 0;
    for i := 1 to Abs(wx - sx)-1 do begin
      if BoardPiece(sx-snx*i, sy - sny* i) <> nil then begin
        result := false;
        Break;
      end;
    end;
  end
  else Result := false;
end;

この頃書いていた、似たような判定をするコードは、普通駒と、線駒で、似たようなコード一つずつで済む。データは作らなくてならないが。

元ネタは、某ベトナム人が作った xiangqi の コードだ。BigBoardSizeを使い、 OB 判定で楽ができるのだった。

const
  OB = -1;
box169: array[1..BigBoardSize] of integer =
   (OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,
OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,
OB,OB, 1, 2, 3, 4, 5, 6, 7, 8, 9,OB,OB,
OB,OB,10,11,12,13,14,15,16,17,18,OB,OB,
OB,OB,19,20,21,22,23,24,25,26,27,OB,OB,
OB,OB,28,29,30,31,32,33,34,35,36,OB,OB,
OB,OB,37,38,39,40,41,42,43,44,45,OB,OB,
OB,OB,46,47,48,49,50,51,52,53,54,OB,OB,
OB,OB,55,56,57,58,59,60,61,62,63,OB,OB,
OB,OB,64,65,66,67,68,69,70,71,72,OB,OB,
OB,OB,73,74,75,76,77,78,79,80,81,OB,OB,
OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,
OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,OB,OB);

box81: array[1..BoardSize] of integer =
(29, 30, 31, 32, 33, 34, 35, 36, 37,
42, 43, 44, 45, 46, 47, 48, 49, 50,
55, 56, 57, 58, 59, 60, 61, 62, 63,
68, 69, 70, 71, 72, 73, 74, 75, 76,
81, 82, 83, 84, 85, 86, 87, 88, 89,
94, 95, 96, 97, 98, 99,100,101,102,
107,108,109,110,111,112,113,114,115,
120,121,122,123,124,125,126,127,128,
133,134,135,136,137,138,139,140,141);

      // 単移動
MovabilitySimple: array[spGyoku..spTokin, 1..DIRECTIONMAX] of integer = (
      (-14, -13, -12,  -1,   1,  12,  13,  14),  // 玉
      (  0,   0,   0,   0,   0,   0,   0,   0),  // 飛
      (  0,   0,   0,   0,   0,   0,   0,   0),  // 角
      (-14, -13, -12,  -1,   1,  13,   0,   0),  // 金
      (-14, -13, -12,  12,  14,   0,   0,   0),  // 銀
      (-27, -25,   0,   0,   0,   0,   0,   0),  // 桂
      (  0,   0,   0,   0,   0,   0,   0,   0),  // 香
      (-13,   0,   0,   0,   0,   0,   0,   0),  // 歩
      (-14, -12,  12,  14,   0,   0,   0,   0),  // 龍
      (-13,  -1,   1,  13,   0,   0,   0,   0),  // 馬
      (-14, -13, -12,  -1,   1,  13,   0,   0),  // 成銀
      (-14, -13, -12,  -1,   1,  13,   0,   0),  // 成桂
      (-14, -13, -12,  -1,   1,  13,   0,   0),  // 成香
      (-14, -13, -12,  -1,   1,  13,   0,   0));  // と

      // 複数移動   queen や nightrider の拡張を見込み 8方向
MovabilityLine: array[spGyoku..spTokin, 1..DIRECTIONMAX] of integer = (
      (  0,   0,   0,   0,   0,   0,   0,   0),
      (-13,  -1,   1,  13,   0,   0,   0,   0),
      (-14, -12,  12,  14,   0,   0,   0,   0),
      (  0,   0,   0,   0,   0,   0,   0,   0),
      (  0,   0,   0,   0,   0,   0,   0,   0),
      (  0,   0,   0,   0,   0,   0,   0,   0),
      (-13,   0,   0,   0,   0,   0,   0,   0),
      (  0,   0,   0,   0,   0,   0,   0,   0),
      (-13,  -1,   1,  13,   0,   0,   0,   0),
      (-14, -12,  12,  14,   0,   0,   0,   0),
      (  0,   0,   0,   0,   0,   0,   0,   0),
      (  0,   0,   0,   0,   0,   0,   0,   0),
      (  0,   0,   0,   0,   0,   0,   0,   0),
      (  0,   0,   0,   0,   0,   0,   0,   0)
    );

  procedure SetSimpleMove;
  var
    i : integer;
    direction: integer;
  begin
    for i := 1 to DIRECTIONMAX do begin
      direction := MovabilitySimple[sp, i];     //  Simple
      if direction <> 0 then begin
        if ti = tiGote then
          direction :=  0 - direction;
        target169 := ind169 + direction;
        target81 := box169[target169];
        SetTarget(target81, ti);  // 返り値は使わない
      end;
    end;
  end;

  procedure SetLineMove;
  var
    i: integer;
    direction: integer;
    cnt: Boolean;
  begin
    for i := 1 to DIRECTIONMAX do begin
      direction := MovabilityLine[sp, i];    //  Line
      if direction <> 0 then begin
        if ti = tiGote then
          direction :=  0 - direction;
   target169 := ind169 + direction;    // 駒位置から
     target81 := box169[target169];
     cnt := SetTarget(target81, ti);
       while cnt do begin
          target169 := target169 + direction;   // 動いた位置から
          target81 := box169[target169];
          cnt := SetTarget(target81, ti);
        end;
      end;
    end;
  end;
スポンサーサイト



TBASE から *.TMK を作る

全詰連の *.DIA *.TJN から、 *.TMKを簡便に作るのは
TMKPlayなどで、読み込んで、表示されるモノをコピーするというのがあった。
手持ちの *.DIA *.TJN などは、この方法で 大昔に変換してしまっていた。

数年前、大量の *.DIA *.TJN を受け取った。
TMKPlayなどでは荷が重く、変換するprogram が必要になり、でっちあげた。

変換後いろいろと修正が必要なこともあり、コツコツと直していた。
まだまだ、おかしい所はあるが、ひとまず終了。

PARA5460.DIA PARA5460.TJN の変換後は以下のようになる。
変換後は、 suiho,  for you, je t'aime などで自由に印刷などに活用できる。

----------------------------------------------------

書名 詰パラ   1954(昭和29)年


章名 1954年8月

#0001 l-SR5 k-bs5 ppp-P4 - B6 / SSN / 鈴木実 :1954-08: 表紙
82銀成同玉94桂同歩91飛成同玉93香82玉92香成同玉93銀81玉82銀打まで13手詰

#0002 l8 R-s4 kpgp5 rBP4 K3b4 N8 / S / 大道棋 :1954-08: 大道棋挑戦記 A
82銀92玉73銀生81玉92金同香同飛成同玉84桂同飛93香同玉84銀成同歩94飛83玉84飛72玉82飛成61玉52龍同玉53歩成61玉62銀72玉73銀成71玉62と81玉82全まで31手詰

#0003 l8 R-s4 kpgp5 rB5 K3b4 N2N-N3 / S / 大道棋 :1954-08: 大道棋挑戦記 B
82銀92玉91銀成同玉93香81玉82飛成同玉74桂71玉91飛81香82桂成同玉92香成72玉81飛成62玉54桂まで19手詰

#0004 l8 R6 kpp6 r6 K2B5 N2LB4 / S / 大道棋 :1954-08: 大道棋挑戦記 C
82銀92玉84桂同飛83角成同飛91銀成同玉92飛成同玉83角成同玉84歩92玉62飛82香83歩成同玉84香74玉64飛成まで21手詰

#0005 nl T-kp- pp-p L- N2 s2 / NP / 土居市太郎 :1954-08: サン毎29.5.16
44桂同歩23歩まで3手必至
☆ 必至

昔、作った LaTeX での 盤面表示 (承前)

前回は、サワリだけだったが、コンパイル出来るものを載せておこう。
昔のママなのですこしく改良は必要だ。

盤面は、2種類用意してあるようだ。
また、持駒の表示は \shortstack を使い簡潔に行っている。
縦中横は  \moti{P{18}} とする。

picture 環境を使っているので、描画の方法は、

\put(\thesuji,#2){\makebox(11,12){\sgtrans{\templist}}}%

なので、風さんのとそっくりだ。

\documentclass[twoside]{jbook}
\usepackage{multicol}
\usepackage{graphicx}

\textwidth=18cm
\textheight=25.5cm
%\textwidth=26cm
%\textheight=18cm
\setlength{\xkanjiskip}{0zw}
\oddsidemargin=-0.5cm
\evensidemargin=-1.5cm
\topmargin=-2.0cm
\renewcommand{\baselinestretch}{0.9}


\newcommand{\king}{\rotatebox[origin=c]{180}{玉}}
\newcommand{\rook}{\rotatebox[origin=c]{180}{飛}}
\newcommand{\dragon}{\rotatebox[origin=c]{180}{龍}}
\newcommand{\bishop}{\rotatebox[origin=c]{180}{角}}
\newcommand{\ma}{\rotatebox[origin=c]{180}{馬}}
\newcommand{\gold}{\rotatebox[origin=c]{180}{金}}
\newcommand{\silver}{\rotatebox[origin=c]{180}{銀}}
\newcommand{\prsilver}{\rotatebox[origin=c]{180}{全}}
\newcommand{\knight}{\rotatebox[origin=c]{180}{桂}}
\newcommand{\prknight}{\rotatebox[origin=c]{180}{圭}}
\newcommand{\lancer}{\rotatebox[origin=c]{180}{香}}
\newcommand{\prlancer}{\rotatebox[origin=c]{180}{杏}}
\newcommand{\pawn}{\rotatebox[origin=c]{180}{歩}}
\newcommand{\tokin}{\rotatebox[origin=c]{180}{と}}
\newcommand{\King}{玉}
\newcommand{\Rook}{飛}
\newcommand{\Dragon}{龍}
\newcommand{\Bishop}{角}
\newcommand{\Ma}{馬}
\newcommand{\Gold}{金}
\newcommand{\Silver}{銀}
\newcommand{\PrSilver}{全}
\newcommand{\Knight}{桂}
\newcommand{\PrKnight}{圭}
\newcommand{\Lancer}{香}
\newcommand{\PrLancer}{杏}
\newcommand{\Pawn}{歩}
\newcommand{\Tokin}{と}
\newcommand{\Space}{ }

\newcommand{\sgtrans}[1]{%
\if#1-\Space \fi%
\if#1k\king \fi%
\if#1r\rook \fi%
\if#1b\bishop \fi%
\if#1g\gold \fi%
\if#1s\silver \fi%
\if#1n\knight \fi%
\if#1l\lancer \fi%
\if#1p\pawn \fi%
\if#1d\dragon \fi%
\if#1m\ma \fi%
\if#1z\prsilver \fi%
\if#1y\prknight\fi%
\if#1x\prlancer \fi%
\if#1t\tokin \fi%
\if#1K\King \fi%
\if#1R\Rook \fi%
\if#1B\Bishop \fi%
\if#1G\Gold \fi%
\if#1S\Silver \fi%
\if#1N\Knight \fi%
\if#1L\Lancer \fi%
\if#1P\Pawn \fi%
\if#1D\Dragon \fi%
\if#1M\Ma \fi%
\if#1Z\PrSilver \fi%
\if#1Y\PrKnight\fi%
\if#1X\PrLancer \fi%
\if#1T\Tokin \fi%
}

\makeatletter


\newcounter{suji}
\newcommand{\sgd}[2]{%
\setcounter{suji}{0}%
\expandafter\@tfor\expandafter\templist\expandafter:\expandafter=#1%
\do{%
\put(\thesuji,#2){\makebox(11,12){\sgtrans{\templist}}}%
\addtocounter{suji}{11}%
}}%



\newcommand{\transmoti}[1]{%
\if#1P\Pawn%
\else \if#1L\Lancer%
\else \if#1N\Knight%
\else \if#1S\Silver%
\else \if#1G\Gold%
\else \if#1R\Rook%
\else \if#1B\Bishop%
\else #1%
\fi\fi\fi\fi\fi\fi\fi%
}


\newcommand{\sgm}[1]{%
\expandafter\@tfor\expandafter\tlist\expandafter:\expandafter=#1%
\do{%
\transmoti{\tlist}\\%
}}%


\newcommand{\sgb}[9]{%
\fontsize{14pt}{14pt}
\selectfont
\sgd{#1}{96}%
\sgd{#2}{84}%
\sgd{#3}{72}%
\sgd{#4}{60}%
\sgd{#5}{48}%
\sgd{#6}{36}%
\sgd{#7}{24}%
\sgd{#8}{12}%
\sgd{#9}{0}%
}


\newcommand{\moti}[1]{%
\fontsize{12pt}{12pt}
\selectfont
\put(101,0){\shortstack{\sgm{#1}}}%
}%

\newcommand{\sgframe}{%
\thicklines
\put(0,0){\framebox(99,108){}}
\thinlines
\multiput(11,0)(11,0){8}{\line(0,1){108}}
\multiput(0,12)(0,12){8}{\line(1,0){99}}
}

\newcommand{\sgdsmall}[2]{%
\setcounter{suji}{0}%
\expandafter\@tfor\expandafter\templist\expandafter:\expandafter=#1%
\do{%
\put(\thesuji,#2){\makebox(8,9){\sgtrans{\templist}}}%
\addtocounter{suji}{8}%
}}%

\newcommand{\sgbsmall}[9]{%
\fontsize{8pt}{8pt}
\selectfont
\sgdsmall{#1}{63}%
\sgdsmall{#2}{55}%
\sgdsmall{#3}{47}%
\sgdsmall{#4}{39}%
\sgdsmall{#5}{31}%
\sgdsmall{#6}{23}%
\sgdsmall{#7}{15}%
\sgdsmall{#8}{7}%
\sgdsmall{#9}{-1}%
}


\newcommand{\motismall}[1]{%
\fontsize{7pt}{7pt}
\selectfont
\put(73,0){\shortstack{\sgm{#1}}}%
}%

\newcommand{\sgframesmall}{%
\thicklines
\put(0,0){\framebox(72,72){}}
\thinlines
\multiput(8,0)(8,0){8}{\line(0,1){72}}
\multiput(0,8)(0,8){8}{\line(1,0){72}}
}


\makeatother%




\begin{document}
%\small 
\setlength{\unitlength}{0.45mm}
\begin{picture}(120,120)
\sgframe
\sgb
{-------z-}
{-L-tzzz-t}
{-pP----pt}
{kPt-PPPPt}
{tNTTN--Tx}
{gTG--m-N-}
{Ng-------}
{--D----L-}
{--L-MGR--}
\moti{なし}
\end{picture}
\end{document}

昔、作った LaTeX での 盤面表示

昔のファイルを探していたら、こんなのが出てきた。

LaTeX での 盤面表示を研究していた時のモノ。

こんな図面が

20230306-1.jpg

こんなソースで表現できる。駒の略号は suiho のものを流用している。

\begin{picture}(120,120)
\sgframe
\sgb
{-------z-}
{-L-tzzz-t}
{-pP----pt}
{kPt-PPPPt}
{tNTTN--Tx}
{gTG--m-N-}
{Ng-------}
{--D----L-}
{--L-MGR--}
\moti{なし}
\end{picture}

ちなみに、\sgb は以下の通りで、 \sgd を呼び出している。

\newcommand{\sgb}[9]{%
\fontsize{14pt}{14pt}
\selectfont
\sgd{#1}{96}%
\sgd{#2}{84}%
\sgd{#3}{72}%
\sgd{#4}{60}%
\sgd{#5}{48}%
\sgd{#6}{36}%
\sgd{#7}{24}%
\sgd{#8}{12}%
\sgd{#9}{0}%
}

\sgd は以下の通り

\newcounter{suji}
\newcommand{\sgd}[2]{%
\setcounter{suji}{0}%
\expandafter\@tfor\expandafter\templist\expandafter:\expandafter=#1%
\do{%
\put(\thesuji,#2){\makebox(11,12){\sgtrans{\templist}}}%
\addtocounter{suji}{11}%
}}%

もう、自分でも理解できなくなっている。



心を入れ替えて

2月末に、 clinic に薬を貰いに行ったら、叱られてしまった。
心を入れ替えて、日に 1hour 位は歩こうと思った。
3月に入ってからは 3日は、 walk したし、歩かない日は bicycle。
結果がでるのは、2か月後かな。

T新聞は、余詰めの件も一段落したので、半分は終わったような気分。

で、K新聞の整理。

N氏が担当前の番号は不明な部分が多すぎるのでナンバリングは簡易版。
それ以降は、正月での番号が不明な点もあるが、2017年までは終了。

と、、

データを直しては、suiho で確認を繰り返していたら、「再読込」があると便利な事に気が付いた。これまでは、まとまった修正をしてから、まとめて確認という方針だった。しかし、つい、1か所直してはその都度確認という、様になったのだった。「再読込」を導入してみると、やはり便利だった。

そのほかにも、色々と作りたい(修正したい)program もあるのだが、、


幾らか進んだ

午前は、 

T新聞の番号チェック。抜け、跳び、重複、無番と盛沢山。1977年までは済んだ。残りは連番かな?余詰順の整理はまた今度。

午後からは、

マルチ画面だと、表示位置がマイナスになったりしているので、suiho の手直しも少し。

あと、windowの幅を変えても、幅一杯にできるようにした。
本に載っていたルーチンの使いまわしなので、いざ、自分で改良するとなると大儀だ。

suiho は、いわば Report  なので、Form も作りたいのだが、時間切れのようだ。