基于Android平台的五子棋游戏的设计与实现.doc

上传人:good****022 文档编号:116793711 上传时间:2022-07-06 格式:DOC 页数:16 大小:141.52KB
收藏 版权申诉 举报 下载
基于Android平台的五子棋游戏的设计与实现.doc_第1页
第1页 / 共16页
基于Android平台的五子棋游戏的设计与实现.doc_第2页
第2页 / 共16页
基于Android平台的五子棋游戏的设计与实现.doc_第3页
第3页 / 共16页
资源描述:

《基于Android平台的五子棋游戏的设计与实现.doc》由会员分享,可在线阅读,更多相关《基于Android平台的五子棋游戏的设计与实现.doc(16页珍藏版)》请在装配图网上搜索。

1、Android平台五子棋游戏的设计与实现Android平台五子棋游戏的设计与实现摘 要在如今这个智能手机系统群雄角逐的时候,2007年Google推出了一款名为Android的开源智能手机操作系统,它采用Linux内核,开放手机联盟成员可以任意使用和修改SDK包,系统的开源性使其具有良好的拓展性。这款软件包括了操作系统、用户界面和应用程序,即智能手机工作所需要的全部软件。Android的最大特点是其开放性体系架构,不仅具有非常好的开发、调试环境,而且还支持各种可扩展的用户体验,包括丰富的图形组件、多媒体支持功能以及强大的浏览器。因此,对于软件从业人员来说,Android平台具有无限的吸引力。本

2、文围绕一个“基于Android平台的五子棋游戏设计与开发”程序的设计和应用系统的开发课题为背景,介绍了在Android平台上以Java为语言编写游戏的过程。五子棋游戏的开发不仅是一个简单游戏的编写过程,更重要的是在系统分析和设计阶段所做的工作。本程序主要讲述了程序的概要设计、核心设计阶段,利用SQlite、SharedPreferences等数据存储功能,直到形成一个完善的可行性系统。【关键字】Android、五子棋、游戏开发、JavaAbstractIn the intelligent mobile phone system to compete against the top when,

3、in 2007 Google launched a Android open source intelligence mobile phone operating system, it uses the Linux kernel, open mobile phone union members can use and modify SDK package, system open source so that it has good expansibility. This software includes the operating system, the user interface an

4、d the application of intelligent mobile phone work, which required all software. Android is the biggest characteristic of its open architecture, not only has the very good development, debugging environment, but also supports a variety of extensible user experience, including a rich graphical compon

5、ents, multimedia support and powerful browser. Therefore, for software professionals, the Android platform has the infinite attraction.This paper focuses on a platform based on the Android Gobang game design and development program design and development of application system project as background,

6、introduced in the Android platform based on Java language game process. Gobang game development is not only a simple game of the preparation process, but more importantly in the system analysis and design phase work. This program focuses on the overall design of the procedure, a summary of the desig

7、n phase, using the data storage function of SQlite, SharedPreferences and so on, until the feasibility of forming a perfect system.Key words: Android, Java, Gobang, game development1. 引言随着智能手机的快速普及,智能手机操作系统市场风生水起。为了让智能手机用户能够随时随地查询互联网所提供的服务,一种高效的办法就是将应用系统的功能拓展到手机终端上,让手机能够通过移动网以及互联网访问Web网站并处理各种各样的业务。因

8、此,智能手机的应用软件及其需要的服务将有广阔的发展前景。1.1 人机对弈五子棋开发背景每个手机上都有手机游戏,上下班以及无聊闲暇时游戏是人们娱乐的一种方式。Android平台下的手机游戏更是受顾客的亲睐,手机游戏不仅玩起来比较方便,还有助于开发我们的思维,使大家在娱乐的同时也增长了见识,拓展了思维。五子棋对思维及协调能力有益,能使我们注意力集中,耐心也有明显的提升,培养我们的逻辑思维能力,对智力以及记忆力都很有帮助。1.2 相关知识的介绍Android是Google于07年发布的基于Linux平台的开源手机操作系统,号称是首个为移动终端打造的真正开放和完整的移动软件。自从Google发布智能手

