1.我想要一个用vb编的象棋五子棋的源码(不要超连接的)
2.手把手超详细!教你用turtle画一个象棋棋盘附源码
3.出色的棋源棋棋开源中国象棋棋谱APP-Chess
4.VB中国象棋源代码
我想要一个用vb编的五子棋的源码(不要超连接的)
'在窗体上加入以下控件
'image1(0),image1(0) - 黑白棋
'image2,image3(0)
'form中的picture为棋盘。因无法上传,码象请自行领会。源码
Option Explicit
Dim I,象棋 J, K, Counter, Firstmoved, Rt, Gen, r, flag As Integer
Dim Grid(), H(), V(), RL(), LR(), Tb(2), Order() As Integer
Private Sub Form_Initialize()
lblHelp.Top = 0
lblHelp.Left = 0
Image1(0).Top = -
Image1(1).Top = -
lblHelp.Left = -lblHelp.Width
lblHelp = vbCrLf + vbCrLf + " 游戏帮助" + vbCrLf _
+ vbCrLf + vbCrLf + "●游戏规则:黑方先行,轮流弈子,任一方向先连成五子者胜." _
+ vbCrLf + vbCrLf + vbCrLf + "●操作提示:①可选择[先后]、[难度]和[对手]菜单设置游戏,棋源棋棋app源码生成app" _
+ vbCrLf + vbCrLf + " 只有按[游戏]->[开始]后才可在棋盘上落子." _
+ vbCrLf + vbCrLf + " ②按[游戏]->[清盘]可重玩并设置游戏." _
+ vbCrLf + vbCrLf + " ③落子后按[动作]菜单下的选择可任意悔棋和恢复." _
+ vbCrLf + vbCrLf + " ④各功能菜单都提供了快捷键(Alt+相应字母)." _
+ vbCrLf + vbCrLf + vbCrLf + "●有什么问题请与本人联系.电子邮件:xwwxyz@sina.com." _
+ vbCrLf + vbCrLf + vbCrLf + "●本页面单击后隐藏."
End Sub
Private Sub Form_Resize()
Me.Height =
Me.Width =
End Sub
Private Sub lblHelp_Click()
lblHelp.Visible = False
End Sub
Private Sub mnuAfter_Click()
Firstmoved = 0
mnuAfter.Checked = True
mnuFirst.Checked = False
End Sub
Private Sub Form_Load()
Dim I As Integer
For I = 1 To
Load Image3(I) '加载棋子控件
Image3(I).Top = (I \ ) * + 5
Image3(I).Left = (I Mod ) * + 5
Image3(I).Visible = True
Next
Ini
End Sub
'游戏初始化
Sub Ini()
For I = 0 To
Image3(I) = Image2
Image3(I).Enabled = False
Grid(I) = 0
V(I) = 0
H(I) = 0
LR(I) = 0
RL(I) = 0
Next I
mnuBack.Enabled = False
Counter = 0
Gen = 0
If mnuAfter.Checked = True Then
Firstmoved = 0
Else
Firstmoved = 1
End If
mnuStart.Enabled = True
End Sub
'一方是否可获胜
Function LineWin(Piece As Integer) As Integer
Dim mun As Integer
LineWin =
'五子一线
mun = Piece * 5
For I = 0 To
If H(I) = mun Or V(I) = mun Or RL(I) = mun Or LR(I) = mun Then
LineWin = + Piece
Exit Function
End If
Next I
'四子一线
mun = Piece * 4
For I = 0 To
If H(I) = mun Then
For K = 0 To 4
If Grid(I + K) = 0 Then LineWin = I + K: Exit Function
Next K
End If
If V(I) = mun Then
For K = 0 To 4
If Grid(I + K * ) = 0 Then LineWin = I + K * : Exit Function
Next K
End If
If RL(I) = mun Then
For K = 0 To 4
If Grid(I + K * ) = 0 Then LineWin = I + K * : Exit Function
Next K
End If
If LR(I) = mun Then
For K = 0 To 4
If Grid(I + K * ) = 0 Then LineWin = I + K * : Exit Function
Next K
End If
Next I
End Function
'计算机走棋
Sub ComputerMove()
Dim ToMove As Integer
If Counter = 0 Then
Randomize
I = Int(Rnd * 7 + 4)
J = Int(Rnd * 7 + 4)
If Grid(I * + J) = 0 Then ToMove = I * + J
Else
If mnuLower.Checked = True Then ToMove = Defend Else ToMove = Attempt
End If
Counter = Counter + 1
If Firstmoved = 0 Then Image3(ToMove) = Image1(0) Else Image3(ToMove) = Image1(1)
Grid(ToMove) = 2
Order(Counter) = ToMove
LineGen ToMove, 6
If LineWin(6) = Then
MsgBox "您输了!"
Ini
Exit Sub
End If
If Counter = Then
MsgBox "和棋"
Ini
Exit Sub
End If
End Sub
'低级模式
Function Defend() As Integer
Rt = LineWin(6)
If Rt < Then Defend = Rt: Exit Function
Rt = LineWin(1)
If Rt < Then Defend = Rt: Exit Function
'查找落子位置
Rt = FindBlank
If Rt < Then Defend = Rt: Exit Function
End Function
'悔棋
Private Sub mnuBack_Click()
mnuComeback.Enabled = True
If (Counter + Firstmoved) Mod 2 = 0 Then Rt = -1 Else Rt = -6
Grid(Order(Counter)) = 0
Image3(Order(Counter)) = Image2
LineGen Order(Counter), Rt
Counter = Counter - 1
If mnuComputer.Checked = True Then
Grid(Order(Counter)) = 0
Image3(Order(Counter)) = Image2
LineGen Order(Counter), -1
Counter = Counter - 1
Else
flag = 1 - flag
End If
r = r + 1
If Counter = 1 And Firstmoved = 0 And mnuComputer.Checked = True Then mnuBack.Enabled = False
If Counter = 0 Then mnuBack.Enabled = False
End Sub
'恢复棋子
Private Sub mnuComeback_Click()
mnuBack.Enabled = True
Counter = Counter + 1
If (Counter + Firstmoved) Mod 2 = 0 Then
Grid(Order(Counter)) = 1
Image3(Order(Counter)) = Image1(1 - Firstmoved)
LineGen Order(Counter), 1
Else
Grid(Order(Counter)) = 2
Image3(Order(Counter)) = Image1(Firstmoved)
LineGen Order(Counter), 6
End If
If mnuComputer.Checked = True Then
Counter = Counter + 1
Grid(Order(Counter)) = 2
Image3(Order(Counter)) = Image1(Firstmoved)
LineGen Order(Counter), 6
Else
flag = 1 - flag
End If
r = r - 1
If r = 0 Then mnuComeback.Enabled = False
End Sub
Private Sub mnuComputer_Click() '对手
mnuComputer.Checked = True '电脑
mnuHuman.Checked = False '棋手
End Sub
Private Sub mnuClear_Click() '清盘
Ini
mnuFirst.Enabled = True
mnuAfter.Enabled = True
mnuLower.Enabled = True
mnuHigher.Enabled = True
mnuComputer.Enabled = True
mnuHuman.Enabled = True
End Sub
Private Sub mnuHuman_Click()
mnuHuman.Checked = True
mnuComputer.Checked = False
End Sub
Private Sub mnuStart_Click() '开始
lblHelp.Visible = False
For I = 0 To
Image3(I).Enabled = True
Next I
mnuFirst.Enabled = False
mnuAfter.Enabled = False
mnuLower.Enabled = False
mnuHigher.Enabled = False
mnuComputer.Enabled = False
mnuHuman.Enabled = False
If Firstmoved = 0 And mnuComputer.Checked = True Then ComputerMove
If Firstmoved = 0 And mnuHuman.Checked = True Then flag = 1 Else flag = 0
mnuStart.Enabled = False
End Sub
'玩家走棋
Private Sub image3_Click(Index As Integer)
If Grid(Index) <> 0 Then Exit Sub
Counter = Counter + 1
If Firstmoved = 0 Then
Image3(Index) = Image1(1 - flag)
Else
Image3(Index) = Image1(flag)
End If
Grid(Index) = 1 + flag
Order(Counter) = Index
mnuBack.Enabled = True
mnuComeback.Enabled = False
r = 0
LineGen Index, (1 + flag * 5)
If LineWin(1 + flag * 5) = + flag * 5 Then
If flag = 0 Then MsgBox "您赢了!" Else MsgBox "您输了!"
Ini
Exit Sub
End If
If Counter = Then
MsgBox "和棋"
Ini
Exit Sub
End If
If mnuComputer.Checked = True Then ComputerMove Else flag = 1 - flag
End Sub
'查找可以落子的空位
Function FindBlank() As Integer
Dim wz, fs, lz, RndNum As Integer
fs = -
For wz = 0 To
If Grid(wz) = 0 Then
Grid(wz) = 2
LineGen wz, 6
Rt = Gen
If Rt > fs Then fs = Rt: lz = wz
Grid(wz) = 0
LineGen wz, -6
End If
Next wz
FindBlank = lz
End Function
'高级模式
Function Attempt() As Integer
Dim wz As Integer
Rt = LineWin(6)
If Rt < Then Attempt = Rt: Exit Function
Rt = LineWin(1)
If Rt < Then Attempt = Rt: Exit Function
'查找落子位置
Rt = linethree(6)
If Rt < Then Attempt = Rt: Exit Function
Rt = linethree(1)
If Rt < Then
Grid(Tb(0)) = 2
LineGen Tb(0), 6
Rt = Gen: wz = Tb(0)
Grid(Tb(0)) = 0
LineGen Tb(0), -6
Grid(Tb(1)) = 2
LineGen Tb(1), 6
If Rt < Gen Then Rt = Gen: wz = Tb(1)
Grid(Tb(1)) = 0
LineGen Tb(1), -6
Grid(Tb(2)) = 2
LineGen Tb(2), 6
If Rt < Gen Then Rt = Gen: wz = Tb(2)
Grid(Tb(2)) = 0
LineGen Tb(2), -6
Attempt = wz
Exit Function
End If
Rt = FindBlank
If Rt < Then Attempt = Rt: Exit Function
End Function
Private Sub mnuFirst_Click() '先后手
Firstmoved = 1
mnuAfter.Checked = False
mnuFirst.Checked = True
End Sub
Private Sub mnuHigher_Click()
mnuLower.Checked = False
mnuHigher.Checked = True
End Sub
Private Sub mnuLower_Click() '难度
mnuLower.Checked = True
mnuHigher.Checked = False
End Sub
'局势评估
Function LineGen(ij, Piece)
Dim b, e, mun As Integer
I = ij \
J = ij Mod
'横线影响
b = IIf(J - 4 > 0, J - 4, 0)
e = IIf(J > , , J)
For K = b To e
mun = H(I * + K)
If mun < 6 Then Gen = Gen + mun * 2 ^ mun
If mun > 5 And mun Mod 6 = 0 Then mun = mun \ 6 - 1: Gen = Gen - mun * 2 ^ mun
H(I * + K) = H(I * + K) + Piece
mun = H(I * + K)
If mun < 6 Then Gen = Gen - mun * 2 ^ mun
If mun > 5 And mun Mod 6 = 0 Then mun = mun \ 6 - 1: Gen = Gen + mun * 2 ^ mun
Next K
'竖线影响
b = IIf(I - 4 > 0, I - 4, 0)
e = IIf(I > , , I)
For K = b To e
mun = V(K * + J)
If mun < 6 Then Gen = Gen + mun * 2 ^ mun
If mun > 5 And mun Mod 6 = 0 Then mun = mun \ 6 - 1: Gen = Gen - mun * 2 ^ mun
V(K * + J) = V(K * + J) + Piece
mun = V(K * + J)
If mun < 6 Then Gen = Gen - mun * 2 ^ mun
If mun > 5 And mun Mod 6 = 0 Then mun = mun \ 6 - 1: Gen = Gen + mun * 2 ^ mun
Next K
'撇线影响
b = IIf(I - 4 > 0, I - 4, 0)
e = IIf(I > , , I)
b = IIf(b > J + I - IIf(J + 4 > , , J + 4), b, J + I - IIf(J + 4 > , , J + 4))
e = IIf(e > J + I - IIf(J > 4, J, 4), J + I - IIf(J > 4, J, 4), e)
For K = b To e
mun = RL(K * + I + J - K)
If mun < 6 Then Gen = Gen + mun * 2 ^ mun
If mun > 5 And mun Mod 6 = 0 Then mun = mun \ 6 - 1: Gen = Gen - mun * 2 ^ mun
RL(K * + I + J - K) = RL(K * + I + J - K) + Piece
mun = RL(K * + I + J - K)
If mun < 6 Then Gen = Gen - mun * 2 ^ mun
If mun > 5 And mun Mod 6 = 0 Then mun = mun \ 6 - 1: Gen = Gen + mun * 2 ^ mun
Next K
'捺线影响
b = IIf(I - 4 > 0, I - 4, 0)
e = IIf(I > , , I)
b = IIf(b > I - J + IIf(J - 4 > 0, J - 4, 0), b, I - J + IIf(J - 4 > 0, J - 4, 0))
e = IIf(e > I - J + IIf(J > , , J), I - J + IIf(J > , , J), e)
For K = b To e
mun = LR(K * - I + J + K)
If mun < 6 Then Gen = Gen + mun * 2 ^ mun
If mun > 5 And mun Mod 6 = 0 Then mun = mun \ 6 - 1: Gen = Gen - mun * 2 ^ mun
LR(K * - I + J + K) = LR(K * - I + J + K) + Piece
mun = LR(K * - I + J + K)
If mun < 6 Then Gen = Gen - mun * 2 ^ mun
If mun > 5 And mun Mod 6 = 0 Then mun = mun \ 6 - 1: Gen = Gen + mun * 2 ^ mun
Next K
End Function
'是否存在三子一线(可发展成五子联线)
Function linethree(Piece As Integer) As Integer
Dim mun As Integer
linethree =
'三子一线
mun = Piece * 3
For I = 0 To
If H(I) = mun Then
If Grid(I) = 0 Then
If I Mod < Then
If Grid(I + 5) = 0 Then
For K = 1 To 4
If Grid(I + K) = 0 Then
Tb(0) = I + K
Tb(1) = I
Tb(2) = I + 5
linethree = Tb(0)
Exit Function
End If
Next K
End If
End If
End If
End If
If V(I) = mun Then
If Grid(I) = 0 Then
If (I \ ) < Then
If Grid(I + ) = 0 Then
For K = 1 To 4
If Grid(I + K * ) = 0 Then
Tb(0) = I + K *
Tb(1) = I
Tb(2) = I +
linethree = Tb(0)
Exit Function
End If
Next K
End If
End If
End If
End If
If RL(I) = mun Then
If Grid(I) = 0 Then
If (I \ ) < And I Mod > 4 Then
If Grid(I + ) = 0 Then
For K = 1 To 4
If Grid(I + K * ) = 0 Then
Tb(0) = I + K *
Tb(1) = I
Tb(2) = I +
linethree = Tb(0)
Exit Function
End If
Next K
End If
End If
End If
End If
If LR(I) = mun Then
If Grid(I) = 0 Then
If (I \ ) < And I Mod < Then
If Grid(I + ) = 0 Then
For K = 1 To 4
If Grid(I + K * ) = 0 Then
Tb(0) = I + K *
Tb(1) = I
Tb(2) = I +
linethree = Tb(0)
Exit Function
End If
Next K
End If
End If
End If
End If
Next I
End Function
Private Sub munHelp_Click() '帮助
lblHelp.Visible = True
End Sub
手把手超详细!教你用turtle画一个象棋棋盘附源码
本文教你使用turtle库画出中国象棋棋盘并提供源代码,码象助你掌握画图技能。源码
一、象棋简介
通过turtle绘制象棋棋盘示意图。棋源棋棋
二、码象确定尺寸
设定棋盘尺寸,源码c 获得像素源码确保绘图比例合适。象棋
三、棋源棋棋初始化
初始化棋盘尺寸数据,码象为绘制做准备。
四、定义自定义函数
创建一个函数简化坐标操作,方便后续绘制。
五、画两个外边框
使用turtle库绘制棋盘的外部边界。
六、画棋盘主体
设计思路,net snmp 源码分析逐步绘制棋盘内部。
七、画将帅老窝斜线
根据路径绘制棋盘上的特殊斜线。
八、绘制楚河汉界
添加棋盘分割线,增加细节。
九、完整源代码
提供Python代码,详细注释,助你快速上手。
此过程充满挑战,网站源码 无广告耗时较长,但通过实践可显著提升Python与turtle技能。
若有关于棋盘绘制的疑问,请直接留言。如有帮助,不妨点赞与转发。感谢你的参与!
关注Python入门速学,一同深入学习Python。
出色的开源中国象棋棋谱APP-Chess
推荐一款名为“Chess中国象棋”的开源小游戏APP,适合中国象棋爱好者。易语言chm源码这款软件由一位热爱象棋和编程的大佬制作,界面简洁大气,功能齐全,帮助棋友们打谱学习和休闲娱乐。
项目设计借鉴国内知名象棋软件,采用C#语言开发,适合大众使用。软件架构使用Visual Studio /和C#,配合NET5.0/6.0以及WPF,SQLite3.0等技术,使得代码管理高效。目前,开发者计划使用Prism框架重构代码,采用MVVM模式,降低模块间耦合度,增强扩展性。
功能方面,Chess中国象棋提供了多种实用功能,方便用户享受游戏和学习。安装步骤简单,使用源码时需在Visual Studio中通过NuGet安装Newtonsoft.Json和System.Data.SQLite两个包,系统会自动根据依赖关系安装所需组件。
软件操作说明和代码示例可以参考文档,通过实际操作来熟悉各项功能。绝杀算法流程图直观展示了棋局的关键操作步骤,便于玩家理解和应用。
Chess中国象棋项目还提供了丰富的古棋谱共享资源,包括少林派和武当派等不同风格的棋谱,满足棋友们对历史文化的兴趣。项目源代码全部开放,用户不仅可下载使用,还可以深入学习编程技巧。
加入程序员了不起读者交流群,与志同道合的伙伴交流技术、分享资源。群内提供简历模板、技术面试资料等G资源,助你快速成长。关注公众号《程序员了不起》,回复特定代码加入交流群,期待你的加入。
VB中国象棋源代码
一、VB中国象棋源代码中国象棋程序一般是通过穷举法,列出人脑接下来可能走的棋,然后列出各种可能的应对方案,然后选择胜率较大的方案进行走棋,其实就是把策略的思考转化为了概率的计算。
当然,中国象棋软件也要具有一定的策略思考能力、棋局的分析能力。其次是要有效率,像人一样要“背”一些棋谱!
至于源码,不用我发了吧,以上已经讲得很清楚了,刚学编程的都会写了。
(仅供参考)
二、中国象棋的源代码
中国象棋源代码blackleft(){ int x,y,n; if(blackcurpos.y>0) { blackcurposition[blacktemppos.x][blacktemppos.y].x; y=position[blacktemppos.x][blacktemp if(board[b.x][blacktemppos.y]==0) drawbmp(xfile[blacblacktemppos.ylacktemppos.x==blackoldpos.x drawbmp(x); } if(blacktemppos.x==blackoldpos.x drawcursor(blackcurpos); blacktemppos.x=blackcuemppos.y=blackcurpos.y; }}blackright()lackcurpos.y<8) { blackcurpos.tion[blacktemppktemppos.ysition[blacktemppos.x][blacktemppos.y].y; if(board[blacktemppos.x][blacktemppos.y]==0) drawbmp(x,y,boardfile[blacktemppos.x][blacktemppos.y]); else if(.x==blackoldpos.x drawbhessfile[ncktemppos.x==blackoldpos.x drawcursor(blackcurpos); blacktemppos.x=blactemppos.ys.y; }}blackdon; if(blackstate==SELECT drawselecursor(blackcurpos); blackoldpos.x=blackcurpos.x; blackoldpos.y=blackcurpos.y; } } else if(blackstate==MOVE y=position[blackoldpos.x][blackoldpos.y].y; drawbmp(x,y,boardfile[blackoldpos.x][blackoldpos.y]); x=position[blackcurpos.x][blackcurpos.y].x; y=position[blackcurpos.x][blackcurpos.y].y; n=board[blackoldpos.x][blackoldpos.y]; drawbmp(x,y,chessfile[n]); if(board[blackcurpos.x][blackcurpos.y]==RED_JIANG) { winner=BLACK; finish=1; return; } board[blackcurpos.x][blackcurpos.y]=n; board[blackoldpos.x][blackoldpos.y]=0; for(i=0;i<=2;i) for(j=3;j<=5;j) if(board[i][j]==BLACK_JIANG) { x=i;y=j;} for(i=x1,j=y,n=0;i<=9;i) { if(board[i][j]==RED_JIANGfinish=1;break;} else if(board[i][j]!=0) n; } turn=RED; redstate=SELECT; drawcursor(redcurpos); drawbmp(,,"bmp\.wfb"); /转交控制权给红方/ } }blackundo(){ int x,y,n; if(blackstate==MOVE) { x=position[blackoldpos.x][blackoldpos.y].x; y=position[blackoldpos.x][blackoldpos.y].y; n=board[blackoldpos.x][blackoldpos.y]; drawbmp(x,y,chessfile[n]); blackoldpos.x=blackcurpos.x; blackoldpos.y=blackcurpos.y; drawcursor(blackcurpos); blackstate=SELECT; }}/----------------------------------------------------/start(){ drawcursor(blackcurpos); drawbmp(,,"bmp\.wfb"); while(!finish) { key=getkey(); switch(key){ case RED_UP: if(turn==RED) redup(); break; case RED_DOWN: if(turn==RED) reddown(); break; case RED_LEFT: if(turn==RED) redleft(); break; case RED_RIGHT: if(turn==RED) redright(); break; case RED_DO: if(turn==RED) reddo(); break; case RED_UNDO: if(turn==RED) redundo(); break; case BLACK_UP: if(turn==BLACK) blackup(); break; case BLACK_DOWN: if(turn==BLACK) blackdown(); break; case BLACK_LEFT: if(turn==BLACK) blackleft(); break; case BLACK_RIGHT: if(turn==BLACK) blackright(); break; case BLACK_DO: if(turn==BLACK) blackdo(); break; case BLACK_UNDO: if(turn==BLACK) blackundo(); break; case ESCAPE: finish=1;break; } }}main(){ init(); initpos(); initchesap(); drawbmp(0,0,"bmp\.wfb"); initdrawchess(); /初始化光标位置/ redcurpos.x=redoldpos.x=redtemppos.x=9; redcurpos.y=redoldpos.y=redtemppos.y=8; blackcurpos.x=blackoldpos.x=blacktemppos.x=0; blackcurpos.y=blackoldpos.y=blacktemppos.y=0;/开始/ start(); if(winner==RED) drawbmp(,,"bmp\.wfb"); else if(winner==BLACK) drawbmp(,,"bmp\.wfb"); else drawbmp(,,"bmp\.wfb"); getch(); end();}
三、中国象棋的源代码
中国象棋源代码blackleft(){ int x,y,n; if(blackcurpos.y>0) { blackcurpos.y--; x=position[blacktemppos.x][blacktemppos.y].x; y=position[blacktemppos.x][blacktemppos.y].y; if(board[blacktemppos.x][blacktemppos.y]==0) drawbmp(x,y,boardfile[blacktemppos.x][blacktemppos.y]); else if(!(blacktemppos.x==blackoldpos.x drawbmp(x,y,chessfile[n]); } if(blacktemppos.x==blackoldpos.x drawcursor(blackcurpos); blacktemppos.x=blackcurpos.x; blacktemppos.y=blackcurpos.y; }}blackright(){ int x,y,n; if(blackcurpos.y<8) { blackcurpos.y; x=position[blacktemppos.x][blacktemppos.y].x; y=position[blacktemppos.x][blacktemppos.y].y; if(board[blacktemppos.x][blacktemppos.y]==0) drawbmp(x,y,boardfile[blacktemppos.x][blacktemppos.y]); else if(!(blacktemppos.x==blackoldpos.x drawbmp(x,y,chessfile[n]); } if(blacktemppos.x==blackoldpos.x drawcursor(blackcurpos); blacktemppos.x=blackcurpos.x; blacktemppos.y=blackcurpos.y; }}blackdo(){ int i,j,x,y,n; if(blackstate==SELECT drawselecursor(blackcurpos); blackoldpos.x=blackcurpos.x; blackoldpos.y=blackcurpos.y; } } else if(blackstate==MOVE y=position[blackoldpos.x][blackoldpos.y].y; drawbmp(x,y,boardfile[blackoldpos.x][blackoldpos.y]); x=position[blackcurpos.x][blackcurpos.y].x; y=position[blackcurpos.x][blackcurpos.y].y; n=board[blackoldpos.x][blackoldpos.y]; drawbmp(x,y,chessfile[n]); if(board[blackcurpos.x][blackcurpos.y]==RED_JIANG) { winner=BLACK; finish=1; return; } board[blackcurpos.x][blackcurpos.y]=n; board[blackoldpos.x][blackoldpos.y]=0; for(i=0;i<=2;i) for(j=3;j<=5;j) if(board[i][j]==BLACK_JIANG) { x=i;y=j;} for(i=x1,j=y,n=0;i<=9;i) { if(board[i][j]==RED_JIANGfinish=1;break;} else if(board[i][j]!=0) n; } turn=RED; redstate=SELECT; drawcursor(redcurpos); drawbmp(,,"bmp\\rzq.wfb"); /转交控制权给红方/ } }blackundo(){ int x,y,n; if(blackstate==MOVE) { x=position[blackoldpos.x][blackoldpos.y].x; y=position[blackoldpos.x][blackoldpos.y].y; n=board[blackoldpos.x][blackoldpos.y]; drawbmp(x,y,chessfile[n]); blackoldpos.x=blackcurpos.x; blackoldpos.y=blackcurpos.y; drawcursor(blackcurpos); blackstate=SELECT; }}/----------------------------------------------------/start(){ drawcursor(blackcurpos); drawbmp(,,"bmp\\bzq.wfb"); while(!finish) { key=getkey(); switch(key){ case RED_UP: if(turn==RED) redup(); break; case RED_DOWN: if(turn==RED) reddown(); break; case RED_LEFT: if(turn==RED) redleft(); break; case RED_RIGHT: if(turn==RED) redright(); break; case RED_DO: if(turn==RED) reddo(); break; case RED_UNDO: if(turn==RED) redundo(); break; case BLACK_UP: if(turn==BLACK) blackup(); break; case BLACK_DOWN: if(turn==BLACK) blackdown(); break; case BLACK_LEFT: if(turn==BLACK) blackleft(); break; case BLACK_RIGHT: if(turn==BLACK) blackright(); break; case BLACK_DO: if(turn==BLACK) blackdo(); break; case BLACK_UNDO: if(turn==BLACK) blackundo(); break; case ESCAPE: finish=1;break; } }}main(){ init(); initpos(); initchesap(); drawbmp(0,0,"bmp\\board.wfb"); initdrawchess(); /初始化光标位置/ redcurpos.x=redoldpos.x=redtemppos.x=9; redcurpos.y=redoldpos.y=redtemppos.y=8; blackcurpos.x=blackoldpos.x=blacktemppos.x=0; blackcurpos.y=blackoldpos.y=blacktemppos.y=0;/开始/ start(); if(winner==RED) drawbmp(,,"bmp\\redwin.wfb"); else if(winner==BLACK) drawbmp(,,"bmp\\blackwin.wfb"); else drawbmp(,,"bmp\\exit.wfb"); getch(); end();}