?
/**************************************************************************************/
?* 功能:?棋盘类
?* 描述:?用于描述和计算棋盘上的棋子状态, 气, 子串
?*???提子等判断。
?* 作者:?Chen Rong
?* 时间:?2004-6-7 2:24
?*
?* History:
?*???2004-6-7 2:24 :实现了子串的搜索, 串的气判断。 使用了 ArrayList 类, 以后效率
?*???????如果要优化, 可改写成数组。
? **************************************************************************************/
using System;
using System.Collections;
using System.Drawing;
namespace ChenRong.Weiqi
{
?///
?/// Board 的摘要说明。
?///
?public class Board
?{
??public static readonly int Black = -1;
??public static readonly int Empty = 0;
??public static readonly int White = 1;
??// 棋子数组
??private int[,] stones;?
??// 最后一步杀死的棋子数
??public int LastKillCount = 0;
??// 上下左右偏移量数组, 用于判断某位置周围四个点的情况
??private int[,] offsets = new int[4, 2] { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1} };
??// 构造函数(constructor)
??public Board()
??{
???this.stones = new int[19, 19];
???this.SetForNewGame();
??}
??// 复制棋盘
??public Board(Board board)
??{
???this.stones = board.stones;
???this.LastKillCount = board.LastKillCount;
??}
??// 初始化
??public void SetFo

本文介绍了一个用于描述和计算围棋棋盘状态的棋盘类,包括棋子状态、气、子串搜索、提子等功能。类中包含了判断有效着点、计算棋子串的气、寻找棋子串及提子的算法。使用了ArrayList实现,但提到可以进一步优化为数组以提高效率。
最低0.47元/天 解锁文章
925

被折叠的 条评论
为什么被折叠?



