java课程设计---中国象棋java源码_第1页
java课程设计---中国象棋java源码_第2页
java课程设计---中国象棋java源码_第3页
java课程设计---中国象棋java源码_第4页
java课程设计---中国象棋java源码_第5页
已阅读5页,还剩36页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Wuhan intelligent elevator co production workshop and warehouse steel structures at the donghu development zone, Wuhan University Science and Technology Park, Park Road. 1, an area of the steel: production workshop is 7344.00 square meters; finished goods warehouse is 1036.80 square meters. 2, light

2、 steel structure fabrication and installation costs of the project are: 4.35 million Yuan. 3, the project designed by Wuhan Polytechnic Institute, Zhejiang, the light steel structure limited the production and installation of steel structures. 4, the installation period of the project is: 70 days (w

3、orkshop and warehouse were 70 days). 5, the technology requirements for the production and installation of engineering and construction quality, duration control, supervision of contract performance commissioned by the owners corporation and Zhejiang, the Palace to complete steel structure, a QC, an

4、d monitor in real time to ensure the completion of the project according to the quality and quantity. This project by the Zhejiang plant production system to do immediately after the steel structure, organized by the Engineering Department for field installation. Design and production based on insta

5、llation procedure the project by Wuhan Polytechnic Institute of design, Zhejiang, the steel structure, based on intelligent elevator company and Wuhan steel, signed production and installation contract for production of detail design. Quality acceptance code for architectural design of light steel s

6、tructure and construction profiles: 1, GB5009-2001 2, of the structural specification of the building code for seismic design of GB50011-2001 3, GB50017-2003 4, of the code for design of steel structure of the standard specification for cold-formed thin-walled steel structure GB50018-2002 5, the ste

7、el structure project construction quality approval standard GB50205-2001 6, the Specification for construction and acceptance of steel structure design of high-strength bolt connection JGJ82-91 7, the technical specification for steel structure welding JBJ81-2002 8, the technical specification for s

8、teel structure of door-like steel frame light house CECS102-2002 material selecting overview support section: production workshop roof pitch i=5%. Finished products warehouse roof slope of 8%. Roof: a single layer Board + insulation wool + steel wire mesh roof plate with 0.50mm blue HXY-820 color st

9、eel plate aluminum-plating zinc. thick fiberglass insulation cotton with 75mm density 12Kg per cubic metre. Wall surfaces (workshop): double Board + insulation cotton, outer wall surface with 0.50mm white galvanized HXY-840 color steel plate, wall plate white galvanized HXY-900 0.40mm color steel pl

10、ate, uses 50mm fiberglass insulation cotton, density 12Kg per m3. Part of the main structure: steel column correction after his time on column bottom and base top surface gaps without the secondary water shrinkage of fine stone concrete. Steel columns, beams, frames, beams, columns, a wind column, t

11、raffic beam material Q345B. mechanical properties and chemical composition are in line with the GB/T1591-94 provision of the low-alloy structural steel. Brace, knee brace . Surface protection of steel structure paint according to the contract, be dealt with separately. Located ± 0.000 2% NaN02

12、steel surface coating cement weight cement mortar, and C10 concrete packages to 0.15M, package thickness of 100 feet of concrete. Steel structure installation overview: installation and acceptance of steel structure should be carried out according to the GB50205-2001, strict construction quality and

13、 construction of the installation order. Single component production after the immediate classification number should be placed, it is forbidden to place. Structure before installing the widget should be a comprehensive inspection, such as member number, length, perpendicularity, flatness, it meets

14、the design requirements and specifications. Structure lifting and appropriate measures should be taken to prevent excessive torsion deformation of components. Main steel frame installed, grasp the rope should be set up in time, and support system in place before they can remove temporary installatio

15、n and adjustment range Rover wind rope. All round support should finally install regulated tension. All the superstructure must be installed in the lower part of the structural adjustment in place and fix the following. High-strength bolt connections within the contact surface using sandblasting pro

