嵌入式WinCE课程设计报告黑白棋Word下载.docx
《嵌入式WinCE课程设计报告黑白棋Word下载.docx》由会员分享,可在线阅读,更多相关《嵌入式WinCE课程设计报告黑白棋Word下载.docx(27页珍藏版)》请在冰豆网上搜索。
随着网络技术的日新月异和计算机的普及,当今的计算机技术也走上了平民化和娱乐化的时代,计算机技术再也不是只能由少数人掌握的深不可测的学问;
同时个人计算机也由原来单纯的数值计算和工业应用逐渐转变成像电视机一样的家庭娱乐中心,伴随着这种巨大的转变计算机软件的发展也走向了娱乐化。
尤其是游戏产业的发展已经成为信息产业中发展势头最猛烈最具前景的一个分支,而游戏厅也渐渐被网吧挤出了正常的营业市场,游戏除了单纯的个人娱乐功能之外,也逐渐向互动的方向发展。
游戏的功能不断按照玩家的需求和爱好扩展延伸进化,如今运行在各种平台上不同名称,不同内容,不同形式的游戏不仅仅为广大游戏爱好者提供了丰富的选择,而且为游戏开发商带来了丰厚的回报,游戏产业吸引着许多程序员去开发更多更新的游戏。
基于游戏发展的历史和前景,我们决定用C#语言开发一款小游戏,游戏内容来自网络上日渐流行的一种智力游戏‘黑白棋’。
黑白棋作为一款经典的棋类博弈游戏,经久不衰,具有很强的趣味性,深受广大游戏爱好者的喜爱。
那么开放一款基于WinCE的黑白棋游戏,具有很高的实用价值。
1.2研究目的
随着消费类电子产业的蓬勃发展,越来越多的嵌入式电子产品走进了千家万户。
各式各样的嵌入式系统出现在了众多的行业和应用中,其中WinCE产品在市场上最受青睐。
本课题的黑白棋游戏设计就是基于WinCE平台的。
本程序使用面向对象的C#语言,开发于可以运行于WinCE环境下的游戏程序。
人机对弈、双人游戏等功能,其中人机对弈包含难度选择和先后手选择。
1.3专题成果概述
黑白棋游戏设计所完成的就是一个游戏软件系统。
其一般的功能包括:
开始新局,对弈方式选择,先手选择,棋力设置,限时设置,双方子数计数、帮助信息,关于黑白棋的介绍等,要求设计一个黑白棋游戏软件,通过计算机实现各个功能。
其具体设计要求为:
1、位图的导入和棋盘的生成。
2、记录双方对弈时间的计时器与记录双方子数的计数器。
3、选择人机对战与人人对战的函数及控制堆栈难度的主函数。
第2章:
实验平台的构建
2.1Wince的烧写
●首先,将eboot烧进开发板
●创建超级终端
配置好超级终端,重启开发板电源,在超级终端中得如下视图:
●定制开发板内核
启动WinCE5.0,新创建一个基于WindowsCE的平台
然后进行编译。
●生成项目
打开VS2008,新建项目
点确定后,接着编写自己的应用程序,然后在模拟器上运行即可生成
●打包生成NK.bin
将自己的程序reversi.exe和Framework2.0的安装程序FW.cab复制到生成WinCE内核的release目录下,然后在WinCE5.0平台的project.bib添加如下文件:
然后点击【BuildOS】【CopyFilestoReleaseDirectory】;
再次将自己的程序reversi.exe和Framework2.0的安装程序FW.cab复制到生成WinCE内核的release目录下,然后点击【BuildOS】【MakeRun-TimeImage】,接着到release目录下找到NK.bin文件。
●生成WinCE系统
在前面配置的超级终端中,选择D
启动eshell(C:
\emdoor\Tool)
选择文件刚才生成的NK.bin
在eshell中会提示发送文件成功
超级终端会显示写入闪存的情况
当写入成功后,开发板会自动重启,此时就装好了WinCE系统
2.2MicrosoftActiveSync的同步
●在WinCE中配置网络连接
系统设计
3.1界面要求
✓菜单栏;
✓子数计数器;
✓棋盘设计。
3.2功能要求
✓选择人机对战;
✓选择双人对战;
✓选择初级、中级、高级难度;
✓认输功能;
✓黑白子数统计;
✓游戏帮助;
✓退出游戏。
第4章:
实作完成
4.1界面设计
4.2代码实现
usingSystem;
namespaceReversi
{
publicclassBoard
{
publicstaticreadonlyintBlack=-1;
publicstaticreadonlyintEmpty=0;
publicstaticreadonlyintWhite=1;
publicintBlackCount
{
get{returnthis.blackCount;
}
}
publicintWhiteCount
get{returnthis.whiteCount;
publicintEmptyCount
get{returnthis.emptyCount;
publicintBlackFrontierCount
get{returnthis.blackFrontierCount;
publicintWhiteFrontierCount
get{returnthis.whiteFrontierCount;
publicintBlackSafeCount
get{returnthis.blackSafeCount;
publicintWhiteSafeCount
get{returnthis.whiteSafeCount;
privateintblackCount;
privateintwhiteCount;
privateintemptyCount;
privateintblackFrontierCount;
privateintwhiteFrontierCount;
privateintblackSafeCount;
privateintwhiteSafeCount;
privateint[,]squares;
privatebool[,]safeDiscs;
publicBoard()
this.squares=newint[8,8];
this.safeDiscs=newbool[8,8];
inti,j;
for(i=0;
i<
8;
i++)
for(j=0;
j<
j++)
{
this.squares[i,j]=Board.Empty;
this.safeDiscs[i,j]=false;
}
this.UpdateCounts();
publicBoard(Boardboard)
this.squares[i,j]=board.squares[i,j];
this.safeDiscs[i,j]=board.safeDiscs[i,j];
this.blackCount=board.blackCount;
this.whiteCount=board.whiteCount;
this.emptyCount=board.emptyCount;
this.blackSafeCount=board.blackSafeCount;
this.whiteSafeCount=board.whiteSafeCount;
publicvoidSetForNewGame()
this.squares[3,3]=White;
this.squares[3,4]=Black;
this.squares[4,3]=Black;
this.squares[4,4]=White;
publicintGetSquareContents(introw,intcol)
returnthis.squares[row,col];
publicvoidMakeMove(intcolor,introw,intcol)
{
this.squares[row,col]=color;
intdr,dc;
intr,c;
for(dr=-1;
dr<
=1;
dr++)
for(dc=-1;
dc<
dc++)
if(!
(dr==0&
&
dc==0)&
IsOutflanking(color,row,col,dr,dc))
{
r=row+dr;
c=col+dc;
//Flip'
em.
while(this.squares[r,c]==-color)
{
this.squares[r,c]=color;
r+=dr;
c+=dc;
}
}
publicboolHasAnyValidMove(intcolor)
for(r=0;
r<
r++)
for(c=0;
c<
c++)
if(this.IsValidMove(color,r,c))
returntrue;
returnfalse;
publicboolIsValidMove(intcolor,introw,intcol)
if(this.squares[row,col]!
=Board.Empty)
returnfalse;
this.IsOutflanking(color,row,col,dr,dc))
publicintGetValidMoveCount(intcolor)
intn=0;
//Ifthemoveisvalidforthecolor,bumpthecount.
if(this.IsValidMove(color,i,j))
n++;
returnn;
privateboolIsOutflanking(intcolor,introw,intcol,intdr,intdc)
intr=row+dr;
intc=col+dc;
while(r>
=0&
8&
c>
this.squares[r,c]==-color)
{
r+=dr;
c+=dc;
}
if(r<
0||r>
7||c<
0||c>
7||(r-dr==row&
c-dc==col)||this.squares[r,c]!
=color)
//Otherwise,returntrue;
returntrue;
privatevoidUpdateCounts()
//Resetallcounts.
this.blackCount=0;
this.whiteCount=0;
this.emptyCount=0;
this.blackFrontierCount=0;
this.whiteFrontierCount=0;
this.whiteSafeCount=0;
this.blackSafeCount=0;
boolstatusChanged=true;
while(statusChanged)
statusChanged=false;
for(i=0;
for(j=0;
if(this.squares[i,j]!
=Board.Empty&
!
this.safeDiscs[i,j]&
this.IsOutflankable(i,j))
this.safeDiscs[i,j]=true;
statusChanged=true;
boolisFrontier=false;
if(this.squares[i,j]!
for(dr=-1;
for(dc=-1;
if(!
i+dr>
i+dr<
j+dc>
j+dc<
this.squares[i+dr,j+dc]==Board.Empty)
isFrontier=true;
if(this.squares[i,j]==Board.Black)
this.blackCount++;
if(isFrontier)
this.blackFrontierCount++;
if(this.safeDiscs[i,j])
this.blackSafeCount++;
elseif(this.squares[i,j]==Board.White)
this.whiteCount++;
this.whiteFrontierCount++;
this.whiteSafeCount++;
else
this.emptyCount++;
privateboolIsOutflankable(introw,intcol)
intcolor=this.squares[row,col];
boolhasSpaceSide1,hasSpaceSide2;
boolhasUnsafeSide1,hasUnsafeSide2;
hasSpaceSide1=false;
hasUnsafeSide1=false;
hasSpaceSide2=false;
hasUnsafeSide2=false;
for(j=0;
col&
hasSpaceSide1;
if(this.squares[row,j]==Board.Empty)
hasSpaceSide1=true;
elseif(this.squares[row,j]!
=color||!
this.safeDiscs[row,j])
hasUnsafeSide1=true;
for(j=col+1;
hasSpaceSide2;
hasSpaceSide2=true;
hasUnsafeSide2=true;
if((hasSpaceSide1&
hasSpaceSide2)||
(hasSpaceSide1&
hasUnsafeSide2)||
(hasUnsafeSide1&
hasSpaceSide2))
returntrue;
hasUnsafeSide