中国象棋(代码)
java课程设计---中国象棋对弈系统

java课程设计---中国象棋对弈系统⽬录摘要 (1)关键字 (1)正⽂ (2)1、程序设计说明 (2)1.1 程序的设计及实现 (2)1.1.1搜索引擎的实现(engine包) (2)1.1.2信息传输机制(message包) (3)1.1.3棋⼦(pieces包) (3)1.2 主控模块(main包) (3)2、运⾏结果 (5)3、设计体会 (6)附件 (7)程序代码 (7)参考⽂献资料 (41)1中国象棋对弈系统Java语⾔程序设计实验报告实验项⽬名称:中国象棋对弈系统作者姓名与单位:李⾮计算机101摘要:本⽂主要是运⽤java实现具有⼀定功能的中国象棋对弈系统软件,主要功能如下:a、象棋对弈:红⽅先⾛,然后⿊⽅再⾛,红⿊交替,直到⼀⽅获胜。
b、新游戏:任何时候可以重新开始⼀盘新的对弈。
c、悔棋:当⾛错棋的时候可以悔棋。
d、信息提⽰:提⽰当前信息状态。
e、简单的帮助⽂档:象棋规则介绍、软件的简单介绍和编制说明关键词:java、中国象棋对弈系统2正⽂:⼀程序设计说明1.1程序的设计及实现2、message:⽹络对战过程中各种消息及其传递机制的类实现包。
3、main:主界⾯实现包。
4、pieces:棋⼦及其相关类实现包。
现就各个包中的要点给与说明。
1.1.1 搜索引擎的实现(engine包)(1) BitBoard.java:位棋盘的实现,见2.4节。
(2) CCEvalue.java:评价函数知识类。
本程序使⽤开源软件“梦⼊神蛋”的快速评价函数。
该函数包含⼦⼒价值和棋⼦所在位置的奖励值。
⼦⼒价值分别是:帅-0, 仕-40, 象-40, 马-88, 车-200, 炮-96, 兵-9。
帅是⽆价的,⽤0表⽰。
以马为例,位置的奖励值如下:0,-3,5,4,2,2,5,4,2,2,-3,2,4,6,10,12,20,10,8,2,2,4,6,10,13,11,12,11,15,2,0,5,7,7,14,15,19,15,9,8,2,-10,4,10,15,16,12,11,6,2,0,5,7,7,14,15,19,15,9,8,2,4,6,10,13,11,12,11,15,2,-3,2,4,6,10,12,20,10,8,2,0,-3,5,4,2,2,5,4,2,2上⾯的每⾏代表棋盘的⼀条纵线。
中国象棋python代码

中国象棋python代码下面是一个简单的中国象棋的Python 代码示例:# 定义棋盘# 绘制棋盘def draw_board():for row in chessboard:for piece in row:print(piece, end=' ')print()# 判断是否在棋盘内def is_valid_move(x, y):return 0 <= x < 9 and 0 <= y < 10# 判断移动是否合法def is_valid_move(x1, y1, x2, y2):piece = chessboard[y1][x1]target = chessboard[y2][x2]if piece == ' ':return Falseif piece == '車' or piece == '車':if x1 != x2 and y1 != y2:return Falseif x1 == x2:min_y, max_y = (y1, y2) if y1 < y2 else (y2, y1)for y in range(min_y + 1, max_y):if chessboard[y][x1] != ' ':return Falseif y1 == y2:min_x, max_x = (x1, x2) if x1 < x2 else (x2, x1)for x in range(min_x + 1, max_x):if chessboard[y1][x] != ' ':return Falseif piece == '馬' or piece == '馬':dx = abs(x2 - x1)dy = abs(y2 - y1)if (dx == 1 and dy == 2) or (dx == 2 and dy == 1): return Truereturn Falseif piece == '象' or piece == '相':if y2 > 4 and (y2 - y1) % 2 != 0:return Falseif abs(x2 - x1) != 2 or abs(y2 - y1) != 2:return Falseif chessboard[(y1 + y2) // 2][(x1 + x2) // 2] != ' ': return Falseif piece == '士' or piece == '士':if x2 < 3 or x2 > 5:return Falseif y2 < 7 or y2 > 9:return Falseif abs(x2 - x1) != 1 or abs(y2 - y1) != 1: return Falseif piece == '帥' or piece == '将':if x2 < 3 or x2 > 5:return Falseif y2 < 0 or y2 > 2:return Falseif abs(x2 - x1) + abs(y2 - y1) != 1:return Falseif piece == '兵':if y1 < 5 and y2 != y1 - 1:return Falseif y1 >= 5 and (x1 != x2 or y2 != y1 - 1):return Falseif piece == '卒':if y1 > 4 and y2 != y1 + 1:return Falseif y1 <= 4 and (x1 != x2 or y2 != y1 + 1):return Falseif target == '帥' or target == '将':if piece == '卒' or piece == '兵':if y2 > 2:return Falseif piece == '兵' or piece == '卒':if y2 < 7:return Falsereturn True# 移动棋子def move_piece(x1, y1, x2, y2):if is_valid_move(x1, y1, x2, y2):piece = chessboard[y1][x1]chessboard[y2][x2] = piecechessboard[y1][x1] = ' 'else:print("Invalid move!")# 游戏循环def game_loop():while True:draw_board()player_input = input("请输入移动的起始位置和目标位置,以逗号分隔(例如:2,1,2,3):")positions = player_input.split(',')if len(positions) != 4:print("请输入正确的起始位置和目标位置!")continuex1, y1, x2, y2 = map(int, positions)if not is_valid_move(x1, y1) or not is_valid_move(x2, y2):print("请输入正确的起始位置和目标位置!")continuemove_piece(x1, y1, x2, y2)# 启动游戏game_loop()这是一个简单的中国象棋游戏代码示例,包括棋盘的绘制、棋子移动的判断和执行等功能。
中国象棋游戏设计

JIU JIANG UNIVERSITY毕业设计题目中国象棋游戏设计英文题目Chinese Chess Game Design院系信息科学与技术学院专业信息管理与信息系统姓名林传玉班级学号 A102215 指导教师杨桃二O一四年五月摘要中国象棋游戏系统是以C/S架构为基础开发的对弈软件,以灵活独立的Java语言为主要开发工具,其中多线程、JavaSwing、Socket编程以及数组和字符串的运用等技术都在开发过程中有所涉猎。
在计算机广泛普及的背景之下,中国象棋游戏解决了由时间、地域和对手有限等面对面对弈所产生的问题,给人们带来很多方便。
对于象棋游戏的研究,通过棋盘类的开发实现棋盘模块,从移动区域、移动规则两个方面详细研究并描述象棋七类棋子的基本属性和棋子走法。
另外,通过对系统的运行测试,表明系统除了实现基于Java技术的中国象棋游戏行棋规则算法,得以使每个棋子的行棋路线都严格遵循棋子属性所具备的走棋规则之外,还具有悔棋、计时、求和、认输等功能,而系统本身也具备界面朴素,操作简便,运行稳定的特点。
系统虽然调试完成,但是仍有许多不足之处,比如没有实现人机对弈,没有聊天记录的本机储存等功能。
不过,随着开发经验的积累,系统的缺陷和不足将会逐步得到完善。
关键词:中国象棋,设计,软件,多线程,信息技术AbstractChinese chess game system is a game software which is developed on the basis of C/S architecture, and using the flexible independent Java language as the main development tools, multi-threading, JavaSwing, Socket programming as well as array and character string are dabbled in the process of development in technology.Under the broad background of the network, the problems resulting from face to face rival game, like the limits of time, region and opponents etc, are solved, to bring a lot of convenience. For the study of chess games, board module achieved through the development of boards, study and describe the basic properties and pawn moves of the seven categories of chess from two aspects of mobile area and moving rules. Furthermore, through the operation tests of the system, it shows that in addition to realize the Chinese chess game moves rules algorithm based on Java technology, so that each piece moves on line strictly follow pieces attribute of the rules of playing chess, the system also has undo, timing, summation, throw in the towel and other functions, and the system itself has characteristics of simple interface, easy operation and stable operation.While System debugging is completed, but there are still many deficiencies, such as no man-machine chess, no chats local storage and other functions. However, with the accumulation of development experience, and gradually perfect the flaw and the insufficiency of the system is imperative.Keywords: Chinese Chess, Design, Software, Muiti Theard, Information Technology目录摘要 (I)Abstract (II)1 绪论1.1 课题背景 (1)1.2 课题研究的内容与意义 (2)1.3 技术思路 (3)1.4 本章小结 (4)2 系统分析2.1 可行性分析 (5)2.2 系统功能模块分析 (6)2.3 需求分析 (7)2.4 本章小结 (10)3 系统设计3.1 中国象棋游戏的结构设计 (11)3.2 系统的功能模块设计 (13)3.3 走棋和吃棋规则设计 (14)3.4 主要算法伪码示例 (18)3.5 本章小结 (22)4 系统运行测试4.1 服务端和客户端运行测试 (23)4.2 客户端和客户端运行测试 (25)4.3 本章小结 (29)5 总结与展望5.1 全文总结 (30)5.2 研究展望 (30)致谢 (32)参考文献 (33)1 绪论1.1 课题背景中国象棋作为我国的十大“国粹”之一,其爱好者不计其数。
java课程设计中国象棋

象棋程序设计1.课程设计目的Java语言是当今流行的网络编程语言,它具有面向对象、跨平台、分布应用等特点。
面向对象的开发方法是当今世界最流行的开发方法,它不仅具有更贴近自然的语义,而且有利于软件的维护和继承,很好的融合了“面向对象”、“跨平台”和“编程简洁”等特性。
随着Java语言的不断发展,它的应用前景将更为宽阔。
本课程设计主要是使用Swing这个Java自带的图形开发工具实现中国象棋棋子及棋盘的绘制,并根据相应的象棋规则,实现在电脑上虚拟出可以供两个人对弈的象棋游戏,从而达到了进一步巩固课堂上所学到的知识,深刻把握Java语言的重要概念及其面向对象的特性,熟练的应用面向对象的思想和设计方法解决实际问题的能力的目的。
2.设计方案论证2.1程序功能象棋是中国一种流传十分广泛的游戏。
下棋双方根据自己对棋局形式的理解和对棋艺规律的掌握,调动车马,组织兵力,协调作战在棋盘--这块特定的战场上进行着象征性的军事战斗。
本程序的功能就是将棋盘和棋子在电脑上模拟出来,双方可以通过鼠标对己方棋子的操作进行对弈。
2.2设计思路象棋,人人会走,把己方的棋子按不同棋子的规则放在棋盘合适的位置上。
象棋包含三个要素:棋盘、棋子和规则。
在本象棋程序的设计上,也大致遵循这三个要素,但是细化为四个方面:棋盘、棋盘上可以走棋的落子点、棋子和象棋规则。
棋盘其实就是一张棋盘的图形,我们要在计算机上的棋盘上落子并不像在现实生活中那么容易,这里说的棋盘充其量只是背景,真正落子的地方必须是我们在图形界面上设定的落子点,不同棋子只能按照各自的规则在这些设定的位置上摆放、搏杀。
2.3设计方法根据前面的细化,程序中分别设计了四个类对应棋盘、落子点、棋子和象棋规则这四个方面。
四个类几乎包括了程序的全部,程序框图如下图所示:图1 程序功能框图2.4详细设计 2.4.1棋子类ChessSwing 中并没有棋子这个组建类,所以我们必须设计一个组件,棋子其实就是圆形 的JLabel ,但Swing 中的JLabel 组件是方形的,没关系,利用JLabel 我们可以创建 圆形的JLabel 组件——Chess 。
中国象棋(代码)