16、cess and components, not brushing paint or defaced.数学与应用数学专业Java课程设计报告 Java语言程序设计实验报告实验项目名称:中国象棋对弈系统作者姓名与单位:李明 数学与应用数学专业 数学081班摘要:本文主要是运用java实现具有一定功能的中国象棋对弈系统软件,主要功能如下:a、 象棋对弈:红方先走,然后黑方再走,红黑交替,直到一方获胜。b、 新游戏:任何时候可以重新开始一盘新的对弈。c、 悔棋:当走错棋的时候可以悔棋。d、 信息提示:提示当前信息状态。e、 简单的帮助文档:象棋规则介绍、软件的简单介绍和编制说明关键词:java、中国

17、象棋对弈系统 正文:一 程序设计说明1.1程序的设计及实现本系统主要有以下4个模块,每个模块对应一个程序包:1、engine:搜索引擎包,系统的核心部分。2、message:网络对战过程中各种消息及其传递机制的类实现包。3、main:主界面实现包。4、pieces:棋子及其相关类实现包。现就各个包中的要点给与说明。1.1.1 搜索引擎的实现(engine包)(1) BitBoard.java:位棋盘的实现,见2.4节。(2) CCEvalue.java:评价函数知识类。本程序使用开源软件“梦入神蛋”的快速评价函数。该函数包含子力价值和棋子所在位置的奖励值。子力价值分别是:帅-0, 仕- 40,

18、 象-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,

19、 4, 2, 2, 5, 4, 2, 2 上面的每行代表棋盘的一条纵线。其中,-10所在的位置是“窝心马”,所以要罚10分。(3) ChessPosition.java:动态局面类包含对局过程中的动态信息,主要实现的是2.4节的各类位棋盘和移子函数。(4) MoveStruct.java:着法表示类。(5) PreMove.java:伪合法着法生成模块,见4.1。(6) MoveSortStruct.java:合法着法的生成及其排序算法,见4.2。(7) SearchMove.java:搜索算法,实现如下功能:1)主置换表及开局库2)Alpha-Beta搜索算法3)针对吃子着法的静态搜索算法4

20、)适应性空着裁剪算法:见5.5.2,根据不同情况来调整R值的做法,称为“适应性空着裁剪”(Adaptive Null-Move Pruning),它首先由Ernst Heinz发表在1999年的ICCA杂志上。其内容可以概括为:a. 深度小于或等于6时,用R = 2的空着裁剪进行搜索b. 深度大于8时,用R = 3; c. 深度是6或7时,如果每方棋子都大于或等于3个,则用 R = 3,否则用 R = 2。5)带时间控制的迭代加深搜索算法:每次加深搜索都判断时间是否够用。6)“将军”扩展(加深)搜索算法:当搜索到己方被“将”时,增加搜索的深度。7)主要变例搜索算法1.1.2 信息传输机制(me

21、ssage包)在对弈过程中(主要是网络对弈)需要在对弈双方之间传输各类信息,抽象为各类消息。如时间规则的协定、各方的走子信息等。每方都有消息接收、消息处理和消息发送程序(OuterMsgReceiver、LocalMsgReceiver,QzMessageHandler,MessageSender)。己方的MessageSender与对方的OuterMsgReceiver通过接口SrConnection连接。所有接收的消息放入消息队列QzMsgQueue中,等待消息处理进程QzMessageHandler来处理。所有的消息都封装在QzMessage类对象中,消息的类型通过消息的Header类型

22、(以静态常量存放在MsgHeader类中)来区分。1.1.3 棋子(pieces包)Qizi.java包含棋子的信息,如棋子的(在棋盘上的)位置、图片、名称、类型、状态等。PiecesFactory.java以“工厂”模式提供根据棋子类型或其他信息生成相关Qizi对象的方法。1.2主控模块(main包)实现了程序界面与消息传递、搜索引擎的集成。(1) NewBoard.java:棋盘坐标系统及其界面的实现。(2) CChessApp.java:主界面类,以内部类实现了QzMessageHandler接口、计时规则TimeRule接口以及事件的处理程序,根据需要生成其他的并发线程如消息接收、处理

