资源简介
这个是学校布置的作业,本人以为完成的不错,上传下以供参考
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace MyGobang
{
public partial class Form1 : Form
{
private Point lastMovePoint = new Point(-1 -1);//上一步棋子的坐标
private int[] virtualGobangBoard = new int[15 15];//虚拟棋盘
private PictureBox[] chessPicutureBox = new PictureBox[15 15];//棋子的图片
private int[ ] ValueTable = new int[15 15 9];//临时棋型表
private int[ ] LastValueTable = new int[15 15 5];//最终棋型表
private const int white = 1;
private const int black = -1;
private const int noChess = 0;//无棋子的空格
private int playerChessColor = black;
private Point MVP = new Point(-1 -1);//最有价值点
public Form1()
{
InitializeComponent();
InitializeGobangBoard();
GobangGroupBox.Paint += new PaintEventHandler(GobangGroupBox_Paint);
// GobangGroupBox.MouseMove += new MouseEventHandler(GobangGroupBox_MouseMove);
GobangGroupBox.MouseClick += new MouseEventHandler(GobangGroupBox_MouseClick);
}
private void InitializeGobangBoard()//初始化棋盘
{
int i j;
GobangGroupBox.Paint += new PaintEventHandler(GobangGroupBox_Paint);
for (i = 0; i < 15; i++)
for (j = 0; j < 15; j++)
{
chessPicutureBox[i j] = new PictureBox();//实例化数组之后也要实例化数组中的每一个成员
chessPicutureBox[i j].BackColor = Color.Transparent;
chessPicutureBox[i j].Size = new Size(40 40);
chessPicutureBox[i j].Location = new Point(10 + 40 * i 10 + 40 * j);
chessPicutureBox[i j].Visible = false;
chessPicutureBox[i j].SizeMode = PictureBoxSizeMode.CenterImage;
GobangGroupBox.Controls.Add(chessPicutureBox[i j]);//加棋格
}
}
private void GobangGroupBox_Paint(object sender PaintEventArgs e)//绘制棋盘
{
int i;
Graphics gr = e.Graphics;
Pen myPen = new Pen(Color.Black 2);
SolidBrush sb = new SolidBrush(Color.Red);//单色画笔用于填充
SolidBrush whiteBrush = new SolidBrush(Color.White);
for (i = 0; i < 15; i++)
{
gr.DrawLine(myPen 30 + i * 40 30 30 + i * 40 590);//画横线
gr.DrawLine(myPen 30 30 + i * 40 590 30 + i * 40);//画竖线
}
gr.FillEllipse(sb 146 146 8 8);//画小红点
gr.FillEllipse(sb 466 146 8 8);
gr.FillEllipse(sb 466 466 8 8);
gr.FillEllipse(sb 146 466 8 8);
gr.FillEllipse(sb 306 306 8 8);
}
//棋型表,包括各种棋型的分值
//H指活棋,d指防守,C指冲棋。比如dH3表示对手的“活3”,C4表示己方的“冲4”
private enum pattern
相关资源
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
- c#向word文件插入图片
- C#左侧导航菜单(动态生成)
- C#TCP 通信(TCP发送16进制)
- C# sql实现批量导入数据到数据库
评论
共有 条评论