中国象棋(web版源代码)程序:using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1{public partial class WebForm1 : System.Web.UI.Page{int tru = 20;int fals = 40;public ImageButton[,] _Image=new ImageButton[11,10];//将上一次点击点的坐标保存到数据库中的lastx和lastypublic void SaveToLast(){if (Session["user"].ToString() == "red" &&_GetUserState(Session["user"].ToString()) == 20){int x, y, lastx, lasty;x = Getpointx();y = Getpointy();lastx = x;lasty = y;Updatalastx(lastx);Updatalasty(lasty);}if (Session["user"].ToString() == "black" &&_GetUserState(Session["user"].ToString()) == 20){int x, y, lastx, lasty;x = Getpointx();y = Getpointy();lastx = x;lasty = y;Updatalastx(lastx);Updatalasty(lasty);}}//将棋盘上所有棋子图片显示到棋盘上private void _Drawqizi(){//_Init();int i,j,k;if (_GetUserState("red") != 0 && _GetUserState("black") != 0){if (Session["user"].ToString() == "red"){for (i = 1; i <= 10; i++)for (j = 1; j <= 9; j++){k = _GetDataQipan(i, j);_Image[i, j].ImageUrl = _GetImageAdd(k);}}if (Session["user"].ToString() == "black"){for (i = 1; i <= 10; i++)for (j = 1; j <= 9; j++){k = _GetDataQipan(i, j);_Image[11 - i, 10 - j].ImageUrl =_GetImageAdd(k);}}}//初始化:对_Image[,]赋值,对ImageButton进行编号private void _Init(){_Image[1, 1] = ImageButton1; _Image[1, 2] = ImageButton2; _Image[1, 3] = ImageButton3; _Image[1, 4] = ImageButton4; _Image[1, 5] = ImageButton5; _Image[1, 6] = ImageButton6; _Image[1, 7] = ImageButton7; _Image[1, 8] = ImageButton8; _Image[1, 9] = ImageButton9;_Image[2, 1] = ImageButton11; _Image[2, 2] = ImageButton12; _Image[2, 3] = ImageButton13; _Image[2, 4] = ImageButton14; _Image[2, 5] = ImageButton15; _Image[2, 6] = ImageButton16; _Image[2, 7] = ImageButton17; _Image[2, 8] = ImageButton18; _Image[2, 9] = ImageButton19;_Image[3, 1] = ImageButton21; _Image[3, 2] = ImageButton22; _Image[3, 3] = ImageButton23; _Image[3, 4] = ImageButton24; _Image[3, 5] = ImageButton25; _Image[3, 6] = ImageButton26; _Image[3, 7] = ImageButton27; _Image[3, 8] = ImageButton28; _Image[3, 9] = ImageButton29;_Image[4, 1] = ImageButton31; _Image[4, 2] = ImageButton32; _Image[4, 3] = ImageButton33; _Image[4, 4] = ImageButton34; _Image[4, 5] = ImageButton35; _Image[4, 6] = ImageButton36; _Image[4, 7] = ImageButton37; _Image[4, 8] = ImageButton38; _Image[4, 9] = ImageButton39;_Image[5, 1] = ImageButton41; _Image[5, 2] = ImageButton42; _Image[5, 3] = ImageButton43; _Image[5, 4] = ImageButton44; _Image[5, 5] = ImageButton45; _Image[5, 6] = ImageButton46; _Image[5, 7] = ImageButton47; _Image[5, 8] = ImageButton48; _Image[5, 9] = ImageButton49;_Image[6, 1] = ImageButton51; _Image[6, 2] = ImageButton52; _Image[6, 3] = ImageButton53; _Image[6, 4] = ImageButton54; _Image[6, 5] = ImageButton55; _Image[6, 6] = ImageButton56; _Image[6, 7] = ImageButton57; _Image[6, 8] = ImageButton58; _Image[6, 9] = ImageButton59;_Image[7, 1] = ImageButton61; _Image[7, 2] = ImageButton62; _Image[7, 3] = ImageButton63; _Image[7, 4] = ImageButton64; _Image[7, 5] = ImageButton65; _Image[7, 6] = ImageButton66; _Image[7, 7] = ImageButton67; _Image[7, 8] = ImageButton68; _Image[7, 9] = ImageButton69;_Image[8, 1] = ImageButton71; _Image[8, 2] = ImageButton72; _Image[8, 3] = ImageButton73; _Image[8, 4] = ImageButton74; _Image[8, 5] = ImageButton75; _Image[8, 6] = ImageButton76; _Image[8, 7] = ImageButton77; _Image[8, 8] = ImageButton78; _Image[8, 9] = ImageButton79;_Image[9, 1] = ImageButton81; _Image[9, 2] = ImageButton82; _Image[9, 3] = ImageButton83; _Image[9, 4] = ImageButton84; _Image[9, 5] = ImageButton85; _Image[9, 6] = ImageButton86; _Image[9, 7] = ImageButton87; _Image[9, 8] = ImageButton88; _Image[9, 9] = ImageButton89;_Image[10, 1] = ImageButton91; _Image[10, 2] = ImageButton92; _Image[10, 3] = ImageButton93; _Image[10, 4] = ImageButton94; _Image[10, 5] = ImageButton95; _Image[10, 6] = ImageButton96; _Image[10, 7] = ImageButton97; _Image[10, 8] = ImageButton98; _Image[10, 9] = ImageButton99;int i, j;for (i = 1; i <= 10; i++)for (j = 1; j <= 9; j++){_Image[i, j].ImageUrl = "~/image/back.gif";}}//初始化棋盘,将两方棋子放好位private void _InitQizi(){int i = 0, j = 0, k = 0;int[] initqipandata = new int[37];for (i = 1; i <= 10; i++)for (j = 1; j <= 9; j++){_UpdataQipan(i, j, k);}for (i = 0; i <= 36; i++)initqipandata[i] = i;_UpdataQipan(1, 1, initqipandata[8]); _UpdataQipan(1, 2, initqipandata[6]); _UpdataQipan(1, 3, initqipandata[4]); _UpdataQipan(1, 4, initqipandata[2]); _UpdataQipan(1, 5, initqipandata[1]); _UpdataQipan(1,6, initqipandata[3]); _UpdataQipan(1, 7, initqipandata[5]); _UpdataQipan(1, 8, initqipandata[7]); _UpdataQipan(1, 9, initqipandata[9]); _UpdataQipan(3, 2, initqipandata[10]); _UpdataQipan(3, 8, initqipandata[11]); _UpdataQipan(4, 1, initqipandata[12]); _UpdataQipan(4, 3, initqipandata[13]);_UpdataQipan(4, 5, initqipandata[14]); _UpdataQipan(4, 7,initqipandata[15]); _UpdataQipan(4, 9, initqipandata[16]);_UpdataQipan(10, 1, initqipandata[28]); _UpdataQipan(10, 2, initqipandata[26]); _UpdataQipan(10, 3, initqipandata[24]);_UpdataQipan(10, 4, initqipandata[22]); _UpdataQipan(10, 5,initqipandata[21]); _UpdataQipan(10, 6, initqipandata[23]);_UpdataQipan(10, 7, initqipandata[25]); _UpdataQipan(10, 8,initqipandata[27]); _UpdataQipan(10, 9, initqipandata[29]); _UpdataQipan(8, 2, initqipandata[30]); _UpdataQipan(8, 8, initqipandata[31]);_UpdataQipan(7, 1, initqipandata[32]); _UpdataQipan(7, 3,initqipandata[33]); _UpdataQipan(7, 5, initqipandata[34]); _UpdataQipan(7, 7, initqipandata[35]); _UpdataQipan(7, 9, initqipandata[36]);}//获取棋子图片地址private string _GetImageAdd(int xxx){string x="" ;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select add_image from qizi where(no_qizi='"+xxx+"');", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read())x = sr["add_image"].ToString();//Session["add_image"] = x;myconn.Close();return x;}//获取点击后的图片地址private string _GetImageDownAdd(int xxx){string x ="";SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select add_image_down from qizi where(no_qizi='" + xxx + "')", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read())x = sr["add_image_down"].ToString();myconn.Close();return x;}//读取鼠标点击点的坐标private int Getpointx(){int x = 0;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select x from zuobiao", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read()){x = int.Parse(sr["x"].ToString());}myconn.Close();return x;}private int Getpointy( ){int x = 0;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select y from zuobiao", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read()){x = int.Parse(sr["y"].ToString());}myconn.Close();return x;}private int Getpointlastx( ){int x = 0;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select lastx from zuobiao", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read()){x = int.Parse(sr["lastx"].ToString());}myconn.Close();return x;}private int Getpointlasty( ){int x = 0;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select lasty from zuobiao", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read()){x = int.Parse(sr["lasty"].ToString());}myconn.Close();return x;}//写入鼠标点击点的坐标private void Updatax(int xxx){SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update zuobiao set x='" + xxx + "'", myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}private void Updatay(int yyy){SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update zuobiao set y='" + yyy + "'", myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}private void Updatalastx(int lastxxx){SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update zuobiao set lastx='"+lastxxx +"'" , myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}private void Updatalasty(int lastyyy){SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update zuobiao set lasty='"+ lastyyy +"'", myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}//以上四个函数的集合,达到一次写入四个坐标值的目的private void _UpdataaZuobiao(int xxx, int yyy, int lastxxx, int lastyyy){Updatax(xxx);Updatay(yyy);Updatalastx(lastxxx);Updatalasty(lastyyy);}//保存当前坐标值到x和yprivate void _UpdatZuobiaoXY(int xxx, int yyy){if (Session["user"].ToString() == "red" &&_GetUserState(Session["user"].ToString()) == 20){Updatax(xxx);Updatay(yyy);}if (Session["user"].ToString() == "black" &&_GetUserState(Session["user"].ToString()) == 20){Updatax(xxx);Updatay(yyy);}}//读取棋盘上的棋子信息private int _GetDataQipan(int xxx, int yyy){int i,data=0;i = (xxx - 1) * 9 + yyy;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select data_qipan from qipan where(position='"+i+"')", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read())data = int.Parse(sr["data_qipan"].ToString());myconn.Close();return data;}//将棋子信息写入棋盘private void _UpdataQipan(int xxx, int yyy,int data){int i;i = (xxx - 1) * 9 + yyy;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update qipan set data_qipan=" + data + "where (position='"+i+"')", myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}//读出用户此时状态private int _GetUserState(string id){int data = 0;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select state from yonghu where(id='" + id + "')", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read())data = int.Parse(sr["state"].ToString());myconn.Close();return data;}//读出用户输赢状态 0表示在进行游戏 20表示赢 40表示输private int _GetUserWin(string id){int data = 0;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select winner from yonghu where(id='" + id + "')", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read())data = int.Parse(sr["winner"].ToString());myconn.Close();return data;}//写入用户状态private void _UpdataUserState(string id,int sta){SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update yonghu set state="+ sta + "where (id='" + id + "')", myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}//写入用户输赢状态 0表示在进行游戏 20表示赢 40表示输private void _UpdataUserWin(string id, int sta){SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update yonghu set winner=" + sta + "where (id='" + id + "')", myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}protected void Page_Load(object sender, EventArgs e){_Init();// _Test();}//测试程序函数private void _Test(){_UpdataUserState("red",tru);_UpdataUserState("black", tru);}private bool_IsAbleToPut()//********************************************************需要传递x,y,laastx,lasty{if (Session["user"].ToString() == "red" &&_GetUserState(Session["user"].ToString()) == 40)return false;if (Session["user"].ToString() == "black" &&_GetUserState(Session["user"].ToString()) == 40)return false;int x, y, lastx, lasty;int qipandata,lastqipandata;x = Getpointx();y = Getpointy();lastx = Getpointlastx();lasty = Getpointlasty();if (Session["user"].ToString() == "black"){x = 11 - x;y = 10 - y;lastx = 11 - lastx;lasty = 10 - lasty;}qipandata = _GetDataQipan(x, y);lastqipandata = _GetDataQipan(lastx, lasty);// if (lastqipandata==0)// return false;if(Session["user"].ToString() == "red"&&(lastqipandata <= 20 || qipandata >=20))//****************************************************************现以红方为对象return false;if (Session["user"].ToString() == "black" && ((lastqipandata == 0 || lastqipandata >= 20) || (qipandata > 0 && qipandata <= 20)))return false;int i, j, c;//将|帅if (lastqipandata == 1 || lastqipandata == 21){if ((x - lastx) * (y - lasty) != 0) return false;if(Math.Abs(x - lastx) > 1 || Math.Abs(y - lasty) > 1) return false;if (y < 4 || y > 6 || (x > 3 && x < 8)) return false;return true;}//士|仕if (lastqipandata == 2 || lastqipandata == 3 || lastqipandata == 22 || lastqipandata == 23){if ((x - lastx) * (y - lasty) == 0) return false;if(Math.Abs(x - lastx) > 1 || Math.Abs(y - lasty) > 1) return false;if (y < 4 || y > 6 || (x > 3 && x < 8)) return false;return true;}//象|相if (lastqipandata == 4 || lastqipandata == 5 || lastqipandata == 24 || lastqipandata == 25){if ((x - lastx) * (y - lasty) == 0) return false;if (Math.Abs(x - lastx) != 2 || Math.Abs(y - lasty) != 2) return false;if(Session["user"].ToString() == "red"&& x < 6) return false;if (Session["user"].ToString() == "black" && x > 5) return false;i = 0; j = 0;//i,j必须有初始值if (x - lastx == 2){i = x - 1;}if (x - lastx == -2){i = x + 1;}if (y - lasty == 2){j = y - 1;}if (y - lasty == -2){j = y + 1;}if (_GetDataQipan(i, j) != 0) return false;return true;}//马if (lastqipandata == 6 || lastqipandata == 7 || lastqipandata == 26 || lastqipandata == 27){if (Math.Abs(x - lastx) * Math.Abs(y - lasty) != 2)return false;if (x - lastx == 2){if (_GetDataQipan(x - 1, lasty) != 0)return false;}if (x - lastx == -2){if (_GetDataQipan(x + 1, lasty) != 0)return false;}if (y - lasty == 2){if (_GetDataQipan(lastx, y - 1) != 0)return false;}if (y - lasty == -2){if (_GetDataQipan(lastx, y + 1) != 0)return false;}return true;}//车if (lastqipandata == 8 || lastqipandata == 9 || lastqipandata == 28 || lastqipandata == 29){//判断是否直线if ((x - lastx) * (y - lasty) != 0) return false;//判断是否隔有棋子if (x != lastx){if (lastx > x) { int t = x; x = lastx; lastx = t; }for (i = lastx; i <= x; i += 1){if (i != x && i != lastx){if (_GetDataQipan(i, y) != 0)return false;}}}if (y != lasty){if (lasty > y) { int t = y; y = lasty; lasty = t; }for (j = lasty; j <= y; j += 1){if (j != y && j != lasty){if (_GetDataQipan(x, j) != 0)return false;}}}return true;}//炮if (lastqipandata == 10 || lastqipandata == 11 || lastqipandata == 30 || lastqipandata == 31){bool swapflagx = false;bool swapflagy = false;if ((x - lastx) * (y - lasty) != 0) return false;c = 0;if (x != lastx){if (lastx > x) { int t = x; x = lastx; lastx = t; swapflagx = true; }for (i = lastx; i <= x; i += 1){if (i != x && i != lastx){if (_GetDataQipan(i, y) != 0)c = c + 1;//IsAbleToPut = False: Exit Function}}}if (y != lasty){if (lasty > y) { int t = y; y = lasty; lasty = t; swapflagy = true; }for (j = lasty; j <= y; j += 1){if (j != y && j != lasty){if (_GetDataQipan(x, j) != 0)c = c + 1;//IsAbleToPut = False: Exit Function}}}if (c > 1) return false; //与目标处间隔1个以上棋子if (c == 0) //与目标处无间隔棋子{if(swapflagx == true) { int t = x; x = lastx; lastx = t; }if(swapflagy == true) { int t = y; y = lasty; lasty = t; }if (_GetDataQipan(x, y) != 0) return false;}if (c == 1)//与目标处间隔1个棋子{if(swapflagx == true) { int t = x; x = lastx; lastx = t; }if(swapflagy == true) { int t = y; y = lasty; lasty = t; }// if ((IsMyChess(qipan[x, y]) || qipan[x, y] == 0))//return false;//***********ismychess************************************************** ***************************if (qipandata == 0)return false;}return true;}//卒|兵if (lastqipandata == 12 || lastqipandata == 13 || lastqipandata == 14 || lastqipandata == 15 || lastqipandata == 16 || lastqipandata == 32 || lastqipandata == 33 || lastqipandata == 34 || lastqipandata == 35 || lastqipandata == 36){if ((x - lastx) * (y - lasty) != 0)return false;if(Math.Abs(x - lastx) > 1 || Math.Abs(y - lasty) > 1)return false;if (Session["user"].ToString() == "red" && (x >= 6 && (y - lasty) != 0)) return false;if(Session["user"].ToString() == "black"&& (x <= 5 && (y - lasty) != 0)) return false;if(Session["user"].ToString() == "red"&& (x - lastx > 0)) return false;if(Session["user"].ToString() == "black"&& (x - lastx < 0)) return false;return true;}return false;}//移动棋子private void _MoveChess()//********************************************************需要传递x,y,laastx,lasty{//如果能移动则移动棋子if (_IsAbleToPut()){int x, y, lastx, lasty,qipandata, lastqipandata, tr;tr = 0;x = Getpointx();y = Getpointy();lastx = Getpointlastx();lasty = Getpointlasty();if (Session["user"].ToString() == "black"){x = 11 - x;y = 10 - y;lastx = 11 - lastx;lasty = 10 - lasty;}qipandata = _GetDataQipan(x, y);lastqipandata = _GetDataQipan(lastx, lasty);_UpdataQipan(x, y, lastqipandata);_UpdataQipan(lastx, lasty, tr);if (Session["user"].ToString() == "red"){_UpdataUserState("red", fals);_UpdataUserState("black", tru);}if (Session["user"].ToString() == "black"){_UpdataUserState("red", tru);_UpdataUserState("black", fals);}if (qipandata == 1){Response.Write("<script language=javascript>alert('恭喜您,您赢啦');</script>");_UpdataUserState("red", fals);_UpdataUserState("black", fals);Button6.Enabled = true;_UpdataUserWin("red",20);_UpdataUserWin("black", 40);}if (qipandata == 21){Response.Write("<script language=javascript>alert('恭喜您,您赢啦');</script>");_UpdataUserState("red", fals);_UpdataUserState("black", fals);Button6.Enabled = true;_UpdataUserWin("red", 40);_UpdataUserWin("black", 20);}_UpdataaZuobiao(0, 0, 0, 0);}//如果不能移动则更换已方被点击棋子的背景图片}protected void ImageButton1_Click1(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 1; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton2_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 2; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton3_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 3; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton4_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 4; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton5_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 5; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton6_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 6; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton7_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 7; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton8_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 8; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton9_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 9; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton11_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 1; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton12_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 2; _UpdatZuobiaoXY(x, y);_MoveChess(); _Drawqizi();}protected void ImageButton13_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 3; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton14_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 4; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton15_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 5; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton16_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 6; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton17_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 7; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton18_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 8; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton19_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 9; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton21_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 1; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton22_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 2; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton23_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 3; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton24_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 4; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton25_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 5; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton26_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 6; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton27_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 7; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton28_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 8; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton29_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 9; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton31_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 1; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton32_Click(object sender,ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 2; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton33_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 3; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton34_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 4; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton35_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 5; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton36_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 6; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton37_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 7; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}。
Excel制作五子棋vba源代码

Excel制作象棋vba源代码' The algorithm of judge and urgentpoint function are exported from one VC program which I downloaded from web.' Sorry I can't remebered the program and the author name.' The original VC program have three options for different level. I simplized it to the hardest one in this VBA sample.'Dim m_Board(17, 17) As IntegerPrivate Type Cpointx As Integery As IntegerEnd TypeDim m_nType As IntegerDim iWho As IntegerPrivate Sub Excelba_Click()End SubPrivate Sub cmdStart_Click()Cells(17, 1) = "Start"Cells(17, 3) = 0 ' total number of stones'clear the boardRange(Cells(17 + 1, 1), Cells(17 + 15, 15)).Value = 0'clear all picture in this sheet except for two orginal pictureFor Each ipic In ActiveSheet.ShapesIf <> "Picture 9" And <> "Picture 10" And Left(, 7) = "Picture" Thenipic.DeleteEnd IfNext'start itIf optComputer.Value = True ThenCall drawit(8, 8, 1)Call setarray(8, 8, 1)Cells(17, 3) = 1End IfEnd SubPrivate Sub optComputer_Click()Cells(17, 1) = ""Cells(17, 2) = 2Cells(17, 3) = 0End SubPrivate Sub optYou_Click()Cells(17, 1) = ""Cells(17, 2) = 1Cells(17, 3) = 0End SubPrivate Function confArray(ix As Integer, iy As Integer) As IntegerconfArray = Cells(17 + ix, iy)End FunctionPrivate Sub setarray(ix As Integer, iy As Integer, iz As Integer)Cells(17 + ix, iy) = izEnd SubPrivate Sub drawit(ix As Integer, iy As Integer, iz As Integer)Dim strP As StringIf ix < 1 Or ix > 15 Or iy < 1 Or iy > 15 Or iz < 1 Or iz > 2 ThenMsgBox "Wrong Entry Number, please check it!", vbCritical, "Wrong Entry"EndEnd IfIf iz = 1 ThenstrP = "Picture 9"ElseIf iz = 2 ThenstrP = "Picture 10"End IfApplication.ScreenUpdating = FalseActiveSheet.Shapes(strP).SelectSelection.CopyCells(16, 4).SelectActiveSheet.Paste-(Selection.Left - Cells(ix, iy).Left) + 1-(Selection.Top - Cells(ix, iy).Top) + 1Cells(17, 4).SelectApplication.ScreenUpdating = TrueEnd SubPrivate Function UrgentPoint(ByVal iz As Integer) As StringDim i, i0, j, j0 As IntegerDim ptUrgent(2025) As CpointDim nGrade1 As IntegerDim nGrade2 As IntegerDim nUrgent1 As IntegerDim nUrgent2 As IntegerDim nUrgent As IntegerDim iEnd As IntegerDim iStep As IntegerDim jEnd As IntegerDim jStep As IntegerFor i = 0 To 2024ptUrgent(i).x = -1ptUrgent(i).y = -1Next iIf ((Rnd() * 32767) Mod 2) = 0 Theni0 = 0Elsei0 = 14End IfIf i0 = 0 TheniEnd = 14iStep = 1ElseiEnd = 0iStep = -1End IfFor i = i0 To iEnd Step iStepIf ((Rnd() * 32767) Mod 2) = 0 Thenj0 = 0Elsej0 = 14End IfIf j0 = 0 ThenjEnd = 14jStep = 1ElsejEnd = 0jStep = -1End IfFor j = j0 To jEnd Step jStepIf (m_Board(i, j) = 0) ThennGrade1 = Judge(i, j, iz)nGrade2 = Judge(i, j, iz + 1)Select Case (nGrade1)Case 0nUrgent1 = 0Case 1nUrgent1 = 2Case 2nUrgent1 = 4Case 3nUrgent1 = 5Case 4nUrgent1 = 8Case 5nUrgent1 = 10Case 6nUrgent1 = 11nUrgent1 = 12 Case 8nUrgent1 = 13 Case 9nUrgent1 = 14 Case 10nUrgent1 = 15 Case 11nUrgent1 = 16 Case 12nUrgent1 = 17 Case 13nUrgent1 = 18 Case 14nUrgent1 = 19 Case 15nUrgent1 = 20 Case 16nUrgent1 = 32 Case 17nUrgent1 = 34 Case 18nUrgent1 = 36 Case 19nUrgent1 = 38 Case 20nUrgent1 = 40 Case ElsenUrgent1 = 40 End SelectSelect Case (nGrade2)Case 0nUrgent2 = 1 Case 1nUrgent2 = 3 Case 2nUrgent2 = 6 Case 3nUrgent2 = 7 Case 4nUrgent2 = 9 Case 5nUrgent2 = 21nUrgent2 = 22Case 7nUrgent2 = 23Case 8nUrgent2 = 24Case 9nUrgent2 = 25Case 10nUrgent2 = 26Case 11nUrgent2 = 27Case 12nUrgent2 = 28Case 13nUrgent2 = 29Case 14nUrgent2 = 30Case 15nUrgent2 = 31Case 16nUrgent2 = 33Case 17nUrgent2 = 35Case 18nUrgent2 = 37Case 19nUrgent2 = 39Case 20nUrgent2 = 41Case ElsenUrgent2 = 41End SelectnUrgent = WorksheetFunction.Min(nUrgent1, nUrgent2) * 45 + WorksheetFunction.Max(nUrgent1, nUrgent2)ptUrgent(nUrgent).x = iptUrgent(nUrgent).y = jEnd IfNext jNext iFor i = 0 To 2024If ((ptUrgent(i).x <> -1) And (ptUrgent(i).y <> -1)) ThenExit ForEnd IfNext iIf (ptUrgent(i).x = -1 And ptUrgent(i).y = -1) ThenMsgBox "Make Draw"End IfUrgentPoint = ptUrgent(i).x & "|" & ptUrgent(i).yEnd FunctionPrivate Sub Worksheet_SelectionChange(ByVal Target As Range)Dim ix As IntegerDim iy As IntegerDim iz As IntegerDim ix1 As IntegerDim iy1 As IntegerDim stmp As StringDim i As IntegerDim j As IntegerIf > 1 Or Target.Areas(1).Columns.Count > 1 Or Target.Areas(1).Rows.Count > 1 Then Exit SubEnd Ifix = Target.Areas(1).Rowiy = Target.Areas(1).Columniz = confArray(ix, iy)If ix > 15 Or iy > 15 ThenExit SubEnd IfIf iz <> 1 And iz <> 2 And Cells(17, 1) = "Start" ThenFor i = 0 To 14For j = 0 To 14m_Board(j, i) = Cells(17 + i + 1, j + 1)Next jNext iCall drawit(ix, iy, 2)Call setarray(ix, iy, 2)m_Board(iy - 1, ix - 1) = 2Call Judge(iy - 1, ix - 1, 2)Call ringIf Cells(17, 1) = "Start" Thenstmp = UrgentPoint(1)iy1 = Left(stmp, InStr(1, stmp, "|") - 1)ix1 = Mid(stmp, InStr(1, stmp, "|") + 1)Call drawit(ix1 + 1, iy1 + 1, 1)Call setarray(ix1 + 1, iy1 + 1, 1)m_Board(iy1, ix1) = 1Call Judge(iy1, ix1, 1)Call ringEnd IfEnd IfEnd SubPrivate Function Judge(ByVal nX As Integer, ByVal nY As Integer, ByVal cValue As Integer) As IntegerDim nGrade As IntegerDim i As IntegerDim j As IntegerDim k As IntegerDim l As IntegerDim nXStart As IntegerDim nXEnd As IntegerDim nYStart As IntegerDim nYEnd As IntegerDim nXYStart As IntegerDim nXYEnd As IntegerDim nYXStart As IntegerDim nYXEnd As IntegerDim nXStartAdd As IntegerDim nYStartAdd As IntegerDim nXYStartAdd As IntegerDim nYXStartAdd As IntegerDim nXEndAdd As IntegerDim nYEndAdd As IntegerDim nXYEndAdd As IntegerDim nYXEndAdd As IntegerDim bXStartEmpty As BooleanDim bXEndEmpty As BooleanDim bXStartEmpty1 As BooleanDim bXEndEmpty1 As BooleanDim bYStartEmpty As BooleanDim bYEndEmpty As BooleanDim bYStartEmpty1 As BooleanDim bYEndEmpty1 As BooleanDim bXYStartEmpty As BooleanDim bXYEndEmpty As BooleanDim bXYStartEmpty1 As BooleanDim bXYEndEmpty1 As BooleanDim bYXStartEmpty As BooleanDim bYXEndEmpty As BooleanDim bYXStartEmpty1 As BooleanDim bYXEndEmpty1 As BooleannXStart = nXnXEnd = nXnYStart = nYnYEnd = nYnXYStart = nXnXYEnd = nXnYXStart = nXnYXEnd = nXnXStartAdd = 0nYStartAdd = 0nXYStartAdd = 0nYXStartAdd = 0nXEndAdd = 0nYEndAdd = 0nXYEndAdd = 0nYXEndAdd = 0bXStartEmpty = FalsebYStartEmpty = FalsebXYStartEmpty = FalsebYXStartEmpty = FalsebXEndEmpty = FalsebYEndEmpty = FalsebXYEndEmpty = FalsebYXEndEmpty = FalsebXStartEmpty1 = FalsebYStartEmpty1 = FalsebXYStartEmpty1 = FalsebYXStartEmpty1 = FalsebXEndEmpty1 = FalsebYEndEmpty1 = FalsebXYEndEmpty1 = FalsebYXEndEmpty1 = FalseFor i = nX - 1 To 0 Step -1 ' <-If m_Board(i, nY) = cV alue ThennXStart = iElseIf m_Board(i, nY) = 0 ThenbXStartEmpty = TrueFor j = i - 1 To 0 Step -1 ' <-If m_Board(j, nY) = cValue ThennXStartAdd = i - jElseIf m_Board(j, nY) = 0 ThenbXStartEmpty1 = TrueExit ForElseExit ForEnd IfNext jExit ForElseExit ForEnd IfNext iFor i = nX + 1 To 14 ' ->If m_Board(i, nY) = cV alue ThennXEnd = iElseIf m_Board(i, nY) = 0 ThenbXEndEmpty = TrueFor j = i + 1 To 14 ' ->If m_Board(j, nY) = cValue ThennXEndAdd = j - iElseIf m_Board(j, nY) = 0 ThenbXEndEmpty1 = TrueExit ForElseExit ForEnd IfNext jExit ForElseExit ForEnd IfNext iFor i = nY - 1 To 0 Step -1 ' ^|^If m_Board(nX, i) = cV alue ThennYStart = iElseIf m_Board(nX, i) = 0 ThenbYStartEmpty = TrueFor j = i - 1 To 0 Step -1 ' <-If m_Board(nX, j) = cValue ThennYStartAdd = i - jElseIf m_Board(nX, j) = 0 ThenbYStartEmpty1 = TrueExit ForElseExit ForEnd IfNext jExit ForElseExit ForEnd IfNext iFor i = nY + 1 To 14 ' v|vIf m_Board(nX, i) = cV alue ThennYEnd = iElseIf m_Board(nX, i) = 0 ThenbYEndEmpty = TrueFor j = i + 1 To 14 ' ->If m_Board(nX, j) = cValue ThennYEndAdd = j - iElseIf m_Board(nX, j) = 0 ThenbYEndEmpty1 = TrueExit ForElseExit ForEnd IfNext jExit ForElseExit ForEnd IfNext ii = nX - 1j = nY + 1Do While i >= 0 And j < 15'j++If m_Board(i, j) = cValue ThennXYStart = iElseIf m_Board(i, j) = 0 ThenbXYStartEmpty = Truek = i - 1l = j + 1Do While k >= 0 And l < 15If m_Board(k, l) = cValue ThennXYStartAdd = i - kElseIf m_Board(k, l) = 0 ThenbXYStartEmpty1 = TrueExit DoElseExit DoEnd Ifk = k - 1l = l + 1LoopElseExit DoEnd Ifi = i - 1j = j + 1Loopi = nX + 1j = nY - 1Do While i < 15 And j >= 0'j--If m_Board(i, j) = cValue ThennXYEnd = iElseIf m_Board(i, j) = 0 ThenbXYEndEmpty = Truek = i + 1l = j - 1Do While l >= 0 And k < 15If m_Board(k, l) = cValue ThennXYEndAdd = i - kElseIf m_Board(k, l) = 0 ThenbXYEndEmpty1 = TrueExit DoElseExit DoEnd Ifk = k + 1l = l - 1LoopExit DoElseExit DoEnd Ifi = i + 1j = j - 1Loopi = nX - 1j = nY - 1Do While i >= 0 And j >= 0'j--If m_Board(i, j) = cValue ThennYXStart = iElseIf m_Board(i, j) = 0 ThenbYXStartEmpty = Truel = j - 1Do While l >= 0 And k >= 0If m_Board(k, l) = cValue ThennYXStartAdd = i - kElseIf m_Board(k, l) = 0 ThenbYXStartEmpty1 = TrueExit DoElseExit DoEnd Ifk = k - 1l = l - 1LoopExit DoElseExit DoEnd Ifi = i - 1j = j - 1Loopi = nX + 1j = nY + 1Do While i < 15 And j < 15'j--If m_Board(i, j) = cValue ThennYXEnd = iElseIf m_Board(i, j) = 0 ThenbYXEndEmpty = Truek = i - 1l = j - 1Do While l < 15 And k < 15If m_Board(k, l) = cValue ThennYXEndAdd = i - kElseIf m_Board(k, l) = 0 ThenbYXEndEmpty1 = TrueExit DoElseExit DoEnd Ifk = k + 1l = l + 1LoopExit DoElseExit DoEnd Ifi = i + 1j = j + 1LoopnXStep = nXEnd - nXStart + 1nXStep = nXEnd - nXStart + 1nYStep = nYEnd - nYStart + 1nXYStep = nXYEnd - nXYStart + 1nYXStep = nYXEnd - nYXStart + 1Dim bX_4 As BooleanDim bY_4 As BooleanDim bXY_4 As BooleanDim bYX_4 As BooleanDim bX4 As BooleanDim bY4 As BooleanDim bXY4 As BooleanDim bYX4 As BooleanbX_4 = (nXStep = 4) And (bXStartEmpty And bXEndEmpty)bY_4 = (nYStep = 4) And (bYStartEmpty And bYEndEmpty)bXY_4 = (nXYStep = 4) And (bXYStartEmpty And bXYEndEmpty) bYX_4 = (nYXStep = 4) And (bYXStartEmpty And bYXEndEmpty) bX4 = (nXStep = 4) And (bXStartEmpty Or bXEndEmpty)bY4 = (nYStep = 4) And (bYStartEmpty Or bYEndEmpty)bXY4 = (nXYStep = 4) And (bXYStartEmpty Or bXYEndEmpty) bYX4 = (nYXStep = 4) And (bYXStartEmpty Or bYXEndEmpty) Dim bX_3 As BooleanDim bY_3 As BooleanDim bXY_3 As BooleanDim bYX_3 As BooleanDim bX3 As BooleanDim bY3 As BooleanDim bXY3 As BooleanDim bYX3 As BooleanbX_3 = (nXStep = 3) And (bXStartEmpty And bXEndEmpty)bY_3 = (nYStep = 3) And (bYStartEmpty And bYEndEmpty)bXY_3 = (nXYStep = 3) And (bXYStartEmpty And bXYEndEmpty) bYX_3 = (nYXStep = 3) And (bYXStartEmpty And bYXEndEmpty) bX3 = (nXStep = 3) And (bXStartEmpty Or bXEndEmpty)bY3 = (nYStep = 3) And (bYStartEmpty Or bYEndEmpty)bXY3 = (nXYStep = 3) And (bXYStartEmpty Or bXYEndEmpty) bYX3 = (nYXStep = 3) And (bYXStartEmpty Or bYXEndEmpty) Dim bX_2 As BooleanDim bY_2 As BooleanDim bXY_2 As BooleanDim bYX_2 As BooleanDim bX2 As BooleanDim bY2 As BooleanDim bXY2 As BooleanDim bYX2 As BooleanbX_2 = (nXStep = 2) And (bXStartEmpty And bXEndEmpty)bY_2 = (nYStep = 2) And (bYStartEmpty And bYEndEmpty)bXY_2 = (nXYStep = 2) And (bXYStartEmpty And bXYEndEmpty) bYX_2 = (nYXStep = 2) And (bYXStartEmpty And bYXEndEmpty) bX2 = (nXStep = 2) And (bXStartEmpty Or bXEndEmpty)bY2 = (nYStep = 2) And (bYStartEmpty Or bYEndEmpty)bXY2 = (nXYStep = 2) And (bXYStartEmpty Or bXYEndEmpty) bYX2 = (nYXStep = 2) And (bYXStartEmpty Or bYXEndEmpty) Dim bX_1 As BooleanDim bY_1 As BooleanDim bXY_1 As BooleanDim bYX_1 As BooleanbX_1 = (nXStep = 1) And (bXStartEmpty And bXEndEmpty)bY_1 = (nYStep = 1) And (bYStartEmpty And bYEndEmpty)bXY_1 = (nXYStep = 1) And (bXYStartEmpty And bXYEndEmpty) bYX_1 = (nYXStep = 1) And (bYXStartEmpty And bYXEndEmpty) Dim nXAdd As IntegerDim nYAdd As IntegerDim nXYAdd As IntegerDim nYXAdd As IntegernXAdd = 0nYAdd = 0nXYAdd = 0nYXAdd = 0If nXEndAdd >= nXStartAdd ThennXAdd = nXEndAddbXEndEmpty = bXEndEmpty1ElsenXAdd = nXStartAddbXStartEmpty = bXStartEmpty1End IfIf (nYEndAdd >= nYStartAdd) ThennYAdd = nYEndAddbYEndEmpty = bYEndEmpty1ElsenYAdd = nYStartAddbYStartEmpty = bYStartEmpty1End IfIf (nXYEndAdd >= nXYStartAdd) ThennXYAdd = nXYEndAddbXYEndEmpty = bXYEndEmpty1ElsenXYAdd = nXYStartAddbXYStartEmpty = bXYStartEmpty1End IfIf (nYXEndAdd >= nYXStartAdd) ThennYXAdd = nYXEndAddbYXEndEmpty = bYXEndEmpty1ElsenYXAdd = nYXStartAddbYXStartEmpty = bYXStartEmpty1End IfDim b1X_4 As BooleanDim b1Y_4 As BooleanDim b1XY_4 As BooleanDim b1YX_4 As BooleanDim b1X4 As BooleanDim b1Y4 As BooleanDim b1XY4 As BooleanDim b1YX4 As Booleanb1X_4 = (nXStep + nXAdd >= 4) And (bXStartEmpty And bXEndEmpty)b1Y_4 = (nYStep + nY Add >= 4) And (bYStartEmpty And bYEndEmpty)b1XY_4 = (nXYStep + nXYAdd >= 4) And (bXYStartEmpty And bXYEndEmpty) b1YX_4 = (nYXStep + nYXAdd >= 4) And (bYXStartEmpty And bYXEndEmpty) b1X4 = (nXStep + nXAdd >= 4) And (bXStartEmpty Or bXEndEmpty)b1Y4 = (nYStep + nY Add >= 4) And (bYStartEmpty Or bYEndEmpty)b1XY4 = (nXYStep + nXY Add >= 4) And (bXYStartEmpty Or bXYEndEmpty)b1YX4 = (nYXStep + nYXAdd >= 4) And (bYXStartEmpty Or bYXEndEmpty) Dim b1X_3 As BooleanDim b1Y_3 As BooleanDim b1XY_3 As BooleanDim b1YX_3 As Booleanb1X_3 = (nXStep + nXAdd >= 3) And (bXStartEmpty And bXEndEmpty)b1Y_3 = (nYStep + nY Add >= 3) And (bYStartEmpty And bYEndEmpty)b1XY_3 = (nXYStep + nXYAdd >= 3) And (bXYStartEmpty And bXYEndEmpty) b1YX_3 = (nYXStep + nYXAdd >= 3) And (bYXStartEmpty And bYXEndEmpty) m_nType = -1'////////If (nXStep >= 5) Or (nYStep >= 5) Or (nXYStep >= 5) Or (nYXStep >= 5) Then nGrade = 0m_nType = 0ElseIf (bX_4 Or bY_4 Or bXY_4 Or bYX_4) ThennGrade = 1m_nType = 1ElseIf ((bX4 And (bY4 Or bXY4 Or bYX4 Or b1Y4 Or b1XY4 Or b1YX4)) Or _(bY4 And (bX4 Or bXY4 Or bYX4 Or b1X4 Or b1XY4 Or b1YX4)) Or _(bXY4 And (bY4 Or bX4 Or bYX4 Or b1Y4 Or b1X4 Or b1YX4)) Or _(bYX4 And (bY4 Or bXY4 Or bX4 Or b1Y4 Or b1XY4 Or b1X4)) Or _(b1X4 And (bY4 Or bXY4 Or bYX4 Or b1Y4 Or b1XY4 Or b1YX4)) Or _(b1Y4 And (bX4 Or bXY4 Or bYX4 Or b1X4 Or b1XY4 Or b1YX4)) Or _(b1XY4 And (bY4 Or bX4 Or bYX4 Or b1Y4 Or b1X4 Or bYX4)) Or _(b1YX4 And (bY4 Or bXY4 Or bX4 Or b1Y4 Or b1XY4 Or b1X4))) Then nGrade = 2m_nType = 1ElseIf ((bX4 And (bY_3 Or bXY_3 Or bYX_3 Or b1Y_3 Or b1XY_3 Or b1YX_3)) Or _ (bY4 And (bX_3 Or bXY_3 Or bYX_3 Or b1X_3 Or b1XY_3 Or b1YX_3)) Or _(bXY4 And (bY_3 Or bX_3 Or bYX_3 Or b1Y_3 Or b1X_3 Or b1YX_3)) Or _(bYX4 And (bY_3 Or bXY_3 Or bX_3 Or b1Y_3 Or b1XY_3 Or b1X_3)) Or _(b1X4 And (bY_3 Or bXY_3 Or bYX_3 Or b1Y_3 Or b1XY_3 Or b1YX_3)) Or _(b1Y4 And (bX_3 Or bXY_3 Or bYX_3 Or b1X_3 Or b1XY_3 Or b1YX_3)) Or _(b1XY4 And (bY_3 Or bX_3 Or bYX_3 Or b1Y_3 Or b1X_3 Or b1YX_3)) Or _(b1YX4 And (bY_3 Or bXY_3 Or bX_3 Or b1Y_3 Or b1XY_3 Or b1X_3))) ThennGrade = 3m_nType = 1ElseIf ((bX_3 And (bY_3 Or bXY_3 Or bYX_3 Or b1Y_3 Or b1XY_3 Or b1YX_3)) Or _ (bY_3 And (bX_3 Or bXY_3 Or bYX_3 Or b1X_3 Or b1XY_3 Or b1YX_3)) Or _(bXY_3 And (bY_3 Or bX_3 Or bYX_3 Or b1Y_3 Or b1X_3 Or b1YX_3)) Or _(bYX_3 And (bY_3 Or bXY_3 Or bX_3 Or b1Y_3 Or b1XY_3 Or b1X_3)) Or _(b1X_3 And (bY_3 Or bXY_3 Or bYX_3 Or b1Y_3 Or b1XY_3 Or b1YX_3)) Or _(b1Y_3 And (bX_3 Or bXY_3 Or bYX_3 Or b1X_3 Or b1XY_3 Or b1YX_3)) Or _(b1XY_3 And (bY_3 Or bX_3 Or bYX_3 Or b1Y_3 Or b1X_3 Or b1YX_3)) Or _(b1YX_3 And (bY_3 Or bXY_3 Or bX_3 Or b1Y_3 Or b1XY_3 Or b1X_3))) ThennGrade = 4m_nType = 2ElseIf ((bXY4 And (bYX_2 Or bY_2 Or bX_2)) Or _(bYX4 And (bXY_2 Or bY_2 Or bX_2)) Or _(bX4 And (bXY_2 Or bYX_2 Or bY_2)) Or _(bY4 And (bXY_2 Or bYX_2 Or bX_2))) ThennGrade = 5m_nType = 1ElseIf ((bXY4 And (bYX3 Or bY3 Or bX3)) Or _(bYX4 And (bXY3 Or bY3 Or bX3)) Or _(bX4 And (bXY3 Or bYX3 Or bY3)) Or _(bY4 And (bXY3 Or bYX3 Or bX3))) Then nGrade = 6m_nType = 1ElseIf ((bXY4 And (bYX_1 Or bY_1 Or bX_1)) Or _(bYX4 And (bXY_1 Or bY_1 Or bX_1)) Or _(bX4 And (bXY_1 Or bYX_1 Or bY_1)) Or _(bY4 And (bXY_1 Or bYX_1 Or bX_1))) Then nGrade = 7m_nType = 2ElseIf ((bXY4 And (bYX2 Or bY2 Or bX2)) Or _(bYX4 And (bXY2 Or bY2 Or bX2)) Or _(bX4 And (bXY2 Or bYX2 Or bY2)) Or _(bY4 And (bXY2 Or bYX2 Or bX2))) Then nGrade = 8m_nType = 1ElseIf (bXY4 Or bYX4 Or bX4 Or bY4) ThennGrade = 9m_nType = 1ElseIf ((bXY_3 And (bYX_2 Or bY_2 Or bX_2)) Or _(bYX_3 And (bXY_2 Or bY_2 Or bX_2)) Or _(bX_3 And (bXY_2 Or bYX_2 Or bY_2)) Or _(bY_3 And (bXY_2 Or bYX_2 Or bX_2))) Then nGrade = 10m_nType = 2ElseIf ((bXY_3 And (bYX3 Or bY3 Or bX3)) Or _(bYX_3 And (bXY3 Or bY3 Or bX3)) Or _(bX_3 And (bXY3 Or bYX3 Or bY3)) Or _(bY_3 And (bXY3 Or bYX3 Or bX3))) Then nGrade = 11m_nType = 2ElseIf ((bXY_3 And (bYX_1 Or bY_1 Or bX_1)) Or _(bYX_3 And (bXY_1 Or bY_1 Or bX_1)) Or _(bX_3 And (bXY_1 Or bYX_1 Or bY_1)) Or _(bY_3 And (bXY_1 Or bYX_1 Or bX_1))) Then nGrade = 12m_nType = 2ElseIf ((bXY_3 And (bYX2 Or bY2 Or bX2)) Or _(bYX_3 And (bXY2 Or bY2 Or bX2)) Or _(bX_3 And (bXY2 Or bYX2 Or bY2)) Or _(bY_3 And (bXY2 Or bYX2 Or bX2))) ThennGrade = 13m_nType = 2ElseIf (bXY_3 Or bYX_3 Or bX_3 Or bY_3) ThennGrade = 14m_nType = 2ElseIf (bXY_2 Or bYX_2 Or bX_2 Or bY_2) ThennGrade = 16ElseIf (bXY3 Or bYX3 Or bX3 Or bY3) ThennGrade = 17ElseIf (bXY2 Or bYX2 Or bX2 Or bY2) ThennGrade = 18ElseIf (bXY_1 Or bYX_1 Or bX_1 Or bY_1) ThennGrade = 19ElsenGrade = 20End IfIf (nGrade > 15) ThenIf (((nX - 2) >= 0) And ((nY - 2) >= 0)) ThenIf ((m_Board(nX, nY - 1) = 0 Or m_Board(nX, nY - 1) = cValue) And _(m_Board(nX + 1, nY) = 0 Or m_Board(nX + 1, nY) = cValue) And _(m_Board(nX, nY + 1) = 0 Or m_Board(nX, nY + 1) = cValue) And _(m_Board(nX - 1, nY) = 0 Or m_Board(nX - 1, nY) = cValue) And _((nX + 2 < 15 And nY - 2 >= 0 And (m_Board(nX + 2, nY - 2) = 0 Or m_Board(nX + 2, nY - 2) = cValue) And _m_Board(nX, nY - 2) = cValue And m_Board(nX + 1, nY - 1) = cValue And m_Board(nX + 2, nY) = cValue) Or _(nX + 2 < 15 And nY + 2 < 15 And (m_Board(nX + 2, nY + 2) = 0 Or m_Board(nX + 2, nY + 2) = cValue) And _m_Board(nX, nY + 2) = cV alue And m_Board(nX + 1, nY + 1) = cValue And m_Board(nX + 2, nY) = cValue) Or _(nX - 2 >= 0 And nY + 2 < 15 And (m_Board(nX - 2, nY + 2) = 0 Or m_Board(nX - 2, nY + 2) = cValue) And _m_Board(nX, nY + 2) = cValue And m_Board(nX - 1, nY + 1) = cV alue And m_Board(nX - 2, nY) = cValue) Or _(nX - 2 >= 0 And nY - 2 >= 0 And (m_Board(nX - 2, nY - 2) = 0 Or m_Board(nX - 2, nY - 2) = cValue) And _m_Board(nX, nY - 2) = cV alue And m_Board(nX - 1, nY - 1) = cValue And m_Board(nX - 2, nY) = cValue))) ThennGrade = 15End IfEnd IfEnd IfiWho = cValueJudge = nGradeEnd FunctionPrivate Sub ring()Cells(17, 3) = Cells(17, 3) + 1If m_nType = 0 ThenIf iWho = 2 ThenIf Cells(17, 3) < 16 ThenMsgBox "Congratulation!! You win by only total " & Cells(17, 3) & " stones, you are cool!"ElseMsgBox "Congratulation!! You win by total " & Cells(17, 3) & " stones, still OK!"End IfElseIf Cells(17, 3) < 16 ThenMsgBox "Sorry!! Computer win by only total " & Cells(17, 3) & " stones, you are bad player!"ElseMsgBox "Sorry!! Computer win by total " & Cells(17, 3) & " stones, you need more practices!"End IfEnd IfCells(17, 1) = ""Cells(17, 3) = 0Range(Cells(17 + 1, 1), Cells(17 + 15, 15)).Value = 0EndEnd IfEnd Sub。
联网式-中国象棋VB源代码 萨云轩 工作室

Option ExplicitPublic bIsNet As BooleanConst FF_EMP = -1Const FF_SIDE1 = 0Const FF_SIDE2 = 1Dim local_side As IntegerDim pos_side As IntegerDim Chess_On As IntegerConst FF_US_INITALL = 0Const FF_US_INITNET = 1Const FF_US_INITLOCAL = 2Const FF_US_NET_CON = 3Const FF_US_USE_CON = 4Dim b_Server As BooleanDim b_isCon As BooleanPublic m_Set As StringDim m_BeSet As String'USER STA TEEnum FF_UA_STA TEFF_UA_INITFF_UA_WAITINGFF_UA_USEFF_UA_INV ALIDEnd EnumDim m_State As FF_UA_STA TEPrivate Sub TransSide(ByRef side As Integer) If side = FF_SIDE1 Thenside = FF_SIDE2Elseside = FF_SIDE1End IfEnd SubPrivate Sub TransState(method As Integer) main.WindowState = vbNormalSelect Case methodCase FF_US_INITALLInitalBoardm_State = FF_UA_INV ALIDc_MunNew.V isible = Falsec_MunLoad.Enabled = Truec_eState.Text = ""c_eMsg.Text = ""c_CmdSay.Enabled = Falsec_MunShow.Checked = bIsNetpos_side = FF_SIDE1Chess_On = FF_EMPc_spChessOn.V isible = Falsec_sUse.Closeb_isCon = FalseCase FF_US_INITNETfrm_net.V isible = Truemain.Width = 8835pic_noclick.Visible = Truepic_click.Visible = Falsec_sColor.FillColor = &H8000000Fc_CmdCon.Enabled = TrueCase FF_US_INITLOCALfrm_net.V isible = Falsemain.Width = 5880pic_noclick.Visible = Falsepic_click.Visible = Truec_sColor.FillColor = vbRedlocal_side = FF_SIDE1Case FF_US_NET_CONc_CmdSay.Enabled = Trueb_isCon = Truec_CmdCon.Enabled = Falsec_eState.Text = "网络连接成功" Case FF_US_USE_CONm_State = FF_UA_USEc_MunLoad.Enabled = Falsec_MunNew.V isible = Falsec_eState.Text = "开始"End SelectEnd SubPrivate Sub InitalBoard()Dim i As IntegerDim x_step, d_step As Integerx_step = 0d_step = -1For i = 0 To 8c_chess(i).Top = 0c_chess(i).Left = 2595 + x_step * d_stepc_chess(i + 16).Top = 5400c_chess(i + 16).Left = c_chess(i).LeftIf (i / 2 = Int(i / 2)) Then x_step = x_step + 600d_step = -d_stepNext iFor i = 0 To 1c_chess(i + 9).Top = 1200c_chess(i + 9).Left = 795 + i * 3600c_chess(i + 25).Top = 4200c_chess(i + 25).Left = c_chess(i + 9).LeftNext iFor i = 0 To 4c_chess(i + 11).Top = 1800c_chess(i + 11).Left = 195 + i * 1200c_chess(i + 27).Top = 3600c_chess(i + 27).Left = c_chess(i + 11).LeftNext iFor i = 0 To 31c_chess(i).V isible = TrueNext iEnd SubPrivate Function DuiJiang() As BooleanDim i, count, temp As IntegerIf Not c_chess(0).Left = c_chess(16).Left ThenDuiJiang = FalseExit FunctionEnd Iftemp = Sgn(c_chess(16).Top - c_chess(0).Top)count = 0For i = c_chess(0).Top / 600 + temp To c_chess(16).Top / 600 - temp Step temp If FindChessInPos((c_chess(0).Left - 195) / 600, i) > -1 Then count = count + 1 Next iIf count = 0 ThenDuiJiang = TrueExit FunctionEnd IfDuiJiang = FalseEnd FunctionPrivate Sub Die(ByV al chess_die As Integer)If chess_die = 0 ThenMsgBox "黑方输了", vbOKOnly, App.LegalTrademarksElseMsgBox "红方输了", vbOKOnly, App.LegalTrademarksEnd IfIf bIsNet = True ThenInitalBoardm_State = FF_UA_INITc_MunNew.V isible = Truec_MunLoad.Enabled = Truec_eState.Text = ""c_eMsg.Text = ""c_CmdSay.Enabled = Truec_MunShow.Checked = bIsNetpos_side = FF_SIDE1Chess_On = FF_EMPc_spChessOn.V isible = Falsefrm_net.V isible = Truepic_noclick.Visible = Truepic_click.Visible = Falsec_sColor.FillColor = &H8000000FElseTransState FF_US_INITALLTransState FF_US_INITLOCALEnd IfEnd SubPrivate Function GoChess(ByV al chess As Integer, ByV al x_off As Integer _ , ByV al y_off As Integer) As BooleanDim use_side As IntegerDim x_begin, y_begin As IntegerDim Distent As SingleDim i As IntegerIf chess > 15 Thenuse_side = FF_SIDE2Elseuse_side = FF_SIDE1End Ifx_begin = (c_chess(chess).Left - 195) / 600y_begin = (c_chess(chess).Top) / 600Distent = Sqr((x_off - x_begin) ^ 2 + (y_off - y_begin) ^ 2)Select Case Int((chess - use_side * 16 + 1) / 2)Case 0 'jianIf Distent > 1 Then GoTo errhandleIf x_off < 3 Or x_off > 5 Then GoTo errhandleIf GetSelf(chess, y_off) > 2 Then GoTo errhandlec_chess(chess).Left = x_off * 600 + 195If DuiJiang = True ThenMsgBox "Can Not this col", vbOKOnly, App.LegalTrademarksc_chess(chess).Left = x_begin * 600 + 195GoTo errhandleEnd IfCase 1 'shiIf Distent < 1.4 Or Distent > 1.5 Then GoTo errhandleIf x_off < 3 Or x_off > 5 Then GoTo errhandleIf GetSelf(chess, y_off) > 2 Then GoTo errhandleCase 2 'xiangIf Distent < 2.8 Or Distent > 2.9 Then GoTo errhandleIf GetSelf(chess, y_off) > 4 Then GoTo errhandleIf FindChessInPos((x_off + x_begin) / 2, (y_begin + y_off) / 2) > -1 Then GoTo errhandle Case 3 'maIf Distent < 2.2 Or Distent > 2.3 Then GoTo errhandleIf FindChessInPos(x_off - Sgn(x_off - x_begin), y_off - Sgn(y_off - y_begin)) > -1 Then GoTo errhandleCase 4 'cheIf (Not x_begin = x_off) And (Not y_begin = y_off) Then GoTo errhandleIf x_begin = x_off ThenFor i = y_begin + Sgn(y_off - y_begin) To y_off - Sgn(y_off - y_begin) Step Sgn(y_off - y_begin)If Not FindChessInPos(x_off, i) = -1 Then GoTo errhandleNext iEnd IfIf y_begin = y_off ThenFor i = x_begin + Sgn(x_off - x_begin) To x_off - Sgn(x_off - x_begin) Step Sgn(x_off - x_begin)If Not FindChessInPos(i, y_off) = -1 Then GoTo errhandleNext iEnd IfCase 5 'paoIf (Not x_begin = x_off) And (Not y_begin = y_off) Then GoTo errhandleIf x_begin = x_off ThenFor i = y_begin + Sgn(y_off - y_begin) To y_off Step Sgn(y_off - y_begin) If Not FindChessInPos(x_off, i) = -1 Then GoTo errhandleNext iEnd IfIf y_begin = y_off ThenFor i = x_begin + Sgn(x_off - x_begin) To x_off Step Sgn(x_off - x_begin) If Not FindChessInPos(i, y_off) = -1 Then GoTo errhandleNext iEnd IfCase Else 'bingIf Distent > 1 Then GoTo errhandleIf GetSelf(chess, y_off) < GetSelf(chess, y_begin) Then GoTo errhandleIf GetSelf(chess, y_off) < 5 And (Not x_off = x_begin) Then GoTo errhandle End Selectc_chess(chess).Left = x_off * 600 + 195c_chess(chess).Top = y_off * 600If bIsNet = False ThenTransSide local_sideIf c_sColor.FillColor = vbRed Thenc_sColor.FillColor = vbBlueElsec_sColor.FillColor = vbRedEnd IfElsepic_click.Visible = Not pic_click.Visiblepic_noclick.Visible = Not pic_click.VisibleEnd IfTransSide pos_sideGoChess = TrueExit Functionerrhandle:GoChess = FalseEnd FunctionPrivate Function FindChessInPos(ByV al X As Integer, ByV al Y As Integer) As Integer Dim i As IntegerFor i = 0 To 31If c_chess(i).V isible = True And c_chess(i).Top / 600 = Y And (c_chess(i).Left - 195) / 600 = X ThenFindChessInPos = iExit FunctionEnd IfNext iFindChessInPos = -1End FunctionPrivate Sub TransBoard()Dim i, x_off, y_off As IntegerFor i = 0 To 31x_off = (c_chess(i).Left - 195) / 600x_off = 8 - x_offy_off = c_chess(i).Top / 600y_off = 9 - y_offc_chess(i).Left = x_off * 600 + 195c_chess(i).Top = y_off * 600Next iEnd SubPrivate Function GetSelf(ByV al chess As Integer, ByV al Y As Integer) As IntegerDim temp_side As IntegerIf bIsNet = True Thentemp_side = Int(chess / 16)If Not local_side = temp_side ThenGetSelf = 9 - YElseGetSelf = YEnd IfElseIf chess > 15 ThenGetSelf = 9 - YElseGetSelf = YEnd IfEnd IfEnd FunctionPrivate Sub c_chess_Click(Index As Integer)If (bIsNet = True) And (Not m_State = FF_UA_USE) Then Exit SubIf Not pos_side = local_side Then Exit SubDim i As IntegerDim count As IntegerDim x_off, y_off, x_begin, y_begin As Integerx_off = (c_chess(Index).Left - 195) / 600y_off = (c_chess(Index).Top) / 600If Not Int(Index / 16) = local_side ThenChess_On = Indexc_spChessOn.Left = c_chess(Chess_On).Left - 60c_spChessOn.Top = c_chess(Chess_On).Top - 60c_spChessOn.V isible = TrueElseIf Chess_On = FF_EMP Then Exit SubIf GoChess(Chess_On, x_off, y_off) = True ThenIf bIsNet = True And m_State = FF_UA_USE Then c_sUse.SendData _"Post " + Chr(Chess_On + 65) + Chr(x_off + 48) + Chr(y_off + 48) c_chess(Index).V isible = FalseIf Index = 0 Or Index = 16 ThenDie IndexExit SubEnd IfChess_On = FF_EMPc_spChessOn.V isible = FalseElseIf Chess_On = 9 Or Chess_On = 10 Or Chess_On = 25 Or Chess_On = 25 Or Chess_On = 26 Thenx_begin = (c_chess(Chess_On).Left - 195) / 600y_begin = (c_chess(Chess_On).Top) / 600count = 0If (Not x_begin = x_off) And (Not y_begin = y_off) Then Exit SubIf x_begin = x_off ThenFor i = y_begin + Sgn(y_off - y_begin) To y_off - Sgn(y_off - y_begin) Step Sgn(y_off - y_begin)If Not FindChessInPos(x_off, i) = -1 Then count = count + 1Next iEnd IfIf y_begin = y_off ThenFor i = x_begin + Sgn(x_off - x_begin) To x_off - Sgn(x_off - x_begin) Step Sgn(x_off - x_begin)If Not FindChessInPos(i, y_off) = -1 Then count = count + 1Next iEnd IfEnd IfEnd IfIf count = 1 ThenIf bIsNet = True And m_State = FF_UA_USE Then c_sUse.SendData _ "Post " + Chr(Chess_On + 65) + Chr(x_off + 48) + Chr(y_off + 48) c_chess(Chess_On).Top = c_chess(Index).Topc_chess(Chess_On).Left = c_chess(Index).Leftc_chess(Index).V isible = FalseIf Index = 0 Or Index = 16 ThenDie IndexExit SubEnd IfChess_On = FF_EMPc_spChessOn.V isible = FalseIf bIsNet = False ThenTransSide local_sideIf c_sColor.FillColor = vbRed Thenc_sColor.FillColor = vbBlueElsec_sColor.FillColor = vbRedEnd IfElsepic_click.Visible = Not pic_click.Visiblepic_noclick.Visible = Not pic_noclick.VisibleEnd IfTransSide pos_sideEnd IfEnd IfEnd SubPrivate Sub c_cmdReset_Click()Load f_Gnetf_Gnet.Show vbModal, mainTransState FF_US_INITALLIf bIsNet = True ThenTransState FF_US_INITNETElseTransState FF_US_INITLOCALEnd IfEnd SubPrivate Sub c_MunExit_Click()Unload MeEnd SubPrivate Sub c_MunLoad_Click()On Error GoTo calcelhandlec_cdgFile.DialogTitle = "Load"c_cdgFile.ShowOpenDim i, x_off, y_off, temp As IntegerDim message As Stringmessage = "Load "Open c_cdgFile.FileName For Input As #2Input #2, local_side, pos_sidemessage = message + Chr(local_side + 65)message = message + Chr(pos_side + 65)If local_side = FF_SIDE1 Thenc_sColor.FillColor = vbRedElsec_sColor.FillColor = vbBlueEnd IfIf local_side = pos_side Thenpic_noclick.Visible = Falsepic_click.Visible = TrueElsepic_click.Visible = Falsepic_noclick.Visible = TrueEnd IfFor i = 0 To 31Input #2, temp, y_off, x_offmessage = message + Chr(temp + 65) + Chr(x_off + 48) + Chr(y_off + 48) c_chess(i).Left = x_off * 600 + 195c_chess(i).Top = y_off * 600If temp = 0 Thenc_chess(i).V isible = FalseElsec_chess(i).V isible = TrueEnd IfNext iClose #2c_MunLoad.Enabled = Falsemessage = message + " Eold"If bIsNet = True Thenc_sUse.SendData messageEnd Ifm_State = FF_UA_USEExit Subcalcelhandle:Close #2End SubPrivate Sub c_MunNew_Click()If b_isCon = False Or b_Server = False Then Exit SubMsgBox "请选单双让对方猜先", vbOKOnly, App.LegalTrademarks Load f_Gfstf_Gfst.Show vbModal, mainc_sUse.SendData "Gues " + m_Setc_MunNew.V isible = FalseEnd SubPrivate Sub c_MunSave_Click()On Error GoTo calcelhandlec_cdgFile.DialogTitle = "Save"c_cdgFile.ShowSaveDim i As IntegerOpen c_cdgFile.FileName For Output As #1Print #1, local_side, pos_sideFor i = 0 To 31If c_chess(i).V isible = True ThenPrint #1, 1, (c_chess(i).Top / 600), ((c_chess(i).Left - 195) / 600) ElsePrint #1, 0, (c_chess(i).Top / 600), ((c_chess(i).Left - 195) / 600) End IfNext iExit Subcalcelhandle:Close #1End SubPrivate Sub c_MunShow_Click()c_MunShow.Checked = Not c_MunShow.Checkedfrm_net.V isible = c_MunShow.CheckedIf frm_net.V isible = True Thenmain.Width = 8835Elsemain.Width = 5880End IfEnd SubPrivate Sub c_pboard_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If (bIsNet = True) And (Not m_State = FF_UA_USE) Then Exit SubIf Not pos_side = local_side Then Exit SubIf Chess_On = FF_EMP Then Exit SubIf X < 195 Or Y < 0 Then Exit SubIf X > 9 * 600 + 195 Or Y > 10 * 600 Then Exit SubDim x_off, y_off As Integerx_off = Int((X - 195) / 600)y_off = Int(Y / 600)If X - (x_off * 600 + 195) > 475 Or Y - y_off * 600 > 475 Then Exit SubIf GoChess(Chess_On, x_off, y_off) = False Then Exit SubIf bIsNet = True And m_State = FF_UA_USE Then c_sUse.SendData _"Post " + Chr(Chess_On + 65) + Chr(x_off + 48) + Chr(y_off + 48)Chess_On = FF_EMPc_spChessOn.V isible = FalseEnd SubPrivate Sub Form_Load()On Error GoTo errhandleTransState FF_US_INITALLIf bIsNet = True ThenTransState FF_US_INITNETc_sListen.ListenElseTransState FF_US_INITLOCALEnd IfExit Suberrhandle:MsgBox "System Wrong", vbOKOnly, App.LegalTrademarksEndEnd SubPrivate Sub c_CmdCon_Click()On Error GoTo errhandlec_sUse.LocalPort = 0c_sUse.RemotePort = 6112c_sUse.RemoteHost = c_eAddr.Textc_sUse.Connectc_CmdCon.Enabled = FalseExit Suberrhandle:MsgBox "Net wrong, Click <Connect> for a while", vbOKOnly, App.LegalTrademarksEnd SubPrivate Sub c_sListen_ConnectionRequest(ByV al requestID As Long)If b_isCon = True Or (Not c_sUse.State = 0) Then Exit Subc_sUse.LocalPort = 0c_sUse.Accept requestIDTransState FF_US_NET_CONb_Server = TrueEnd SubPrivate Sub c_sListen_Error(ByV al Number As Integer, Description As String, ByV al Scode As Long, ByV al Source As String, ByV al HelpFile As String, ByV al HelpContext As Long, CancelDisplay As Boolean)MsgBox Description, vbOKOnly, App.LegalTrademarksEndEnd SubPrivate Sub c_sUse_Close()MsgBox "连接已经关闭!!", vbOKOnly, App.LegalTrademarksTransState FF_US_INITALLTransState FF_US_INITNETc_eAddr.Text = c_sUse.RemoteHostIPEnd SubPrivate Sub c_sUse_Connect()c_sUse.SendData "Init"b_Server = FalseTransState FF_US_NET_CONm_State = FF_UA_INITEnd SubPrivate Sub c_sUse_DataArrival(ByV al bytesTotal As Long)If bIsNet = False Then Exit SubDim message As StringDim x_off, y_off, i, temp As Integerc_sUse.GetData message, vbString, bytesTotalSelect Case Left(message, 4)Case "Msag"c_eMsg.Text = Right(message, Len(message) - 5)Case "Init"If (Not m_State = FF_UA_INV ALID) Or (b_Server = False) Then _ GoTo Errorhandlec_eState.Text = c_sUse.RemoteHost + "@" + c_sUse.RemoteHostIP + "来了"m_State = FF_UA_INITc_MunNew.V isible = TrueCase "Gues"If (Not m_State = FF_UA_INIT) Or (b_Server = True) Then _GoTo Errorhandlem_BeSet = Mid(message, 6, 1)MsgBox "猜先", vbOKOnly, App.LegalTrademarksLoad f_Gfstf_Gfst.Show vbModal, mainIf Not m_Set = m_BeSet Thenc_sUse.SendData "Y our"local_side = FF_SIDE2pic_click.Visible = Falsepic_noclick.Visible = Truec_sColor.FillColor = vbBlueTransBoardElsec_sUse.SendData "Mfst"local_side = FF_SIDE1pic_noclick.Visible = Falsepic_click.Visible = Truec_sColor.FillColor = vbRedEnd IfTransState FF_US_USE_CONCase "Y our"If (Not m_State = FF_UA_INIT) Or (b_Server = False) Then _GoTo ErrorhandleTransState FF_US_USE_CONlocal_side = FF_SIDE1pic_noclick.Visible = Falsepic_click.Visible = Truec_sColor.FillColor = vbRedCase "Mfst"If (Not m_State = FF_UA_INIT) Or (b_Server = False) Then _GoTo ErrorhandleTransState FF_US_USE_CONlocal_side = FF_SIDE2pic_click.Visible = Falsepic_noclick.Visible = Truec_sColor.FillColor = vbBlueTransBoardCase "Load"If (Not m_State = FF_UA_INIT) Or (b_Server = True) Then _ GoTo Errorhandlelocal_side = Asc(Mid(message, 6, 1)) - 65TransSide local_sidepos_side = Asc(Mid(message, 7, 1)) - 65If local_side = FF_SIDE1 Thenc_sColor.FillColor = vbRedElsec_sColor.FillColor = vbBlueEnd IfIf pos_side = local_side Thenpic_noclick.Visible = Falsepic_click.Visible = TrueElsepic_click.Visible = Falsepic_noclick.Visible = TrueEnd IfDim j As Integerj = 0For i = 8 To bytesTotal - 5 Step 3temp = Asc(Mid(message, i, 1)) - 65x_off = Asc(Mid(message, i + 1, 1)) - 48y_off = Asc(Mid(message, i + 2, 1)) - 48If x_off < 0 Or x_off > 8 Or y_off < 0 Or y_off > 9 Then Exit Sub c_chess(j).Top = y_off * 600c_chess(j).Left = x_off * 600 + 195If temp = 0 Thenc_chess(j).V isible = FalseElsec_chess(j).V isible = TrueEnd Ifj = j + 1Next iTransBoardm_State = FF_UA_USECase "Post"Dim chess, chess_die, x_begin, y_begin, count As IntegerIf Not m_State = FF_UA_USE Then GoTo ErrorhandleIf pos_side = local_side Then GoTo Errorhandlechess = Asc(Mid(message, 6, 1)) - 65x_off = Asc(Mid(message, 7, 1)) - 48y_off = Asc(Mid(message, 8, 1)) - 48y_off = 9 - y_offx_off = 8 - x_offchess_die = FindChessInPos(x_off, y_off)If GoChess(chess, x_off, y_off) = False ThenIf chess = 9 Or chess = 10 Or chess = 25 Or chess = 25 Or chess = 26 ThenIf chess_die = -1 Then GoTo Errorhandlex_begin = (c_chess(chess).Left - 195) / 600y_begin = (c_chess(chess).Top) / 600count = 0If (Not x_begin = x_off) And (Not y_begin = y_off) Then GoTo ErrorhandleIf x_begin = x_off ThenFor i = y_begin + Sgn(y_off - y_begin) To y_off - Sgn(y_off - y_begin) Step Sgn(y_off - y_begin)If Not FindChessInPos(x_off, i) = -1 Then count = count + 1Next iEnd IfIf y_begin = y_off ThenFor i = x_begin + Sgn(x_off - x_begin) To x_off - Sgn(x_off - x_begin) Step Sgn(x_off - x_begin)If Not FindChessInPos(i, y_off) = -1 Then count = count + 1Next iEnd IfElseGoTo ErrorhandleEnd IfIf count = 1 Thenc_chess(chess).Top = c_chess(chess_die).Topc_chess(chess).Left = c_chess(chess_die).Leftc_chess(chess_die).V isible = FalseIf chess_die = 0 Or chess_die = 16 ThenDie chess_dieExit SubEnd IfTransSide pos_sidepic_click.Visible = Not pic_click.Visiblepic_noclick.Visible = Not pic_noclick.VisibleEnd IfElseIf chess_die = -1 Then Exit Subc_chess(chess_die).V isible = FalseIf chess_die = 0 Or chess_die = 16 ThenDie chess_dieExit SubEnd IfEnd IfCase ElseGoTo ErrorhandleEnd SelectExit SubErrorhandle:If Not message = "Invalid Command" Thenc_sUse.SendData "Invalid Command"Elsec_eState.Text = "错误的命令或操作"End IfEnd SubPrivate Sub c_sUse_Error(ByV al Number As Integer, Description As String, ByV al Scode As Long, ByV al Source As String, ByV al HelpFile As String, ByV al HelpContext As Long, CancelDisplay As Boolean)MsgBox Description, vbOKOnly, App.LegalTrademarksTransState FF_US_INITALLTransState FF_US_INITNETEnd Sub'中国象棋Option ExplicitPrivate Sub Form_Load()opt_Net.V alue = Falseopt_Local.V alue = TrueEnd SubPrivate Sub m_CmdNetOk_Click() main.bIsNet = opt_Net.V alue Unload f_GnetLoad mainmain.ShowEnd Sub'中国象棋-VB开发Option ExplicitPrivate Sub Form_Load()opt_d.V alue = TrueEnd SubPrivate Sub m_cmdGfstOk_Click() If opt_d.V alue = True Then main.m_Set = "D"Elsemain.m_Set = "S"End IfUnload f_GfstEnd Sub。
商品归类代码说明第九十五章

商品归类代码说明第九十五章商品归类代码说明(第九十五章)商品名称编码附加编码附加序号说明儿童三轮车 95010000 - 001 -儿童踏板车 95010000 - 002 -儿童踏板汽车 95010000 - 003 -玩偶车 95010000 - 004 -游戏用赛车 95010000 - 005 -布公仔 95021000 - 001 指玩偶塑胶公仔 95021000 - 002 指玩偶玩偶 95021000 - 003 -公仔棉衫裤 95029100 - 001 指玩偶用公仔衫 95029100 - 002 指玩偶公仔衫裁片 95029100 - 003 -毛冷公仔衫 95029100 - 004 -毛冷公仔衫 95029100 - 005 指玩偶娃娃衣服裁片 95029100 - 006 -玩偶服装 95029100 - 007 -玩偶帽 95029100 - 008 -玩偶衫裁片 95029100 - 009 -玩偶鞋 95029100 - 010 -玩偶鞋仔 95029100 - 011 -玩偶靴 95029100 - 012 -鼻子 95029900 - 001 指玩偶瓷器脚 95029900 - 002 指玩偶瓷器手 95029900 - 003 指玩偶瓷器头 95029900 - 004 指玩偶各式头发 95029900 - 005 指玩偶公仔发线 95029900 - 006 指玩偶公仔活动眼 95029900 - 007 指玩偶公仔脚 95029900 - 008 指玩偶公仔手 95029900 - 009 指玩偶公仔塑胶鼻 95029900 - 010 指玩偶公仔塑胶眼 95029900 - 011 指玩偶公仔头 95029900 - 012 指玩偶公仔头发 95029900 - 013 指玩偶公仔眼 95029900 - 014 指玩偶公仔眼片 95029900 - 015 指玩偶公仔眼珠 95029900 - 016 指玩偶关节 95029900 - 017 指玩偶假发 95029900 - 018 指玩偶假发丝 95029900 - 019 指玩偶胶鼻子 95029900 - 020 指玩偶胶眼睛 95029900 - 021 指玩偶胶眼珠 95029900 - 022 指玩偶开关制 95029900 - 023 玩偶开关制尼龙发丝 95029900 - 024 指玩偶尼龙发线 95029900 - 025 指玩偶尼龙假发 95029900 - 026 指玩偶尼龙头发 95029900 - 027 指玩偶饰物 95029900 - 028 指玩偶娃娃架 95029900 - 029 -娃娃站台 95029900 - 030 -玩偶发音装置 95029900 - 031 玩偶零件线路板 95029900 - 032 玩偶零件鞋仔 95029900 - 033 玩偶鞋眼睛活动装置 95029900 - 034 指玩偶宝马模型 95032000 - 001 -飞机模型 95032000 - 002 -汽车模型 95032000 - 003 -建筑玩具 95033000 - 001 -毛绒动物玩具 95034100 - 001 -毛绒玩具 95034100 - 002 指玩具动物兔毛老鼠玩具 95034100 - 003 填充玩具塑胶动物玩具 95034900 - 001 -塑胶玩具 95034900 - 002 指玩具动物玩具钢琴 95035000 - 001 -玩具鼓 95035000 - 002 -玩具口琴 95035000 - 003 -玩具喇叭 95035000 - 004 -玩具木琴 95035000 - 005 -玩具手风琴 95035000 - 006 -玩具音乐盒 95035000 - 007 -智力玩具 95036000 - 001 -玩具电动波子机 95037000 - 001 -玩具电动车 95038000 - 001 -玩具缝纫机 95038000 - 002 -玩具遥控车 95038000 - 003 -电子鞭炮 95039000 - 001 -风筝 95039000 - 002 -跳绳 95039000 - 003 -铁球 95039000 - 004 -玩具弹子 95039000 - 005 -玩具计算器 95039000 - 006 -玩具教具 95039000 - 007 -玩具气球 95039000 - 008 -玩具钱箱 95039000 - 009 -玩具手枪 95039000 - 010 -玩具武器 95039000 - 011 -玩具戏院 95039000 - 012 -玩具蒸汽机 95039000 - 013 -玩具钟表 95039000 - 014 -玩偶盒 95039000 - 015 -婴儿摇鼓 95039000 - 016 -电子游戏机 95041000 - 001 与电视机配套使用游戏机 95041000 - 002 与电视机配套使用击球杆 95042000 - 001 -击球架 95042000 - 002 -记分牌 95042000 - 003 -球 95042000 - 004 -台球粉 95042000 - 005 -台球桌 95042000 - 006 -桌球 95042000 - 007 -电子游戏机 95043010 - 001 投币式游戏机投币式电子游戏机 95043010 - 002 -游戏机 95043010 - 003 投币式电子游戏机游戏机底盖 95043010 - 004 投币式电子游戏机零件游戏机后盖 95043010 - 005 投币式电子游戏机零件游戏机前盖 95043010 - 006 投币式电子游戏机零件主机解读器 95043010 - 007 投币式电子游戏机零件主印制板 95043010 - 008 投币式电子游戏机零件扑克 95044000 - 001 -扑克牌 95044000 - 002 -桥牌 95044000 - 003 -小型便携式游戏机 95049010 - 001 -保龄球自动分瓶机 95049021 - 001 -保龄球自动分瓶系统 95049021 - 002 -保龄球 95049022 - 001 -保龄球瓶 95049023 - 001 -保龄球道 95049029 - 001 -保龄球自动计分台 95049029 - 002 - 保龄球自动球道设备 95049029 - 003 - 国际象棋 95049030 - 001 -棋盘 95049030 - 002 -棋子 95049030 - 003 -跳棋 95049030 - 004 -象棋 95049030 - 005 -中国象棋 95049030 - 006 -麻将 95049040 - 001 -骰子 95049040 - 002 麻将用弹球机 95049090 - 001 -投镖 95049090 - 002 -投镖板 95049090 - 003 -游戏用计数器 95049090 - 004 -纸牌花色显示器 95049090 - 005 -。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
中国象棋(web版源代码)程序:using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1{public partial class WebForm1 : System.Web.UI.Page{int tru = 20;int fals = 40;public ImageButton[,] _Image=new ImageButton[11,10];//将上一次点击点的坐标保存到数据库中的lastx和lastypublic void SaveToLast(){if (Session["user"].ToString() == "red" &&_GetUserState(Session["user"].ToString()) == 20){int x, y, lastx, lasty;x = Getpointx();y = Getpointy();lastx = x;lasty = y;Updatalastx(lastx);Updatalasty(lasty);}if (Session["user"].ToString() == "black" &&_GetUserState(Session["user"].ToString()) == 20){int x, y, lastx, lasty;x = Getpointx();y = Getpointy();lastx = x;lasty = y;Updatalastx(lastx);Updatalasty(lasty);}}//将棋盘上所有棋子图片显示到棋盘上private void _Drawqizi(){//_Init();int i,j,k;if (_GetUserState("red") != 0 && _GetUserState("black") != 0){if (Session["user"].ToString() == "red"){for (i = 1; i <= 10; i++)for (j = 1; j <= 9; j++){k = _GetDataQipan(i, j);_Image[i, j].ImageUrl = _GetImageAdd(k);}}if (Session["user"].ToString() == "black"){for (i = 1; i <= 10; i++)for (j = 1; j <= 9; j++){k = _GetDataQipan(i, j);_Image[11 - i, 10 - j].ImageUrl =_GetImageAdd(k);}}}//初始化:对_Image[,]赋值,对ImageButton进行编号private void _Init(){_Image[1, 1] = ImageButton1; _Image[1, 2] = ImageButton2; _Image[1, 3] = ImageButton3; _Image[1, 4] = ImageButton4; _Image[1, 5] = ImageButton5; _Image[1, 6] = ImageButton6; _Image[1, 7] = ImageButton7; _Image[1, 8] = ImageButton8; _Image[1, 9] = ImageButton9;_Image[2, 1] = ImageButton11; _Image[2, 2] = ImageButton12; _Image[2, 3] = ImageButton13; _Image[2, 4] = ImageButton14; _Image[2, 5] = ImageButton15; _Image[2, 6] = ImageButton16; _Image[2, 7] = ImageButton17; _Image[2, 8] = ImageButton18; _Image[2, 9] = ImageButton19;_Image[3, 1] = ImageButton21; _Image[3, 2] = ImageButton22; _Image[3, 3] = ImageButton23; _Image[3, 4] = ImageButton24; _Image[3, 5] = ImageButton25; _Image[3, 6] = ImageButton26; _Image[3, 7] = ImageButton27; _Image[3, 8] = ImageButton28; _Image[3, 9] = ImageButton29;_Image[4, 1] = ImageButton31; _Image[4, 2] = ImageButton32; _Image[4, 3] = ImageButton33; _Image[4, 4] = ImageButton34; _Image[4, 5] = ImageButton35; _Image[4, 6] = ImageButton36; _Image[4, 7] = ImageButton37; _Image[4, 8] = ImageButton38; _Image[4, 9] = ImageButton39;_Image[5, 1] = ImageButton41; _Image[5, 2] = ImageButton42; _Image[5, 3] = ImageButton43; _Image[5, 4] = ImageButton44; _Image[5, 5] = ImageButton45; _Image[5, 6] = ImageButton46; _Image[5, 7] = ImageButton47; _Image[5, 8] = ImageButton48; _Image[5, 9] = ImageButton49;_Image[6, 1] = ImageButton51; _Image[6, 2] = ImageButton52; _Image[6, 3] = ImageButton53; _Image[6, 4] = ImageButton54; _Image[6, 5] = ImageButton55; _Image[6, 6] = ImageButton56; _Image[6, 7] = ImageButton57; _Image[6, 8] = ImageButton58; _Image[6, 9] = ImageButton59;_Image[7, 1] = ImageButton61; _Image[7, 2] = ImageButton62; _Image[7, 3] = ImageButton63; _Image[7, 4] = ImageButton64; _Image[7, 5] = ImageButton65; _Image[7, 6] = ImageButton66; _Image[7, 7] = ImageButton67; _Image[7, 8] = ImageButton68; _Image[7, 9] = ImageButton69;_Image[8, 1] = ImageButton71; _Image[8, 2] = ImageButton72; _Image[8, 3] = ImageButton73; _Image[8, 4] = ImageButton74; _Image[8, 5] = ImageButton75; _Image[8, 6] = ImageButton76; _Image[8, 7] = ImageButton77; _Image[8, 8] = ImageButton78; _Image[8, 9] = ImageButton79;_Image[9, 1] = ImageButton81; _Image[9, 2] = ImageButton82; _Image[9, 3] = ImageButton83; _Image[9, 4] = ImageButton84; _Image[9, 5] = ImageButton85; _Image[9, 6] = ImageButton86; _Image[9, 7] = ImageButton87; _Image[9, 8] = ImageButton88; _Image[9, 9] = ImageButton89;_Image[10, 1] = ImageButton91; _Image[10, 2] = ImageButton92; _Image[10, 3] = ImageButton93; _Image[10, 4] = ImageButton94; _Image[10, 5] = ImageButton95; _Image[10, 6] = ImageButton96; _Image[10, 7] = ImageButton97; _Image[10, 8] = ImageButton98; _Image[10, 9] = ImageButton99;int i, j;for (i = 1; i <= 10; i++)for (j = 1; j <= 9; j++){_Image[i, j].ImageUrl = "~/image/back.gif";}}//初始化棋盘,将两方棋子放好位private void _InitQizi(){int i = 0, j = 0, k = 0;int[] initqipandata = new int[37];for (i = 1; i <= 10; i++)for (j = 1; j <= 9; j++){_UpdataQipan(i, j, k);}for (i = 0; i <= 36; i++)initqipandata[i] = i;_UpdataQipan(1, 1, initqipandata[8]); _UpdataQipan(1, 2, initqipandata[6]); _UpdataQipan(1, 3, initqipandata[4]); _UpdataQipan(1, 4, initqipandata[2]); _UpdataQipan(1, 5, initqipandata[1]); _UpdataQipan(1,6, initqipandata[3]); _UpdataQipan(1, 7, initqipandata[5]); _UpdataQipan(1, 8, initqipandata[7]); _UpdataQipan(1, 9, initqipandata[9]); _UpdataQipan(3, 2, initqipandata[10]); _UpdataQipan(3, 8, initqipandata[11]); _UpdataQipan(4, 1, initqipandata[12]); _UpdataQipan(4, 3, initqipandata[13]);_UpdataQipan(4, 5, initqipandata[14]); _UpdataQipan(4, 7,initqipandata[15]); _UpdataQipan(4, 9, initqipandata[16]);_UpdataQipan(10, 1, initqipandata[28]); _UpdataQipan(10, 2, initqipandata[26]); _UpdataQipan(10, 3, initqipandata[24]);_UpdataQipan(10, 4, initqipandata[22]); _UpdataQipan(10, 5,initqipandata[21]); _UpdataQipan(10, 6, initqipandata[23]);_UpdataQipan(10, 7, initqipandata[25]); _UpdataQipan(10, 8,initqipandata[27]); _UpdataQipan(10, 9, initqipandata[29]); _UpdataQipan(8, 2, initqipandata[30]); _UpdataQipan(8, 8, initqipandata[31]);_UpdataQipan(7, 1, initqipandata[32]); _UpdataQipan(7, 3,initqipandata[33]); _UpdataQipan(7, 5, initqipandata[34]); _UpdataQipan(7, 7, initqipandata[35]); _UpdataQipan(7, 9, initqipandata[36]);}//获取棋子图片地址private string _GetImageAdd(int xxx){string x="" ;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select add_image from qizi where(no_qizi='"+xxx+"');", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read())x = sr["add_image"].ToString();//Session["add_image"] = x;myconn.Close();return x;}//获取点击后的图片地址private string _GetImageDownAdd(int xxx){string x ="";SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select add_image_down from qizi where(no_qizi='" + xxx + "')", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read())x = sr["add_image_down"].ToString();myconn.Close();return x;}//读取鼠标点击点的坐标private int Getpointx(){int x = 0;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select x from zuobiao", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read()){x = int.Parse(sr["x"].ToString());}myconn.Close();return x;}private int Getpointy( ){int x = 0;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select y from zuobiao", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read()){x = int.Parse(sr["y"].ToString());}myconn.Close();return x;}private int Getpointlastx( ){int x = 0;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select lastx from zuobiao", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read()){x = int.Parse(sr["lastx"].ToString());}myconn.Close();return x;}private int Getpointlasty( ){int x = 0;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select lasty from zuobiao", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read()){x = int.Parse(sr["lasty"].ToString());}myconn.Close();return x;}//写入鼠标点击点的坐标private void Updatax(int xxx){SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update zuobiao set x='" + xxx + "'", myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}private void Updatay(int yyy){SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update zuobiao set y='" + yyy + "'", myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}private void Updatalastx(int lastxxx){SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update zuobiao set lastx='"+lastxxx +"'" , myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}private void Updatalasty(int lastyyy){SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update zuobiao set lasty='"+ lastyyy +"'", myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}//以上四个函数的集合,达到一次写入四个坐标值的目的private void _UpdataaZuobiao(int xxx, int yyy, int lastxxx, int lastyyy){Updatax(xxx);Updatay(yyy);Updatalastx(lastxxx);Updatalasty(lastyyy);}//保存当前坐标值到x和yprivate void _UpdatZuobiaoXY(int xxx, int yyy){if (Session["user"].ToString() == "red" &&_GetUserState(Session["user"].ToString()) == 20){Updatax(xxx);Updatay(yyy);}if (Session["user"].ToString() == "black" &&_GetUserState(Session["user"].ToString()) == 20){Updatax(xxx);Updatay(yyy);}}//读取棋盘上的棋子信息private int _GetDataQipan(int xxx, int yyy){int i,data=0;i = (xxx - 1) * 9 + yyy;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select data_qipan from qipan where(position='"+i+"')", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read())data = int.Parse(sr["data_qipan"].ToString());myconn.Close();return data;}//将棋子信息写入棋盘private void _UpdataQipan(int xxx, int yyy,int data){int i;i = (xxx - 1) * 9 + yyy;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update qipan set data_qipan=" + data + "where (position='"+i+"')", myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}//读出用户此时状态private int _GetUserState(string id){int data = 0;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select state from yonghu where(id='" + id + "')", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read())data = int.Parse(sr["state"].ToString());myconn.Close();return data;}//读出用户输赢状态 0表示在进行游戏 20表示赢 40表示输private int _GetUserWin(string id){int data = 0;SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("select winner from yonghu where(id='" + id + "')", myconn);myconn.Open();SqlDataReader sr = cmd.ExecuteReader();if (sr.Read())data = int.Parse(sr["winner"].ToString());myconn.Close();return data;}//写入用户状态private void _UpdataUserState(string id,int sta){SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update yonghu set state="+ sta + "where (id='" + id + "')", myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}//写入用户输赢状态 0表示在进行游戏 20表示赢 40表示输private void _UpdataUserWin(string id, int sta){SqlConnection myconn = newSqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRIN G"].ConnectionString);SqlCommand cmd = new SqlCommand("update yonghu set winner=" + sta + "where (id='" + id + "')", myconn);myconn.Open();int aa = cmd.ExecuteNonQuery();myconn.Close();}protected void Page_Load(object sender, EventArgs e){_Init();// _Test();}//测试程序函数private void _Test(){_UpdataUserState("red",tru);_UpdataUserState("black", tru);}private bool_IsAbleToPut()//********************************************************需要传递x,y,laastx,lasty{if (Session["user"].ToString() == "red" &&_GetUserState(Session["user"].ToString()) == 40)return false;if (Session["user"].ToString() == "black" &&_GetUserState(Session["user"].ToString()) == 40)return false;int x, y, lastx, lasty;int qipandata,lastqipandata;x = Getpointx();y = Getpointy();lastx = Getpointlastx();lasty = Getpointlasty();if (Session["user"].ToString() == "black"){x = 11 - x;y = 10 - y;lastx = 11 - lastx;lasty = 10 - lasty;}qipandata = _GetDataQipan(x, y);lastqipandata = _GetDataQipan(lastx, lasty);// if (lastqipandata==0)// return false;if(Session["user"].ToString() == "red"&&(lastqipandata <= 20 || qipandata >=20))//****************************************************************现以红方为对象return false;if (Session["user"].ToString() == "black" && ((lastqipandata == 0 || lastqipandata >= 20) || (qipandata > 0 && qipandata <= 20)))return false;int i, j, c;//将|帅if (lastqipandata == 1 || lastqipandata == 21){if ((x - lastx) * (y - lasty) != 0) return false;if(Math.Abs(x - lastx) > 1 || Math.Abs(y - lasty) > 1) return false;if (y < 4 || y > 6 || (x > 3 && x < 8)) return false;return true;}//士|仕if (lastqipandata == 2 || lastqipandata == 3 || lastqipandata == 22 || lastqipandata == 23){if ((x - lastx) * (y - lasty) == 0) return false;if(Math.Abs(x - lastx) > 1 || Math.Abs(y - lasty) > 1) return false;if (y < 4 || y > 6 || (x > 3 && x < 8)) return false;return true;}//象|相if (lastqipandata == 4 || lastqipandata == 5 || lastqipandata == 24 || lastqipandata == 25){if ((x - lastx) * (y - lasty) == 0) return false;if (Math.Abs(x - lastx) != 2 || Math.Abs(y - lasty) != 2) return false;if(Session["user"].ToString() == "red"&& x < 6) return false;if (Session["user"].ToString() == "black" && x > 5) return false;i = 0; j = 0;//i,j必须有初始值if (x - lastx == 2){i = x - 1;}if (x - lastx == -2){i = x + 1;}if (y - lasty == 2){j = y - 1;}if (y - lasty == -2){j = y + 1;}if (_GetDataQipan(i, j) != 0) return false;return true;}//马if (lastqipandata == 6 || lastqipandata == 7 || lastqipandata == 26 || lastqipandata == 27){if (Math.Abs(x - lastx) * Math.Abs(y - lasty) != 2)return false;if (x - lastx == 2){if (_GetDataQipan(x - 1, lasty) != 0)return false;}if (x - lastx == -2){if (_GetDataQipan(x + 1, lasty) != 0)return false;}if (y - lasty == 2){if (_GetDataQipan(lastx, y - 1) != 0)return false;}if (y - lasty == -2){if (_GetDataQipan(lastx, y + 1) != 0)return false;}return true;}//车if (lastqipandata == 8 || lastqipandata == 9 || lastqipandata == 28 || lastqipandata == 29){//判断是否直线if ((x - lastx) * (y - lasty) != 0) return false;//判断是否隔有棋子if (x != lastx){if (lastx > x) { int t = x; x = lastx; lastx = t; }for (i = lastx; i <= x; i += 1){if (i != x && i != lastx){if (_GetDataQipan(i, y) != 0)return false;}}}if (y != lasty){if (lasty > y) { int t = y; y = lasty; lasty = t; }for (j = lasty; j <= y; j += 1){if (j != y && j != lasty){if (_GetDataQipan(x, j) != 0)return false;}}}return true;}//炮if (lastqipandata == 10 || lastqipandata == 11 || lastqipandata == 30 || lastqipandata == 31){bool swapflagx = false;bool swapflagy = false;if ((x - lastx) * (y - lasty) != 0) return false;c = 0;if (x != lastx){if (lastx > x) { int t = x; x = lastx; lastx = t; swapflagx = true; }for (i = lastx; i <= x; i += 1){if (i != x && i != lastx){if (_GetDataQipan(i, y) != 0)c = c + 1;//IsAbleToPut = False: Exit Function}}}if (y != lasty){if (lasty > y) { int t = y; y = lasty; lasty = t; swapflagy = true; }for (j = lasty; j <= y; j += 1){if (j != y && j != lasty){if (_GetDataQipan(x, j) != 0)c = c + 1;//IsAbleToPut = False: Exit Function}}}if (c > 1) return false; //与目标处间隔1个以上棋子if (c == 0) //与目标处无间隔棋子{if(swapflagx == true) { int t = x; x = lastx; lastx = t; }if(swapflagy == true) { int t = y; y = lasty; lasty = t; }if (_GetDataQipan(x, y) != 0) return false;}if (c == 1)//与目标处间隔1个棋子{if(swapflagx == true) { int t = x; x = lastx; lastx = t; }if(swapflagy == true) { int t = y; y = lasty; lasty = t; }// if ((IsMyChess(qipan[x, y]) || qipan[x, y] == 0))//return false;//***********ismychess************************************************** ***************************if (qipandata == 0)return false;}return true;}//卒|兵if (lastqipandata == 12 || lastqipandata == 13 || lastqipandata == 14 || lastqipandata == 15 || lastqipandata == 16 || lastqipandata == 32 || lastqipandata == 33 || lastqipandata == 34 || lastqipandata == 35 || lastqipandata == 36){if ((x - lastx) * (y - lasty) != 0)return false;if(Math.Abs(x - lastx) > 1 || Math.Abs(y - lasty) > 1)return false;if (Session["user"].ToString() == "red" && (x >= 6 && (y - lasty) != 0)) return false;if(Session["user"].ToString() == "black"&& (x <= 5 && (y - lasty) != 0)) return false;if(Session["user"].ToString() == "red"&& (x - lastx > 0)) return false;if(Session["user"].ToString() == "black"&& (x - lastx < 0)) return false;return true;}return false;}//移动棋子private void _MoveChess()//********************************************************需要传递x,y,laastx,lasty{//如果能移动则移动棋子if (_IsAbleToPut()){int x, y, lastx, lasty,qipandata, lastqipandata, tr;tr = 0;x = Getpointx();y = Getpointy();lastx = Getpointlastx();lasty = Getpointlasty();if (Session["user"].ToString() == "black"){x = 11 - x;y = 10 - y;lastx = 11 - lastx;lasty = 10 - lasty;}qipandata = _GetDataQipan(x, y);lastqipandata = _GetDataQipan(lastx, lasty);_UpdataQipan(x, y, lastqipandata);_UpdataQipan(lastx, lasty, tr);if (Session["user"].ToString() == "red"){_UpdataUserState("red", fals);_UpdataUserState("black", tru);}if (Session["user"].ToString() == "black"){_UpdataUserState("red", tru);_UpdataUserState("black", fals);}if (qipandata == 1){Response.Write("<script language=javascript>alert('恭喜您,您赢啦');</script>");_UpdataUserState("red", fals);_UpdataUserState("black", fals);Button6.Enabled = true;_UpdataUserWin("red",20);_UpdataUserWin("black", 40);}if (qipandata == 21){Response.Write("<script language=javascript>alert('恭喜您,您赢啦');</script>");_UpdataUserState("red", fals);_UpdataUserState("black", fals);Button6.Enabled = true;_UpdataUserWin("red", 40);_UpdataUserWin("black", 20);}_UpdataaZuobiao(0, 0, 0, 0);}//如果不能移动则更换已方被点击棋子的背景图片}protected void ImageButton1_Click1(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 1; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton2_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 2; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton3_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 3; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton4_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 4; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton5_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 5; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton6_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 6; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton7_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 7; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton8_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 8; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton9_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 1; y = 9; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton11_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 1; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton12_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 2; _UpdatZuobiaoXY(x, y);_MoveChess(); _Drawqizi();}protected void ImageButton13_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 3; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton14_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 4; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton15_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 5; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton16_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 6; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton17_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 7; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton18_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 8; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton19_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 2; y = 9; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton21_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 1; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton22_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 2; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton23_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 3; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton24_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 4; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton25_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 5; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton26_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 6; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton27_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 7; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton28_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 8; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton29_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 3; y = 9; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton31_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 1; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton32_Click(object sender,ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 2; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton33_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 3; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton34_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 4; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton35_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 5; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton36_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 6; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}protected void ImageButton37_Click(object sender, ImageClickEventArgs e){int x, y; SaveToLast(); x = 4; y = 7; _UpdatZuobiaoXY(x, y); _MoveChess(); _Drawqizi();}。