-
大小: 5.7MB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2023-11-07
- 語言: C/C++
- 標(biāo)簽: c++??五子棋??游戲設(shè)計(jì)??畢業(yè)設(shè)計(jì)??
資源簡介
基于C++的五子棋游戲設(shè)計(jì) 絕對(duì)可用 詳細(xì)畢業(yè)設(shè)計(jì)代碼,編譯即可運(yùn)行

代碼片段和文件信息
//?Algorithm.cpp?:?implementation?file
//
#include?“stdafx.h“
#include?“GoBang.h“
#include?“Algorithm.h“
#include?“Afxtempl.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CAlgorithm
CAlgorithm::CAlgorithm()
{
}
CAlgorithm::~CAlgorithm()
{
}
int?CAlgorithm::SearchMaxValue(Step?&st?int?array[16][16])
{
int?max_score?=?0;
int?score?=?0;
GameStatus?temp;
temp.is_machine?=?true;
temp.deep?=?0;
for?(int?i?=?0?;?i?16?;?i++)
for?(int?jj?=?0?;?jj16?;jj++)
temp.fivearray[i][jj]?=?array[i][jj];
for?(?i?=?1?;?i?16?;?i++)
for(int?j?=1;?j?16?;?j++)
{
if?(?array[i][j]?==?0)
{
temp.st.x?=?i?;
temp.st.y?=?j;
score?=?0;
int?score1?=?0score2?=?0;
temp.fivearray[i][j]?=?3;
temp.st.side?=?3;
temp.is_machine?=?true;?
temp.score?=?0;
GetCurrentScore(temp);
score1??=?temp.score?;
temp.fivearray[i][j]?=?1;
temp.st.side?=?1?;
temp.is_machine?=?false?;
temp.score?=?0;
?GetCurrentScore(temp);
score2?=?-temp.score?;
//機(jī)器
if?(?score1?>=?10000?)
{
?
temp.fivearray[i][j]?=?3;
temp.st.side?=?3;
temp.is_machine?=?true;?
temp.score?=?0;
Step?tempst1;?
int?tempscore?=?SearchValue(temp.fivearraytempst1false);
if?(?score1? {
st.x?=?tempst1.x;
st.y?=?tempst1.y?;
return?tempscore;
}
else
{
st.x?=?i;
st.y?=?j;
return?score1;
}
}
if?(?score2?>=?10000?)
{
temp.fivearray[i][j]?=?1;
temp.st.side?=?1?;
temp.is_machine?=?false?;
temp.score?=?0;
Step?tempst1;?
int?tempscore?=?SearchValue(temp.fivearraytempst1true);
if?(?score2?<=?tempscore)//
{
st.x?=?tempst1.x;
st.y?=?tempst1.y?;
return?tempscore;
}
else
{
st.x?=?i;
st.y?=?j;
return?score1;
}
}
score?=?score1?+?score2?;
?if??(?score?>?max_score?)
?{
?max_score?=?score?;
?st.x?=?i;
?st.y?=?j;
?}
temp.fivearray[i][j]?=?0;
}
}
return?max_score?;
}
void?CAlgorithm::GetCurrentScore(?GameStatus?&board_situation)
{
int?i?=?board_situation.st.x?;
int?j?=?board_situation.st.y;
board_situation.score?=?0;
//狀態(tài)
//返回8?成5:five
//返回7?活4:alivefour
//返回6?活3:alivethree
//返回5?活2:alivetwo
//返回4?死4:deadfour
//返回3?死3:deadthree
//返回2?死2:deadtwo
//返回0
//搜索出左到右的狀態(tài)
int?lr?=LeftToRight_Status(i??j?board_situation.fivearray);
if??(?lr?==?8?)?
{
if?(?board_situation.is_machine?)
board_situation.score?=?100000;
else
board_situation.score?=?-100000;
return?;
}
//從上到下
int?ud?=?UpToDown_Status(ij
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-05-25?08:45??基于C++的五子棋游戲設(shè)計(jì)\
?????文件???????25374??2012-05-26?22:04??基于C++的五子棋游戲設(shè)計(jì)\Algorithm.cpp
?????文件????????2081??2013-05-16?13:04??基于C++的五子棋游戲設(shè)計(jì)\Algorithm.h
?????文件????????3919??2012-05-26?22:46??基于C++的五子棋游戲設(shè)計(jì)\Chess.cpp
?????文件????????1524??2012-05-26?16:11??基于C++的五子棋游戲設(shè)計(jì)\Chess.h
?????文件??????906416??2013-05-16?12:59??基于C++的五子棋游戲設(shè)計(jì)\GoBang.aps
?????文件????????2076??2013-05-23?10:09??基于C++的五子棋游戲設(shè)計(jì)\GoBang.clw
?????文件????????2063??2008-11-06?18:00??基于C++的五子棋游戲設(shè)計(jì)\GoBang.cpp
?????文件????????5086??2012-05-22?19:56??基于C++的五子棋游戲設(shè)計(jì)\GoBang.dsp
?????文件?????????537??2008-11-06?18:00??基于C++的五子棋游戲設(shè)計(jì)\GoBang.dsw
?????文件????????1324??2008-11-06?18:00??基于C++的五子棋游戲設(shè)計(jì)\GoBang.h
?????文件???????82944??2013-05-25?08:45??基于C++的五子棋游戲設(shè)計(jì)\GoBang.ncb
?????文件??????130048??2013-05-25?08:45??基于C++的五子棋游戲設(shè)計(jì)\GoBang.opt
?????文件????????1023??2013-05-25?08:45??基于C++的五子棋游戲設(shè)計(jì)\GoBang.plg
?????文件????????6652??2013-05-16?12:59??基于C++的五子棋游戲設(shè)計(jì)\GoBang.rc
?????文件?????????882??2013-05-16?12:43??基于C++的五子棋游戲設(shè)計(jì)\GoBang.sln
?????文件???????10240??2013-05-25?08:44??基于C++的五子棋游戲設(shè)計(jì)\GoBang.suo
?????文件????????9232??2013-05-16?12:40??基于C++的五子棋游戲設(shè)計(jì)\GoBang.vcproj
?????文件????????1427??2013-05-16?12:46??基于C++的五子棋游戲設(shè)計(jì)\GoBang.vcproj.CX1DWFG65MRWCLE.Administrator.user
?????文件???????12185??2012-05-26?23:00??基于C++的五子棋游戲設(shè)計(jì)\GoBangDlg.cpp
?????文件????????2045??2012-05-26?22:12??基于C++的五子棋游戲設(shè)計(jì)\GoBangDlg.h
?????文件????????3579??2008-11-06?18:00??基于C++的五子棋游戲設(shè)計(jì)\ReadMe.txt
?????目錄???????????0??2013-05-23?12:50??基于C++的五子棋游戲設(shè)計(jì)\Release\
?????文件???????19124??2013-05-23?12:50??基于C++的五子棋游戲設(shè)計(jì)\Release\Algorithm.obj
?????文件???????????0??2013-05-23?12:50??基于C++的五子棋游戲設(shè)計(jì)\Release\Algorithm.sbr
?????文件???????15656??2013-05-25?08:45??基于C++的五子棋游戲設(shè)計(jì)\Release\Chess.obj
?????文件???????????0??2013-05-25?08:45??基于C++的五子棋游戲設(shè)計(jì)\Release\Chess.sbr
?????文件????????7464??2012-05-15?09:49??基于C++的五子棋游戲設(shè)計(jì)\Release\Computer.obj
?????文件???????????0??2012-05-15?09:49??基于C++的五子棋游戲設(shè)計(jì)\Release\Computer.sbr
?????文件?????3695616??2013-05-25?08:45??基于C++的五子棋游戲設(shè)計(jì)\Release\GoBang.bsc
?????文件??????905216??2013-05-25?08:45??基于C++的五子棋游戲設(shè)計(jì)\Release\GoBang.exe
............此處省略36個(gè)文件信息
評(píng)論
共有 條評(píng)論