ImageVerifierCode 换一换
格式:DOCX , 页数:22 ,大小:16.68KB ,
资源ID:6858258      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6858258.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(c#五子棋游戏.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

c#五子棋游戏.docx

1、c#五子棋游戏/ button1开始游戏/ button2重新开始/ panal1游戏界面using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Drawing.Imaging;using System.Drawing.Drawing2D;using System.Thread

2、ing;namespace 图像处理 public partial class Form1 : Form xyz class1=new xyz (); static int, count = new int15, 15; private enum kind white, black ; private kind flag=kind.black ; private Bitmap bm = new Bitmap(900,700); public Form1() InitializeComponent(); private class xyz public int xget;set ; public

3、 int yget;set ; public int z get; set; public int position get; set; public int lose get; set; private bool judgewin() int pro=1; int k = 1; for(int i=0;i15;i+) for(int j=0;j15;j+) if (counti, j != 0) while (true)/往右边遍历 if (i + k = 15 | j = 15) pro = 1; k = 1; break; if (counti + k, j = counti, j) p

4、ro+; k+; else pro = 1; k = 1; break; if (pro = 5) if (counti, j = 1) MessageBox.Show(您赢了!); else MessageBox.Show(您输了!); return true; while (true)/往右下遍历 if (i + k = 15 | i + k = 15 | j + k = 5) if (counti, j = 1) MessageBox.Show(您赢了!); else MessageBox.Show(您输了!); return true; while (true)/往下边遍历 if (i

5、 =15 | j + k = 15|i0|j+k= 5) if (counti, j = 1) MessageBox.Show(您赢了!); else MessageBox.Show(您输了!); return true; while (true)/往左下遍历 if (i - k = 15 | i - k = 15 | j + k = 5) if (counti, j = 1) MessageBox.Show(您赢了!); else MessageBox.Show(您输了!); return true; return false; private void machine()/机器落子 cla

6、ss1 = new xyz(); int pro=1; int k = 1; for (int i = 0; i 15; i+) for (int j = 0; j 15;j+ ) if (counti, j != 0) while (true)/往下边遍历 if (i 15 & j + k = 0 & j + k = 0) /不越界 if (counti, j + k = counti, j) pro+; k+; else if (counti, j + k != 0 & (j - 1) 0) /上面是墙 pro = 1; k = 1; break; if (counti, j + k !=

7、 0 & counti, j - 1 != 0) pro = 1; k = 1; break; if (counti, j + k != 0) pro-; if (class1.z pro) /记录点 class1.x = i; class1.y = j; class1.z = pro; class1.position = 3; class1.lose = -1; k = 1; pro = 1; break; if (class1.z pro) class1.x = i; class1.y = j; class1.z = pro; class1.position = 3; k = 1; pro

8、 = 1; break; else/什么都不做 k = 1; pro = 1; break; else/下面越界 if (counti, j -1 != 0) /上面是子 pro = 1; k = 1; break; pro-; if (class1.z = 0 & i + k = 0 & j 15) if (counti + k, j = counti, j) pro+; k+; else if (counti + k, j != 0 & i - 1 0) /左边是墙 pro = 1; k = 1; break; if (counti + k, j != 0 & counti - 1, j

9、!= 0) pro = 1; k = 1; break; if (counti + k, j != 0) pro-; if (class1.z pro) /记录点 class1.x = i; class1.y = j; class1.z = pro; class1.position = 1; class1.lose = -1; k = 1; pro = 1; break; if (class1.z pro) class1.x = i; class1.y = j; class1.z = pro; class1.position = 1; k = 1; pro = 1; break; else/什

10、么都不做 k = 1; pro = 1; break; else if (counti-1, j != 0) /左边是子 pro = 1; k = 1; break; pro-; if (class1.z pro) /记录点 class1.x = i; class1.y = j; class1.z = pro; class1.position = 1; class1.lose = -1; k = 1; pro = 1; break; else/什么都不做 k = 1; pro = 1; break; while (true)/往右下遍历 if (i + k = 0 & j + k = 0) i

11、f (counti + k, j + k = counti, j) pro+; k+; else if (counti + k, j + k != 0 & (i - 1 0 | j - 1 0) /左上是墙 pro = 1; k = 1; break; if (counti + k, j + k != 0 & counti - 1, j - 1 != 0) pro = 1; k = 1; break; if (counti + k, j + k != 0) pro-; if (class1.z pro) /记录点 class1.x = i; class1.y = j; class1.z = p

12、ro; class1.position = 2; class1.lose = -1; k = 1; pro = 1; break; if (class1.z pro) class1.x = i; class1.y = j; class1.z = pro; class1.position = 2; k = 1; pro = 1; break; else/什么都不做 k = 1; pro = 1; break; else if (counti -1, j -1 != 0 ) /左上是墙 pro = 1; k = 1; break; pro-; if (class1.z pro) /记录点 clas

13、s1.x = i; class1.y = j; class1.z = pro; class1.position = 2; class1.lose = -1; k = 1; pro = 1; break; else/什么都不做 k = 1; pro = 1; break; while (true)/往左下遍历 if (i - k = 0 & j + k = 0) if (counti - k, j + k = counti, j) pro+; k+; else if (counti - k, j + k != 0 & (i + 1 15 | j - 1 0) pro = 1; k = 1; br

14、eak; if (counti - k, j + k != 0 & counti + 1, j - 1 != 0) pro = 1; k = 1; break; if (counti - k, j + k != 0) pro-; if (class1.z pro) /记录点 class1.x = i; class1.y = j; class1.z = pro; class1.position = 4; class1.lose = -1; k = 1; pro = 1; break; if (class1.z pro) class1.x = i; class1.y = j; class1.z =

15、 pro; class1.position = 4; k = 1; pro = 1; break; else/什么都不做 k = 1; pro = 1; break; else if (counti +1, j -1 != 0) pro = 1; k = 1; break; pro-; if (class1.z pro) /记录点 class1.x = i; class1.y = j; class1.z = pro; class1.position = 4; class1.lose = -1; k = 1; pro = 1; break; else/什么都不做 k = 1; pro = 1;

16、break; if (class1.position = 1) if (class1.lose = -1) class1.x-; else class1.x += class1.z; if(class1.position =2) if (class1.lose = -1) class1.x-; class1.y-; else class1.x += class1.z; class1.y += class1.z; if (class1.position = 3) if (class1.lose = -1) class1.y-; else class1.y += class1.z; if(clas

17、s1 .position=4) if (class1.lose = -1) class1.x+; class1.y-; else class1.x -= class1.z; class1.y += class1.z; this.richTextBox1.AppendText(电脑落子横 + (class1.x + 1) + ,竖 + (class1.y + 1) + n); paintwhite(new Rectangle(class1.x*40-15, class1.y*40-15, 30, 30); countclass1.x, class1.y = 2; if (judgewin() =

18、 true) return; flag = kind.black; private void paintwhite(Rectangle rect) Graphics g = Graphics.FromImage(bm); g.TranslateTransform(20, 20); g.FillEllipse(new LinearGradientBrush (new Point (rect.X,rect .Y),new Point (rect.X +15,rect .Y +15),Color .FromArgb (250,Color .White),Color .FromArgb (255,Co

19、lor.White), rect); private void paintblack(Rectangle rect) Graphics g = Graphics.FromImage(bm); g.TranslateTransform(20, 20); g.FillEllipse(new LinearGradientBrush(new Point(rect.X, rect.Y), new Point(rect.X + 15, rect.Y + 15), Color.FromArgb(250, Color.Black), Color.FromArgb(200, Color.Black ), rec

20、t); private void paintpanel() Graphics g=Graphics .FromImage (bm); g.TranslateTransform(20, 20); g.DrawRectangle(new Pen(Color.Black, 3), 0, 0,560,560); for (int i = 1; i = 14; i+) g.DrawLine(new Pen(Color.Black, 1), new Point(i * 40, 0), new Point(i * 40, 560); g.DrawLine(new Pen(Color.Black, 1), n

21、ew Point(0, i * 40), new Point(560, i * 40); private void button1_Click(object sender, EventArgs e) this.button2.Visible = false; for (int i = 0; i 15; i+) for (int j = 0; j 15; j+) counti, j = 0; paintpanel(); this.pictureBox1.BackgroundImage = null; this.pictureBox1.BackgroundImage = bm; private v

22、oid pictureBox1_MouseClick(object sender, MouseEventArgs e) if (this.pictureBox1.BackgroundImage = null) return; if (flag = kind.white) return; int X,Y; if (Convert .ToInt16(e.X) 20 | Convert .ToInt16(e.Y) 20) return; if (Convert .ToInt16(e.X-20) % 40 20) X = (Convert .ToInt16(e.X-20) / 40) * 40; el

23、se X = (Convert .ToInt16(e.X-20) / 40 + 1) * 40; if (Convert .ToInt16(e.Y-20) % 40 20) Y = (Convert .ToInt16(e.Y-20) / 40) * 40; else Y = (Convert .ToInt16(e.Y-20) / 40 + 1) * 40; /人落子记为1 if (countX / 40, Y / 40 = 1) return; countX / 40, Y / 40 = 1; this.richTextBox1.AppendText(您落子横 + (X / 40 + 1).T

24、oString () + ,竖 + (Y / 40 + 1)+n); paintblack(new Rectangle(X-15, Y-15, 30, 30); this.pictureBox1.BackgroundImage = null; this.pictureBox1.BackgroundImage = bm; flag = kind.white ; if (judgewin() = true) return; machine(); private void pictureBox1_BackgroundImageChanged(object sender, EventArgs e) /*if (flag = kind.white) Thread th = new Thread(new ThreadStart(machine); th.Start(); */ private void button2_Click(object sender, EventArgs e) this.button1.Visible = false; this.button2.Visible = tru

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1