9、机Android操作系统平台以来,Android平台一直以惊人速度挺进,并支持Android智能手机迅速进入领先行列。Android在全球的智能手机市场的份额从10年第五位跃进到11年的第一位。目前,智能手机市场份额中Android仍然排名第一,占市场份额的46.3%,iOS系统只占30%。迄今Android是智能机市场上最大的赢家,是销售增长最快、最成功的竞争者。本游戏采用当前很热的Android系统, 以Java语言为基础的2D手机游戏。用户游戏界面通过手机终端来实现,较强的人际交互。这样就大大简化了用户的操作,该游戏为免费游戏,用户可以放心使用。此外,本系统采用了SharedPrefer

10、ences作为应用程序的数据存储,用来存储简单的配置信息,简单快捷,占用系统资源少。背景音乐采用媒体播放功能实现,控制也比较方便。1.2.1 开发工具简介该系统的开发环境是MyEclipse8.5、JDK1.6、Android SDK,运用了Java语言。 Java是Android的基础开发语言,java是一门各方面性能都很好的编程语言,它的基本特点是简单、面象对象、分布式、解释的、健壮的、安全的、结构中立的、可移植的、性能很优异的、多线程的、动态的,适合在internet环境上开发应用系统。java可以制作大部分网络应用程序系统,而且与当今流行的WWW浏览器结合得很好。Java也是一种与平台

11、无关的语言,因此用Java开发的网络应用系统可以在各种平台上运行,大大增加了开发效率,减少重复劳动。而且,Java集成的网络功能有利于开发网络应用系统。JDK(Java Development Kit)是Sun Microsystems针对Java开发员的产品。自从Java推出以来,JDK已经成为使用最广泛的Java SDK。JDK 是整个Java的核心,包括了Java运行环境,Java工具和Java基础的类库。JDK是学好Java的第一步。而专门运行在x86平台的Jrocket在服务端运行效率也要比Sun JDK好很多。从SUN的JDK5.0开始,提供了泛型等非常实用的功能,其版本也不断更新

12、,运行效率得到了非常大的提高。MyEclipse企业级工作平台(MyEclipse Enterprise Workbench ,简称MyEclipse)是对EclipseIDE的扩展,利用它我们可以在数据库和JavaEE的开发、发布以及应用程序服务器的整合方面极大的提高工作效率。它是功能丰富的JavaEE集成开发环境,包括了完备的编码、调试、测试和发布功能,完整支持HTML,Struts,JSP,CSS,Javascript,Spring,SQL,Hibernate。在结构上,MyEclipse的特征可以被分为7类:1 JavaEE模型2 WEB开发工具 3 EJB开发工具4 应用程序服务器的

13、连接器5 JavaEE项目部署服务6 数据库服务7 MyEclipse整合帮助对于以上每一种功能上的类别,在Eclipse中都有相应的功能部件,并通过一系列的插件来实现它们。MyEclipse结构上的这种模块化,可以让我们在不影响其他模块的情况下,对任一模块进行单独的扩展和升级。简单而言,MyEclipse是Eclipse的插件,也是一款功能强大的JavaEE集成开发环境,支持代码编写、配置、测试以及除错,MyEclipse6.0以前版本需先安装Eclipse。MyEclipse6.0以后版本安装时不需安装Eclipse。SDK(software development kit)软件开发工具包

