/// <summary> /// 盤上にあるか。 /// 碁番の行列が同じ長さという前提で、行でも列でも両用。 /// </summary> /// <param name="ij"></param> /// <returns></returns> public static bool In_Board( int ij, GobanRectangleA gobanBounds ) { return(0 <= ij && ij <= gobanBounds.BoardEnd); }
/// <summary> /// 盤上の端っこ(両端のどちらでも)にあるか。 /// 碁番の行列が同じ長さという前提で、行でも列でも両用。 /// </summary> /// <param name="ij"></param> /// <returns></returns> public static bool On_Edge ( int ij, GobanRectangleA gobanBounds ) { return(ij == 0 || ij == gobanBounds.BoardSize); }
/// <summary> /// 交点の番号。 /// /// 例えば19路盤であれば、左上から右へ、右上から次の行の左端へと、 /// 0,1,2…,18、 /// 19,20,21...37、 /// といったように番号が振られます。 /// /// Gnugo1.2 では、endgame.c の node関数。 /// </summary> /// <param name="location">Gnugo1.2 では、i,j という変数名。</param> /// <returns></returns> public static int GetNodeByLocation ( GobanPoint location, GobanRectangleA gobanBounds ) { return(location.I * gobanBounds.BoardSize + location.J); }
/// <summary> /// 交点の番号を、碁盤の座標 i,j に戻します。 /// /// Gnugo1.2 では、endgame.c の node2ij関数。 /// </summary> /// <param name="out_location"></param> /// <param name="node"></param> public static void GetLocationByNode( out GobanPoint out_location, int node, GobanRectangleA gobanBounds ) { out_location = new GobanPointImpl( node / gobanBounds.BoardSize, node % gobanBounds.BoardSize ); }
/// <summary> /// 中央からどれだけ離れているか。 /// /// Gnugo1.2 では line 関数。 /// </summary> /// <param name="x"></param> /// <returns></returns> public static int DistanceFromCenter(int x, GobanRectangleA gobanBounds) { return(Util_FindLocalZyoseki.Abs(x - gobanBounds.BoardCenter)); }
/// <summary> /// 南端なら真。 /// </summary> /// <returns></returns> public bool IsSouthEnd(GobanRectangleA gobanBound) { return(this.I == gobanBound.BoardEnd); }
/// <summary> /// 東端なら真。 /// </summary> /// <returns></returns> public bool IsEastEnd(GobanRectangleA gobanBound) { return(this.J == gobanBound.BoardEnd); }