极趣五子棋软件及其源代码.(老玩童@_@)

类别:VC语言 点击:0 评论:0 推荐:

极趣五子棋软件及其源代码.

片断:

void CFiveXPDlg::TwoInSix(int m, int n, int p)
{
 file://there are 2 chesses in a contigous 6 dots, and 2 blank every side, 2 blank inside
 int m_count,a,b;
 int m_six;     file://must be 6 times

 for (i=0;i<=14;i++)
 {
  for (j=0;j<=14;j++)
  {
   m_count=0;
   for (a=i,b=j,m_six=0; (b<=14) && (b>=0) && (a<=14) && (a>=0) && ( (b!=j+6*n)||(a!=i+6*m) ); a=a+m,b=b+n,m_six++)
    m_count=m_count + m_array[a][b];

   if ( (m_count==p) && (m_six==6) ) file://if m_five!=6 , then maybe no blank beyond the 3 chesses...
   {         file://p==2 or p==20 
    if ( (m_array[i][j]==0) && (m_array[i+5*m][j+5*n]==0) )
    {
/*     for (a=i+m,b=j+n; (b!=j+5*n)||(a!=i+5*m) ; a=a+m,b=b+n)
      if (  m_array[a][b]==0 )
      {
       if (p==2)
        m_2Iin6.Add( (m+1)*100000 + (n+1)*10000 + a*100+ b);
       else
        m_2Pin6.Add( (m+1)*100000 + (n+1)*10000 + a*100+ b);
      }*/
      for (a=i+m,b=j+n; (b!=j+5*n)||(a!=i+5*m) ; a=a+m,b=b+n)
      if (  m_array[a][b]!=0 )
      {
       if (m_array[a-m][b-n]==0)
       {
        if (p==2)
         m_2Iin6.Add( (m+1)*100000 + (n+1)*10000 + (a-m)*100+ (b-n) );
        else
         m_2Pin6.Add( (m+1)*100000 + (n+1)*10000 + (a-m)*100+ (b-n) );
       }
       if (m_array[a+m][b+n]==0);
       {
        if (p==2)
         m_2Iin6.Add( (m+1)*100000 + (n+1)*10000 + (a+m)*100+ (b+n) );
        else
         m_2Pin6.Add( (m+1)*100000 + (n+1)*10000 + (a+m)*100+ (b+n) );
       }
      }
    }//need change
   }
  }
 }
}

连接:

都必须下载的

本文地址:http://com.8s8s.com/it/it2540.htm