14、。被软件开发工程师用于为特定的软件包、软件框架、硬件平台、操作系统等建立应用软件的开发工具的集合。1.2.2 系统运行配置操作系统:Android 2.1以上。开发包:JDK 1.6、Android SDK。数据存储:SharedPreferences、SQlite。2. 需求分析2.1 功能需求1.适合不同阶段的玩家(新手和熟手)。2.玩家与手机对弈。3.可以为新手提供游戏解说。4.可以纪录玩家的最高游戏纪录(以玩家游戏胜利的时间为标准。)。2.2 性能需求1硬件环境 :PC2软件环境 :Windows XP、Android 2.1以上3. 概要设计3.1 功能设计五子棋分为五个模块:开始游

15、戏、游戏设置、最高纪录、游戏说明、退出游戏。1.开始游戏:.点击进入游戏。2. 游戏设置:.音效设置:开启/关闭音效、背景音乐的开/关。 .难度设置:简单,中等,较难。3.最高纪录:.纪录不同难度获胜的最短时间,可清空。 4. 游戏说明: .五子棋游戏规则的说明及操作说明。5.退出游戏: .退出游戏。3.2 系统功能结构及流程图根据系统功能的要求,可以将系统分解成几个功能模块来分别设计。系统结构如图3.1所示:五 子 棋游戏退出游戏说明最高纪录游戏设置游戏开始(默认简单)简单、中级、困难纪录修改(可清空)3.1系统结构图3.3 数据存储设计SharePreference主要用来保存应用程序的属

16、性设置,在Android平台常用于存储较简单的参数设置。其采用了Map数据结构来存储数据,以键值的方式存储,可以简单的读取与写入。最高纪录则用此存储方式进行存储。通过getPreferences()方法来获得Preferences对象,通过“SharePreferences.Editor editor=uiState.edit();”取得编辑对象,然后通过“deitor.putPreferences()方法添加数据,最后用commit()方法保存这些数据,如果不需要与其它模块共享数据,可以使用Activity.getPreferences()方法保持私有。SQlite是一个开源的关系型数据库,

17、功能非常强大,可以存储大量的数据,能够很容易地对数据进行使用、更新、维护等操作。根据系统所做的需求分析和系统设计,SharedPreferences为本系统最有效的存储方式。4. 棋盘、棋子的绘制本设计中棋盘的设置采用drawLine(float startX, float startY, float stopX, float stopY, Paint paint)/画线,参数一起始点的x轴位置,参数二起始点的y轴位置,参数三终点的x轴水平位置,参数四y轴垂直位置,最后一个参数为Paint画刷对象。本设计中棋子是用drawCircle在坐标上绘制一个经典几何图形。先判断是否有棋,是黑子还是白子

18、,然后判断是哪个坐标,然后调用drawCircle绘制棋子canvas.drawCircle(float,float, float, Paint)方法用于画圆,前两个参数代表圆心坐标,第三个参数为圆半径,第四个参数是画笔;5. 游戏核心设计5.1游戏的三种不同难度等级的设计与输赢判断手机与玩家的胜负判断:每走一步,调用判断方法。其思想为:是根据当前最后一个落子的情况来判断胜负的。实际上需要从四个位置判断,以该子为出发点的水平,竖直和两条分别为 45度角和135度角的线,目的是看在这四个方向是否最后落子的一方构成连续五个的棋子,如果是的话,就表示该盘棋局已经分出胜负。本游戏中最重要的是难度设计,

