围棋打谱程序之棋盘类(包括提子,子串搜索,打劫,禁手等判断)

本文介绍了一个用于描述和计算围棋棋盘状态的棋盘类,包括棋子状态、气、子串搜索、提子等功能。类中包含了判断有效着点、计算棋子串的气、寻找棋子串及提子的算法。使用了ArrayList实现,但提到可以进一步优化为数组以提高效率。
摘要由CSDN通过智能技术生成

?

/**************************************************************************************/
?* 功能:?棋盘类
?* 描述:?用于描述和计算棋盘上的棋子状态, 气, 子串
?*???提子等判断。
?* 作者:?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 SetForNewGame()
?

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值