level 1
要来块巧克力吗
楼主
在OnLButtonUp()中实现ai,电脑走棋
void CWuziqidlgDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//flag 1:black 2:white
//color 1:white 2:black
int i,temp1,temp2,max1,max2;
max1=0;
max2=0;
temp1=0;
temp2=0;
for(i=0;i!=qy.size();i++)
{
if(qy[i].isEmpty())
{
qy[i].flag=2;
if(getScore(1)>max1)
{
temp1=getScore(1);
max1=temp1;
temp1=i;
}
qy[i].flag=1;
if(getScore(2)>max2)
{
temp2=getScore(2);
max2=temp2;
temp2=i;
}
qy[i].flag=0;
}
}
if(ison==1&&!over)
{
if(max1>=max2)
qy[temp1].flag=2;
else
qy[temp2].flag=2;
}
ison=0;
if(!isWin())
Invalidate();
CDialog::OnLButtonUp(nFlags, point);
}
2018年09月13日 02点09分
1
void CWuziqidlgDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//flag 1:black 2:white
//color 1:white 2:black
int i,temp1,temp2,max1,max2;
max1=0;
max2=0;
temp1=0;
temp2=0;
for(i=0;i!=qy.size();i++)
{
if(qy[i].isEmpty())
{
qy[i].flag=2;
if(getScore(1)>max1)
{
temp1=getScore(1);
max1=temp1;
temp1=i;
}
qy[i].flag=1;
if(getScore(2)>max2)
{
temp2=getScore(2);
max2=temp2;
temp2=i;
}
qy[i].flag=0;
}
}
if(ison==1&&!over)
{
if(max1>=max2)
qy[temp1].flag=2;
else
qy[temp2].flag=2;
}
ison=0;
if(!isWin())
Invalidate();
CDialog::OnLButtonUp(nFlags, point);
}