
前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
( ;FF[3]GM[1]AP[PocketGoban Ver 0.999] SZ[19]DT[2014-02-17] KM[5.5] AB[bc][cc][db]AW[cd][dc][ec][eb][de][cf]( ;B[ca](;W[ab];B[bb];W[ea];B[aa];W[ba];B[ac];W[da];B[cb] )(;W[bb] ;B[ab];W[ba];B[bd];W[be];B[ad] )(;W[ea];B[ab];W[bd];B[ba] ) )(;B[bb] ;W[da];B[ca] ) ) |
a b c d e f g h i j k l m n o p q r s 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
![]()
class CELL
{
public int num; //セルの番号(チェック用)
public int level; //棋譜の分岐レベル
public CELL car; //次の cell へのポインタ
public CELL cdr; //分岐 cell へのポインタ
public CELL next; //選択手順へのポインタ
public CELL back; //next の逆リンク
public Point pos; //X座標, Y座標
public short teban; //黒(1)・白(-1)
public string id; //見出し
public string msg; //コメント
// Constructor
public CELL(int n)
{
num = n;
level = 0;
car= null;
cdr= null;
next= null;
back= null;
id= string.Empty;
msg= string.Empty;
pos.X = 0;
pos.Y = 0;
}
// Cell Print
public void Print(CELL pt)
{
string link;
if (pt==null) return;
if (pt.car!=null) link = " LINK:" + pt.car.num;
else link = " LINK:*";
if (pt.cdr!=null) link = link + " " + pt.cdr.num;
else link = link + " *";
Console.Write(pt.num + " LEV:" + pt.level + link);
Console.Write(" [" + pt.pos.X + "," + pt.pos.Y + "] ");
Console.WriteLine(pt.teban + " ID:" + pt.id + " MSG:" + pt.msg);
Print(pt.car);
Print(pt.cdr);
return;
}
}
|
![]()
static public void Reset(CELL pt)
{ if (pt==null) return;
pt.next = null;
pt.back = null;
Reset(pt.car);
Reset(pt.cdr);
}
|
// lev, ps の CELL を検索
static public CELL Scan(CELL pt, int lev, Point ps)
{ CELL wp;
if (pt==null) return null;
if (pt.level==lev && pt.pos.X==ps.X && pt.pos.Y==ps.Y) return pt;
wp = Scan(pt.cdr, lev, ps);
if (wp != null) return wp;
return null;
}
|
static public CELL Clone(CELL pt)
{ CELL wp;
wp = new CELL(0);
wp.num = pt.num;
wp.car = pt.car;
wp.cdr = pt.cdr;
wp.pos = pt.pos;
wp.teban = pt.teban;
wp.id = pt.id;
wp.msg = pt.msg;
wp.lb = pt.lb;
wp.judge = pt.judge;
wp.level = pt.level;
return wp;
}
|
static public void Copy(CELL sou, CELL des)
{
if (sou==null) return;
des = Clone(sou);
if (sou.car!=null)
{ Copy(sou.car, des.car);
}
if (sou.cdr!=null)
{ Copy(sou.cdr, des.cdr);
}
}
|
![]()
[Next Chapter ↓] 棋譜の再生
[Previous Chapter ↑] SGF ファイルを入力