19、游戏流程如图5.1所示。NYYNNYNY游戏开始电脑落子电脑下棋玩家下棋胜负判断结束是否玩家胜玩家胜利的时间小于最高纪录的时间刷新最高纪录玩家胜电脑胜玩家选择执子颜色5.1游戏流程图三大难度的算法设计,算法的主体思想分三个步骤:第一步:根据双方的当前的形势循环地假设性的分别给自己和对方下一子(在某个范围内下子),并判断此棋子能带来的形势上的变化。第二步:根据上一步结果,组合每一步棋子所带来的所有结果(包括电脑和玩家的)。第三步:根据用户给的游戏难度对上一步结果进行排序,并选子(有进攻形、防守形规则)。名词解析:活四棋:在(横、竖或斜角)方向有同色四子不间隔连成一线,两端都可落子活三棋:在(横、

20、竖或斜角)方向有同色三子不间隔连成一线,两端都可落子单活棋:即在某方向上连成一线的棋只有一端可落子四冲棋:除活四外的,再下一着棋便可形成五连,并且存在五连的可能性的局面搜索方法举例(活三棋):OYX5.2活三棋的示例图棋盘上的坐标都为大于等于0,想要判断活三棋,先判断在哪个方向上有同色的连棋:1) 如图黑子此种情况下在与Y/X轴成45。角的方向上有同色连棋,接下来判断三棋子的坐标是否依次相邻递增1,如果是,再判断,最小坐标(非原点)减1和最大坐标(非棋盘最大坐标)加1的两坐标点上是否为空,为空则是活三,否则,不是2) 如图白子与X/Y轴成135。角的方向上有同色连棋,接下来判断三棋子的X坐标是

21、否依次相邻递增1,Y坐标是否依次递减1,如果是,再判断,最小坐标(非原点)X坐标减1,Y坐标加1后和最大坐标(非棋盘最大坐标)X坐标加1,Y坐标减1后的两坐标点上是否为空,为空则是活三,否则,不是3) 如果平行于X/Y轴,则只需根据X/Y坐标来判断即可。注:最小坐标、最大坐标根据各点的X坐标判断。简单:简单难度的实现,只有当电脑为活四棋的时候才进攻,其他情况离玩家最近下棋棋子最近的8个位置上的空位上随机下棋。中等:中等难度的实现,电脑只防守,少攻击。当玩家有“三活棋”以及“四冲”时,防守;否则选择自己最长连棋并且可下棋的空位下棋。流程图如图5.3所示:YYYYYY防守玩家活四棋机活四棋机四冲棋

22、玩家四冲棋机活三棋玩家活三棋进攻结束5.3中等难度流程图较难:较难难度的实现,机有强烈的防守,有猛烈的攻击。双方都不可以制造活4棋,找活3棋子,不行就找半活4(四冲),再不行就找单活3,活2的攻守模式。流程图如图5.4所示:YYYYYNNNNNNNNNYYYY开始玩家是否有活四棋玩家是否有活三棋玩家是否有冲四棋能否制造活四棋能否制造冲四棋能否制造单活三能否制造活三棋玩家是否有活三棋能否制造活二能否制造单活二防守下棋5.4较难难度流程图结束语经过这一段时间的不断探索,自己对Android的研究,对Android游戏有了进一步的了解和学习。这段时间的不懈努力,五子棋游戏系统设计已初步完成。系统设计

23、为整个游戏构建了框架,各个功能模块实现各个细节部分。难,中,易三种游戏难度的选择。 系统的详细设计将根据系统分析阶段的结论具体化,并完成各个模块的相关功能,从而实现Android五子棋。随着3G智能机的普及,人们对游戏的要求也越来越高,人机对战的实现往往是不够的。现在网络越来越好,网络双人对战也是一个很不错的研究方向。参考文献1 吴亚峰,索光亚.Android 2.0游戏开发实战宝典M.北京:人民邮电出版社2 杨丰盛.Android应用开发揭秘M.北京:机械工业出版社3 高焕堂.Android应用框架原理与程式设计36技M/OL4 裴佳迪,马超,孙仁贵.Android开发全程实录M.人民邮电出

24、版社5 马越.Android的架构与应用D.北京:中国地质大学(北京)硕士学位论文.g an employment tribunal claiEmployment tribunals sort out disagreements between employers and employees.You may need to make a claim to an employment tribunal if: you dont agree with the disciplinary action your employer has taken against you your employer

25、dismisses you and you think that you have been dismissed unfairly.For more information about dismissal and unfair dismissal, seeDismissal.You can make a claim to an employment tribunal, even if you haventappealedagainst the disciplinary action your employer has taken against you. However, if you win