23、和发送,机器思考(启动搜索引擎),计时显示等。(3) SetRuleDialog.java:设置规则的对话框。(4) SetSysInfoDialog.java:设置系统的一些属性如对战模式、连接端口等。(5) Translation.java:提供了一系列实用方法主要有:1)FEN串与局面ChessPosition对象之间的转换2)不同着法表示(见第一章)之间的转换。如“炮二平五”与“Ch2-e2”及“62.5或C2.5“(C和6代表炮)这几种表示法之间的转换3)棋谱文件的读入和存储。4)开局库的生成:将近年实战的棋谱文件(可能有几种格式)整理生成开局库。2、 运行结果:3、 设计体会:本次

24、课程设计主要是运用本学期所学到的Java基础知识来设计一个符合要求的中国象棋对弈系统,这期间我遇到了很多的困难,发现了很多的问题,正是在解决问题的期间我才慢慢地熟悉了Java的基础知识,才慢慢学会了如何去按照给定的要求设计出合适的java系统。通过本次课程设计,我明白了一个道理:无论做什么事情,都必需养成严谨,认真,善思的工作作风遇到问题最好的办法就是请教别人,因为每个人掌握的情况都不一样,一个人不可能做到处处都懂,必须发挥群众的力量,复杂的事情才能够简单化。这一点我深有体会,在很多时候,我遇到的困难或许别人之前就遇到过,向他们请教远比自己在那边摸索来得简单,来得快。附件程序代码:import

25、 java.awt.*;import java.awt.event.*;import javax.swing.*;import java.util.*;import java.io.*;public class Chesspublic static void main(String args)new ChessMainFrame("中国象棋:观棋不语真君子,棋死无悔大丈夫");class ChessMainFrame extends JFrame implements ActionListener,MouseListener,Runnable/玩家JLabel play =

26、 new JLabel32;/棋盘JLabel image;/窗格Container con;/工具栏JToolBar jmain;/重新开始JButton anew;/悔棋JButton repent;/退出JButton exit;/当前信息JLabel text;/保存当前操作Vector Var;/规则类对象(使于调用方法)ChessRule rule;/* 单击棋子* chessManClick = true 闪烁棋子 并给线程响应* chessManClick = false 吃棋子 停止闪烁 并给线程响应*/boolean chessManClick;/* 控制玩家走棋* che

27、ssPlayClick=1 黑棋走棋* chessPlayClick=2 红棋走棋 默认红棋* chessPlayClick=3 双方都不能走棋*/int chessPlayClick=2;/控制棋子闪烁的线程Thread tmain;/把第一次的单击棋子给线程响应static int Man,i;ChessMainFrame()new ChessMainFrame("中国象棋");/* 构造函数* 初始化图形用户界面*/ChessMainFrame(String Title)/获行客格引用con = this.getContentPane();con.setLayout(

28、null);/实例化规则类rule = new ChessRule();Var = new Vector();/创建工具栏jmain = new JToolBar();text = new JLabel("欢迎使用象棋对弈系统");/当鼠标放上显示信息text.setToolTipText("信息提示");anew = new JButton(" 新 游 戏 ");anew.setToolTipText("重新开始新的一局");exit = new JButton(" 退 出 ");exit.s

