91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 188KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-05
  • 語言: 其他
  • 標簽: 井字棋??

資源簡介

利用Minimax算法或α-β剪枝算法實現井字棋游戲。

資源截圖

代碼片段和文件信息

#include
#include

int?chess[3][3];
int?xycount;

int?IsWin()
{
int?i;
for(i=0;i<3;i++)
{
if(chess[i][0]==1?&&?chess[i][1]==1?&&?chess[i][2]==1)?return?1;
if(chess[i][0]==-1?&&?chess[i][1]==-1?&&?chess[i][2]==-1)?return?-1;
}

for(i=0;i<3;i++)
{
if(chess[0][i]==1?&&?chess[1][i]==1?&&?chess[2][i]==1)?return?1;
if(chess[0][i]==-1?&&?chess[1][i]==-1?&&?chess[2][i]==-1)?return?-1;
}

if((chess[0][0]==1&&chess[1][1]==1&&chess[2][2]==1)||(chess[2][0]==1&&chess[1][1]==1&&chess[0][2]==1))?return?1;
????if((chess[0][0]==-1&&chess[1][1]==-1&&chess[2][2]==-1)||(chess[2][0]==-1&&chess[1][1]==-1&&chess[0][2]==-1))?return?-1;

return?0;
}

int?Evaluation()
{
int?ijtemp[3][3];

x=y=0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(chess[i][j]==0)?temp[i][j]=1;
else?temp[i][j]=chess[i][j];
}
}
?
for(i=0;i<3;i++)
{
x+=(temp[i][0]+temp[i][1]+temp[i][2])/3;
}

for(i=0;i<3;i++)
{
x+=(temp[0][i]+temp[1][i]+temp[2][i])/3;
}

x+=(temp[0][0]+temp[1][1]+temp[2][2])/3;
x+=(temp[2][0]+temp[1][1]+temp[0][2])/3;

for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(chess[i][j]==0)?temp[i][j]=-1;
else?temp[i][j]=chess[i][j];
}
}


for(i=0;i<3;i++)
{
y+=(temp[i][0]+temp[i][1]+temp[i][2])/3;
}

for(i=0;i<3;i++)
{
y+=(temp[0][i]+temp[1][i]+temp[2][i])/3;
}

y+=(temp[0][0]+temp[1][1]+temp[2][2])/3;
y+=(temp[2][0]+temp[1][1]+temp[0][2])/3;

return?x+y;
}

int?AlphaBeta(int?&valueint?deepbool?MAX)
{
bool?prune=false;
int?ijflagtemp;????????
?????
????if(deep==3||deep+count==9)
????{
????????return?Evaluation();
????}
????????????????
????if(IsWin()==1)
????{
????????value=10000;
????????return?0;
????}

????if(MAX)??????????????????
????????flag=10000;
????else
????????flag=-10000;
????for(i=0;i<3?&&?!prune;i++)
????{
????????for(j=0;j<3?&&?!prune;j++)
????????{
????????????if(chess[i][j]==0)
????????????{
????????????????if(MAX)
????????????????{
????????????????????chess[i][j]=-1;
????????????????????????
????????????????????if(IsWin()==-1)
????????????????????????temp=-10000;
????????????????????else
????????????????????????temp=AlphaBeta(flagdeep+1!MAX);

????????????????????if(temp????????????????????if(flag<=value)?prune=true;??????????????????????
????????????????}
????????????????else
????????????????{
????????????????????chess[i][j]=1;
????????????????????
????????????????????if(IsWin()==1)
????????????????????????temp=10000;
????????????????????else
????????????????????????temp=AlphaBeta(flagdeep+1!MAX);

????????????????????if(temp>flag)?flag=temp;?????????????????????
????????????????????if(flag>=value)?prune=true;
???????????????????????
????????????????}
????????????????chess[i][j]=0;
????????????}
????????}
????}
????if(MAX)
????{
????????if(flag>value)
????????????value=flag;
????}
????else
????{
??

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????6430??2010-01-10?09:03??Chess.cpp

????I.A....????299311??2010-08-17?22:33??報告?.doc

-----------?---------??----------?-----??----

???????????????305741????????????????????2


評論

共有 條評論