26、 your case, the tribunal may reduce any compensation awarded to you as a result of your failure to appeal.Remember that in most cases you must make an application to an employment tribunal within three months of the date when the event you are complaining about happened. If your application is recei

27、ved after this time limit, the tribunal will not usually accept i.If you are worried about how the time limits apply to you, take advice from one of the organisations listed underFurther help.Employment tribunals are less formal than some other courts, but it is still a legal process and you will ne

28、ed to give evidence under an oath or affirmation.Most people find making a claim to an employment tribunal challenging. If you are thinking about making a claim to an employment tribunal, you should get help straight away from one of the organisations listed underFurther help.If you are being repres

29、ented by a solicitor at the tribunal, they may ask you to sign an agreement where you pay their fee out of your compensation if you win the case. This is known as adamages-based agreement. In England and Wales, your solicitor cant charge you more than 35% of your compensation if you win the case.If

30、you are thinking about signing up for a damages-based agreement, you should make sure youre clear about the terms of the agreement. It might be best to get advice from an experienced adviser, for example, at a Citizens Advice Bureau. To find your nearest CAB, including those that give advice by e-ma

31、il, click onnearest CAB.For more information about making a claim to an employment tribunal, seeEmployment tribunals.The (lack of) air up there Watch mCayman Islands-based Webb, the head of Fifas anti-racism taskforce, is in London for the Football Associations 150th anniversary celebrations and wil

32、l attend Citys Premier League match at Chelsea on Sunday.I am going to be at the match tomorrow and I have asked to meet Yaya Toure, he told BBC Sport.For me its about how he felt and I would like to speak to him first to find out what his experience was.Uefa hasopened disciplinary proceedings again

33、st CSKAfor the racist behaviour of their fans duringCitys 2-1 win.Michel Platini, president of European footballs governing body, has also ordered an immediate investigation into the referees actions.CSKA said they were surprised and disappointed by Toures complaint. In a statement the Russian side

34、added: We found no racist insults from fans of CSKA.Age has reached the end of the beginning of a word. May be guilty in his seems to passing a lot of different life became the appearance of the same day; May be back in the past, to oneself the paranoid weird belief disillusionment, these days, my m

35、ind has been very messy, in my mind constantly. Always feel oneself should go to do something, or write something. Twenty years of life trajectory deeply shallow, suddenly feel something, do it.一字开头的年龄已经到了尾声。或许是愧疚于自己似乎把转瞬即逝的很多个不同的日子过成了同一天的样子;或许是追溯过去,对自己那些近乎偏执的怪异信念的醒悟,这些天以来,思绪一直很凌乱,在脑海中不断纠缠。总觉得自己自己似乎

36、应该去做点什么,或者写点什么。二十年的人生轨迹深深浅浅,突然就感觉到有些事情,非做不可了。The end of our life, and can meet many things really do?而穷尽我们的一生,又能遇到多少事情是真正地非做不可?During my childhood, think lucky money and new clothes are necessary for New Year, but as the advance of the age, will be more and more found that those things are optional;

37、 Junior high school, thought to have a crush on just means that the real growth, but over the past three years later, his writing of alumni in peace, suddenly found that isnt really grow up, it seems is not so important; Then in high school, think dont want to give vent to out your inner voice can b

38、e in the high school children of the feelings in a period, but was eventually infarction when graduation party in the throat, later again stood on the pitch he has sweat profusely, looked at his thrown a basketball hoops, suddenly found himself has already cant remember his appearance.童年时,觉得压岁钱和新衣服是

39、过年必备,但是随着年龄的推进,会越来越发现,那些东西根本就可有可无;初中时,以为要有一场暗恋才意味着真正的成长,但三年过去后,自己心平气和的写同学录的时候,突然就发现是不是真正的成长了,好像并没有那么重要了;然后到了高中,觉得非要吐露出自己的心声才能为高中生涯里的懵懂情愫划上一个句点,但毕业晚会的时候最终还是被梗塞在了咽喉,后来再次站在他曾经挥汗如雨的球场,看着他投过篮球的球框时,突然间发现自己已经想不起他的容颜。Originally, this world, can produce a chemical reaction to an event, in addition to resolut