29、etToolTipText("退出象棋程序程序");repent = new JButton(" 悔 棋 ");repent.setToolTipText("返回到上次走棋的位置");/把组件添加到工具栏jmain.setLayout(new GridLayout(0,4);jmain.add(anew);jmain.add(repent);jmain.add(exit);jmain.add(text);jmain.setBounds(0,0,558,30);con.add(jmain);/添加棋子标签drawChessMan();/

30、注册按扭监听anew.addActionListener(this);repent.addActionListener(this);exit.addActionListener(this);/注册棋子移动监听for (int i=0;i<32;i+)con.add(playi);playi.addMouseListener(this);/添加棋盘标签con.add(image = new JLabel(new ImageIcon("imageMain.GIF");image.setBounds(0,30,558,620);image.addMouseListener(

31、this);/注册窗体关闭监听this.addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent we)System.exit(0););/窗体居中Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();Dimension frameSize = this.getSize();if (frameSize.height > screenSize.height)frameSize.height = screenSize.h

32、eight;if (frameSize.width > screenSize.width)frameSize.width = screenSize.width;this.setLocation(screenSize.width - frameSize.width) / 2 - 280 ,(screenSize.height - frameSize.height ) / 2 - 350); /设置this.setIconImage(new ImageIcon("image红将.GIF").getImage();this.setResizable(false);this.

33、setTitle(Title);this.setSize(558,670);this.show();/* 添加棋子方法*/public void drawChessMan()/流程控制int i,k;/图标Icon in;/黑色棋子/车in = new ImageIcon("image黑车.GIF");for (i=0,k=24;i<2;i+,k+=456)playi = new JLabel(in);playi.setBounds(k,56,55,55);playi.setName("车1");/马in = new ImageIcon("

34、;image黑马.GIF");for (i=4,k=81;i<6;i+,k+=342)playi = new JLabel(in);playi.setBounds(k,56,55,55);playi.setName("马1");/相in = new ImageIcon("image黑象.GIF");for (i=8,k=138;i<10;i+,k+=228)playi = new JLabel(in);playi.setBounds(k,56,55,55);playi.setName("象1");/士in = n

35、ew ImageIcon("image黑士.GIF");for (i=12,k=195;i<14;i+,k+=114)playi = new JLabel(in);playi.setBounds(k,56,55,55);playi.setName("士1");/卒in = new ImageIcon("image黑卒.GIF");for (i=16,k=24;i<21;i+,k+=114)playi = new JLabel(in);playi.setBounds(k,227,55,55);playi.setName(&q

36、uot;卒1" + i);/炮in = new ImageIcon("image黑炮.GIF");for (i=26,k=81;i<28;i+,k+=342)playi = new JLabel(in);playi.setBounds(k,170,55,55);playi.setName("炮1" + i);/将in = new ImageIcon("image黑将.GIF");play30 = new JLabel(in);play30.setBounds(252,56,55,55);play30.setName(&

37、quot;将1");/红色棋子/车in = new ImageIcon("image红车.GIF");for (i=2,k=24;i<4;i+,k+=456)playi = new JLabel(in);playi.setBounds(k,569,55,55);playi.setName("车2");/马in = new ImageIcon("image红马.GIF");for (i=6,k=81;i<8;i+,k+=342)playi = new JLabel(in);playi.setBounds(k,569

38、,55,55);playi.setName("马2");/相in = new ImageIcon("image红象.GIF");for (i=10,k=138;i<12;i+,k+=228)playi = new JLabel(in);playi.setBounds(k,569,55,55);playi.setName("象2");/士in = new ImageIcon("image红士.GIF");for (i=14,k=195;i<16;i+,k+=114)playi = new JLabel(i

39、n);playi.setBounds(k,569,55,55);playi.setName("士2");/兵in = new ImageIcon("image红卒.GIF");for (i=21,k=24;i<26;i+,k+=114)playi = new JLabel(in);playi.setBounds(k,398,55,55);playi.setName("卒2" + i);/炮in = new ImageIcon("image红炮.GIF");for (i=28,k=81;i<30;i+,k

40、+=342)playi = new JLabel(in);playi.setBounds(k,455,55,55);playi.setName("炮2" + i);/帅in = new ImageIcon("image红将.GIF");play31 = new JLabel(in);play31.setBounds(252,569,55,55);play31.setName("帅2");/* 线程方法控制棋子闪烁*/public void run()while (true)/单击棋子第一下开始闪烁if (chessManClick)p

41、layMan.setVisible(false);/时间控制trytmain.sleep(200);catch(Exception e)playMan.setVisible(true);/闪烁当前提示信息 以免用户看不见else text.setVisible(false);/时间控制trytmain.sleep(250);catch(Exception e)text.setVisible(true);trytmain.sleep(350);catch (Exception e)/* 单击棋子方法*/public void mouseClicked(MouseEvent me)System.o

42、ut.println("Mouse");/当前坐标int Ex=0,Ey=0; /启动线程if (tmain = null)tmain = new Thread(this);tmain.start(); /单击棋盘(移动棋子)if (me.getSource().equals(image)/该红棋走棋的时候if (chessPlayClick = 2 && playMan.getName().charAt(1) = '2')Ex = playMan.getX();Ey = playMan.getY();/移动卒、兵if (Man > 1

43、5 && Man < 26)rule.armsRule(Man,playMan,me);/移动炮else if (Man > 25 && Man < 30)rule.cannonRule(playMan,play,me);/移动车else if (Man >=0 && Man < 4)rule.cannonRule(playMan,play,me);/移动马else if (Man > 3 && Man < 8)rule.horseRule(playMan,play,me);/移动相、象e

44、lse if (Man > 7 && Man < 12)rule.elephantRule(Man,playMan,play,me);/移动仕、士else if (Man > 11 && Man < 16)rule.chapRule(Man,playMan,play,me);/移动将、帅else if (Man = 30 | Man = 31)rule.willRule(Man,playMan,play,me);/是否走棋错误(是否在原地没有动)if (Ex = playMan.getX() && Ey = playMan

45、.getY()text.setText(" 红棋走棋");chessPlayClick=2;else text.setText(" 黑棋走棋");chessPlayClick=1;/if/该黑棋走棋的时候else if (chessPlayClick = 1 && playMan.getName().charAt(1) = '1')Ex = playMan.getX();Ey = playMan.getY();/移动卒、兵if (Man > 15 && Man < 26)rule.armsRul

46、e(Man,playMan,me);/移动炮else if (Man > 25 && Man < 30)rule.cannonRule(playMan,play,me);/移动车else if (Man >=0 && Man < 4)rule.cannonRule(playMan,play,me);/移动马else if (Man > 3 && Man < 8)rule.horseRule(playMan,play,me);/移动相、象else if (Man > 7 && Man <

47、; 12)rule.elephantRule(Man,playMan,play,me);/移动仕、士else if (Man > 11 && Man < 16)rule.chapRule(Man,playMan,play,me);/移动将、帅else if (Man = 30 | Man = 31)rule.willRule(Man,playMan,play,me);/是否走棋错误(是否在原地没有动)if (Ex = playMan.getX() && Ey = playMan.getY()text.setText(" 黑棋走棋"

48、);chessPlayClick=1;else text.setText(" 红棋走棋");chessPlayClick=2;/else if/当前没有操作(停止闪烁)chessManClick=false;/if/单击棋子else/第一次单击棋子(闪烁棋子)if (!chessManClick)for (int i=0;i<32;i+)/被单击的棋子if (me.getSource().equals(playi)/告诉线程让该棋子闪烁Man=i;/开始闪烁chessManClick=true;break;/for/if/第二次单击棋子(吃棋子)else if (ch

49、essManClick)/当前没有操作(停止闪烁)chessManClick=false;for (i=0;i<32;i+)/找到被吃的棋子if (me.getSource().equals(playi)/该红棋吃棋的时候if (chessPlayClick = 2 && playMan.getName().charAt(1) = '2')Ex = playMan.getX();Ey = playMan.getY(); /卒、兵吃规则if (Man > 15 && Man < 26)rule.armsRule(playMan,p

50、layi);/炮吃规则else if (Man > 25 && Man < 30)rule.cannonRule(0,playMan,playi,play,me);/车吃规则else if (Man >=0 && Man < 4)rule.cannonRule(1,playMan,playi,play,me);/马吃规则else if (Man > 3 && Man < 8)rule.horseRule(playMan,playi,play,me);/相、象吃规则else if (Man > 7 &

51、;& Man < 12)rule.elephantRule(playMan,playi,play);/士、仕吃棋规则else if (Man > 11 && Man < 16)rule.chapRule(Man,playMan,playi,play);/将、帅吃棋规则else if (Man = 30 | Man = 31)rule.willRule(Man,playMan,playi,play);playMan.setVisible(true);/是否走棋错误(是否在原地没有动)if (Ex = playMan.getX() && Ey = playMan.getY()text.setText(" 红棋走棋");chessPlayClick=2;break;elsetext.setText(" 黑棋走棋");chessPlayClick=1;break;/if/该黑棋吃棋的时候else if (chessPlayClick = 1 && playMan.getName().charAt(1) = '1')Ex = playMan.getX();Ey = playMan.getY();/卒吃规则if (Man > 15 &&

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论