40、ely, have to do, and time.原来,这个世界上,对某个事件能产生化学反应的,除了非做不可的坚决,还有,时间。A persons time, your ideas are always special to clear. Want, want, line is clear, as if nothing could shake his. Also once seemed to be determined to do something, but more often is he backed out at last. Dislike his cowardice, finall

41、y found that there are a lot of love, there are a lot of miss, like shadow really have been doomed. Those who do, just green years oneself give oneself an arm injection, or is a self-righteous spiritual.一个人的时候,自己的想法总是特别地清晰。想要的,不想要的,界限明确,好像没有什么可以撼动自己。也曾经好像已经下定了决心去做某件事,但更多的时候是最后又打起了退堂鼓。嫌恶过自己的怯懦,最终却发现有

42、很多缘分,有很多错过,好像冥冥之中真的已经注定。那些曾经所谓的非做不可,只是青葱年华里自己给自己注射的一支强心剂,或者说,是自以为是的精神寄托罢了。At the moment, the sky is dark, the air is fresh factor after just rained. Suddenly thought of blue plaid shirt; Those were broken into various shapes of stationery; From the corner at the beginning of deep friendship; Have de

43、clared the end of the encounter that havent start planning. Those years, those days of do, finally, like youth, will end in our life.此刻,天空是阴暗的,空气里有着刚下过雨之后的清新因子。突然想到那件蓝格子衬衫;那些被折成各种各样形状的信纸;那段从街角深巷伊始的友谊;还有那场还没有开始就宣告了终结的邂逅计划那些年那些天的非做不可,终于和青春一样,都将在我们的人生中谢幕。Baumgartner the disappointing news: Mission abor

44、ted. r plays an important role in this mission. Starting at the ground, conditions have to be very calm - winds less than 2 mph, with no precipitation or humidity and limited cloud cover. The balloon, with capsule attached, will move through the lower level of the atmosphere (the troposphere) where

45、our day-to-day weather lives. It will climb higher than the tip of Mount Everest (5.5 miles/8.85 kilometers), drifting even higher than the cruising altitude of commercial airliners (5.6 miles/9.17 kilometers) and into the stratosphere. As he crosses the boundary layer (called the tropopause),e can

46、expect a lot of turbulence.The supersonic descent could happen as early as Sunda.The weatheThe balloon will slowly drift to the edge of space at 120,000 feet ( Then, I would assume, he will slowly step out onto something resembling an Olympic diving platform.Below, the Earth becomes the concrete bot

47、tom of a swimming pool that he wants to land on, but not too hard. Still, hell be traveling fast, so despite the distance, it will not be like diving into the deep end of a pool. It will be like he is diving into the shallow end. Skydiver preps for the big jumpWhen he jumps, he is expected to reach

48、the speed of sound - 690 mph (1,110 kph) - in less than 40 seconds. Like hitting the top of the water, he will begin to slow as he approaches the more dense air closer to Earth. But this will not be enough to stop him completely.If he goes too fast or spins out of control, he has a stabilization par

49、achute that can be deployed to slow him down. His team hopes its not needed. Instead, he plans to deploy his 270-square-foot (25-square-meter) main chute at an altitude of around 5,000 feet (1,524 meters).In order to deploy this chute successfully, he will have to slow to 172 mph (277 kph). He will

50、have a reserve parachute that will open automatically if he loses consciousness at mach speeds.Even if everything goes as planned, it wont. Baumgartner still will free fall at a speed that would cause you and me to pass out, and no parachute is guaranteed to work higher than 25,000 feet (7,620 meters).cause there14

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

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!