afirmación válida
#include "stdafx.h"
#include "3_1.h"
#include "3_1Doc.h"
# incluir "3_1View.h"
#include "MainFrm.h"
#ifdef _DEBUG
#definir nuevo DEBUG_NEW
#undef ESTE_FILE
carácter estático ESTE_FILE[] = __FILE__;
#endif
/////////////////// /////////////////////////////////////////////////// /// /////////
// CMy3_1View
IMPLEMENT_DYNCREATE(CMy3_1View, CView)
BEGIN_MESSAGE_MAP(CMy3_1View, CView) p>
//{{AFX_MSG_MAP(CMy3_1View)
ON_WM_LBUTTONUP()
ON_WM_SETCURSOR()
ON_COMMAND(ID_START, OnStart)
ON_COMMAND(ID_PLAYER, OnPlayer)
ON_COMMAND(ID_CPMPUTER, OnCpmputer)
//}}AFX_MSG_MAP
// Comandos de impresión estándar
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP( )
//////////////////////////////////////// ///// /////////////////////////////////////////// CMy3_1Ver construcción/ destrucción
p>CMy3_1View::CMy3_1View()
{
// TODO: agregar código de construcción aquí
hcursorblack=AfxGetApp( )->LoadCursor( IDC_CURSOR1);
hcursorwhite=AfxGetApp()->LoadCursor(IDC_CURSOR2);
m_bmwhite.LoadBitmap(IDB_WHITE);
m_bmblack. LoadBitmap(IDB_BLACK);
for(int i=0;i<19;i++)
for(int j=0;j<19;j++)
wzq[i ][j]=0;
colorwhite=true;
//El valor predeterminado es humano versus máquina
vscomputer=1;
}
CMy3_1View::~CMy3_1View()
{
}
BOOL CMy3_1View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modifique la clase o los estilos de Ventana aquí modificando
// el CREATESTRUCT cs
return CView: :PreCreateWindow(cs);
}
////////////////////////////// // ///////////////////////////////////////////////// /// p>
// CMy3_1Ver dibujo
void CMy3_1View::OnDraw(CDC* pDC)
{
CMy3_1Doc* pDoc = GetDocument( );
ASSERT_VALID(pDoc);
// TODO: agregue código de dibujo para datos nativos aquí
//Dibuje el fondo
CBrush mybrush1
mybrush1.CreateSolidBrush(RGB(192,192,192));
CRect myrect1(0,0,1200,800);
pDC-> FillRect(myrect1, &mybrush1);
CBrush mybrush;
mybrush.CreateSolidBrush(RGB(0,0,0));
for(int a= 0;a< 3;a++)
for(int b=0;b<3;b++)
{
CRect myrect(97+a* 120,97+ b*120,103+a*120,103+b*120);
pDC->FillRect(myrect,&mybrush);
}
/ /Dibujar una línea de marco negro
CPen mypen;
CPen*myoldPen;
mypen.CreatePen(PS_SOLID,1,RGB(0,0,0) );
myoldPen=pDC->SelectObject(&mypen);
for(int i=0;i<19;i++)
{
pDC ->MoverA(40,4i*20);
pDC->LíneaA(400,4i*20);
pDC->MoverA (4i* 20,40);
pDC->LineTo(4i*20,400);
}
CDC Dc;
if (Dc.CreateCompatibleDC(pDC)==FALSE)
AfxMessageBox("No se puede crear DC");
for(int n=0;n< 19;n++)
para(
int m=0;m<19;m++)
if(wzq[n][m]==1)
{
Dc.SelectObject( m_bmwhite);
pDC->BitBlt(n*232,m*232,160,160,&Dc,0,0,SRCCOPY
}
else if(wzq[n][m]==-1)
{
Dc.SelectObject(m_bmblack);
pDC->BitBlt( n*232,m*232,160,160,&Dc,0,0,SRCCOPY
}
}
//////); /////////////////////////////////////////////////// /// //////////////////////
// CMy3_1Ver impresión
BOOL CMy3_1View::OnPreparePrinting(CPrintInfo * pInfo)
{
// preparación predeterminada
return DoPreparePrinting(pInfo);
}
void CMy3_1View:: OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: agregar inicialización adicional antes de imprimir
}
void CMy3_1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: agregar limpieza después de imprimir
}
///////////////////////////// ///// ////////////////////////////////////////////// /
// CMy3_1View diagnóstico
#ifdef _DEBUG
void CMy3_1View::AssertValid() const
{
CView::AssertValid( );
}
void CMy3_1View::Dump(CDumpContext& dc) const
{
CView ::Dump(dc);
}
CMy3_1Doc* CMy3_1View::GetDocument() // la versión sin depuración está en línea
{
ASSERT(m_pDocument- >IsKindOf(RUNTIME_CLASS(CMy3_1Doc)));
return (CMy3_1Doc*)m_pDocument;
}
#endif // _DEBUG
/////////////////////////////////////////// ////////// ///////////
/////////////////
// CMy3_1View controladores de mensajes
void CMy3_1View::OnLButtonUp(UINT nFlags, CPoint point) p>
{
// TODO: Agregue su código de controlador de mensajes aquí y/o llame al CDC predeterminado
*pDC=GetDC();
CDC Dc;
if(Dc.CreateCompatibleDC(pDC)==FALSE)
AfxMessageBox("No se puede crear DC"); Piezas de ajedrez
//////////////////////Hombre versus máquina
if(vscomputer==1) p>
{
if(point.x>30&&point.x<410&&point.y>30&&point.y<410)
{
int px =( punto.x-30)/20;
int py=(punto.y-30)/20;
if(colorblanco&&wzq[px][py]==0 )
{
Dc.SelectObject(m_bmwhite);
pDC->BitBlt(px*232,py*232,160,160,&Dc,0 ,0 ,SRCCOPY);
wzq[px][py]=1;
over(punto);
colorwhite=false;
//Guardar la posición de ajedrez de las blancas
vspoint=point;
//La computadora juega al ajedrez
computerdown();
}
}
}
//Personas a personas
if(vscomputer==2)
{
if(point.x>30&&point.x<410&&point.y>30&&point.y<410)
{
int px=(point. x-30 )/20;
int py=(punto.y-30)/20;
if(colorblanco&&wzq[px][py]==0)
{
Dc.SelectObject(m_bmwhite);
pDC->BitBlt(px*232,py*232,160,160,&Dc,0,0,SRCCOPY
wzq[px][py]=1;
over(point);
colorwhite=false;
}
else if(wzq[px][py]==0)
{
Dc.SelectObject(
m_bmblack);
pDC->BitBlt(px*232,py*232,160,160,&Dc,0,0,SRCCOPY);
wzq[px][py] =-1;
sobre(punto);
colorwhite=true;
}
}
}
CView::OnLButtonUp(nFlags, punto);
}
BOOL CMy3_1View::OnSetCursor(CWnd* pWnd, UINT nHitTest, mensaje UINT)
{
// TODO: Agregue su código de controlador de mensajes aquí y/o llame al valor predeterminado
if(nHitTest==HTCLIENT)
{
if(colorblanco)
{
CMainFrame*pFrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CStatusBar *pStatus=&pFrm->m_wndStatusBar;
if(pStatus)
{
pStatus->GetStatusBarCtrl().SetIcon(0,AfxGetApp()-> LoadIcon(IDI_WHITE));
pStatus->SetPaneText(0,"Movimientos blancos");
}
SetCursor(hcursorwhite);
}
else
{
CMainFrame*pFrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CStatusBar *pStatus=&pFrm->m_wndStatusBar;
if(pStatus)
{
//Mostrar imagen
pStatus->GetStatusBarCtrl ( ).SetIcon(0,AfxGetApp()->LoadIcon(IDI_BLACK));
//Mostrar texto
pStatus->SetPaneText(0,"Movimientos negros" ); p>
}
SetCursor(hcursorblack);
}
devuelve 1;
}
devolver CView::OnSetCursor(pWnd, nHitTest, mensaje);
}
void CMy3_1View::over(punto CPoint)
{ p>
//Obtiene la posición de la matriz señalada por el mouse
int x=(point.x-30)/20;
int y=(point.y-30) / 20;
//Coordenadas para empezar a juzgar
int xx,yy;
if(x<4)
xx= 0 ;
más
más
p>
xx=x-4;
si(y<4)
yy=0;
más
yy=y-4;
int i,j,a;
//Juicio horizontal
for(i=xx;i<15;i++)
{
a=0;
for(j=i;j
{ p>
a=a+wzq[j][y];
if(a==5)
{
AfxMessageBox("白¡Gana!");OnStart();return;
}
if(a==-5)
{
AfxMessageBox ("¡Las negras ganan!");OnStart();return;
}
}
}
//Vertical Para juzgar
for(i=yy;i<15;i++)
{
a=0;
for(j =i ;j
{
a=a+wzq[x][j]
if(a== 5)
{
AfxMessageBox("¡Las blancas ganan!");OnStart();return;
}
if( a== -5)
{
AfxMessageBox("¡Las negras ganan!");OnStart();return;
}
}
}
//A la esquina inferior derecha
//Determina la posición inicial
if(x { if(xx==0) yy=y-x; } más { if(yy==0) xx=x-y; } //Cuando el parámetro es 1 Salir del bucle int over=0; do { a=0; for( i=0;i<5;i++) { if((xx+i)<19||(yy+i)<19) { a=a+wzq[xx+i][yy+i]; if(a==5) { AfxMessageBox("¡Las blancas ganan!");OnStart();return; } if(a==-5) { AfxMessageBox("¡Las negras ganan!");OnStart();return; } } //Límite llegado else over=1; } xx+=1; yy+=1 p> } while(over==0); //A la esquina inferior izquierda if(y>(18-x)) { si(x>13) { yy=y-(18-x); xx=18; } más p> p> { yy=y-4; xx=x+4; } } p> else { if(y<5) { xx=x+y; p> yy=0; } más { yy=y-4; p> xx=x+4; } } over=0; hacer { a=0; for(i=0;i<5;i++) { si (( xx-i)>=0||(yy+i)<19) { a=a+wzq[xx-i][yy+i]; p> if(a==5) { AfxMessageBox("¡Las blancas ganan!");OnStart();return; } if(a==-5) { AfxMessageBox("¡Las negras ganan!");OnStart();return; } } //En la frontera else over=1; } xx-=1; yy+=1; }mientras(sobre==0); }< / p> void CMy3_1View::OnStart() { // TODO: Agregue el código del controlador de comandos aquí for(int i= 0 ;i<19;i++) for(int j=0;j<19;j++) wzq[i][j]=0; colorwhite=true; Invalidate(); } //Movida de las negras void CMy3_1View::putdown(CPoint punto) { CDC *pDC=GetDC(); CDC Dc; if(Dc.CreateCompatibleDC(pDC) ==FALSE) AfxMessageBox("No se puede crear DC"); Dc.SelectObject(m_bmblack); pDC->BitBlt(point. x*232,punto.y*232,160,160,&Dc,0,0,SRCCOPY wzq[punto.x][punto.y]=-1;
CPoint overpoint;
overpoint.x=point.x*230;
overpoint.y= punto.y*230;
> over(overpoint);
colorwhite=true;
}
//Es el turno de la computadora de jugar al ajedrez
void CMy3_1View :: computerdown()
{
//Asigna varias situaciones de la siguiente manera
bpointcan4=(-1,-1);
wpointcan4=(-1,-1);
bpointcan3=(-1,-1);
wpointcan3=(-1,-1);
bpointcan2=(-1,-1);
wpointcan2=(-1,-1);
bpointcan1=(-1,-1);
//Busca la mejor posición
for(int i=0;i<19;i++)
for(int j=0;j<19; j++)
bestputdown(i,j);
//Determina dónde colocarlas
//Se da prioridad a la posición con más piezas de ajedrez
//Cuando hay cantidades iguales de blanco y negro, el negro va primero
if(bpointcan4.x!=-1)
{
putdown(bpointcan4);
return;
}
else if(wpointcan4.x!=-1)
{
putdown(wpointcan4);
retorno;
}
else if(bpointcan3.x!=-1)
{
putdown (bpointcan3);
return;
}
else if(wpointcan3.x!=-1 )
{
putdown(wpointcan3);
return;
}
else if(bpointcan2. x!=-1)
{
putdown(bpointcan2);
retorno;
}
else if(wpointcan2.x!=-1)
{
putdown(wpointcan2);
return;
} p>
más
{
putdown(bpointcan1);
retorno;
}
}
//Comprueba cuatro direcciones, calcula la suma de las cinco piezas en cada dirección y asigna el valor
void CMy3_1View::bestputdown(int i,int j)
{
int num[4 ];
CPoint numbig;
int a,k;
/// //////////////// //////////// num[0] -->
a=0;
if(i<15)
for(k=0;k<5;k++)
a=a+wzq[i+k][j];
num[0]=abs(a);
/////////////////////////// ////
/ num[1] "|"
a=0;
if(j<15)
for(k=0;k<5;k++ )
a=a+wzq[i][j+k];
num[1]=abs(a);
//// ///////////////////////////// num[2] "\"
a=0;
if(i<15&&j<15)
for(k=0;k<5;k++)
a=a+wzq[i+k][j +k ];
num[2]=abs(a);
////////////////////// // ////// num[3] "/"
a=0;
if((i>4)&&(j<15))
for(k=0;k<5;k++)
a=a+wzq[i-k][j+k];
num[3]=abs (a );
//Compara qué dirección tiene más piezas del mismo color
numbig=maxnum(num[0],num[1],num[2], num[3]);
//Encontrar el punto de aterrizaje en el valor y dirección máximos
switch(numbig.y)
{
caso 4:
searchcandown4(i,j,numbig.x);break;
caso 3:
searchcandown3(i,j,numbig .x);romper;
caso 2:
searchcandown2(i,j,numbig.x);romper;
valor predeterminado:
searchcandown1(i, j,numbig.x);
}
}
CPoint CMy3_1View::maxnum(int a, int b, int c , int d) p>
{
//point.x es el valor de dirección
//point.y es el valor máximo
CPunto punto;
if(a>=b)
{
punto.x=0;
punto.y= a;
}
más
{
punto.x=1;
punto.y= b;
}
if(c>punto.y)
{
punto.x=2;
punto.y=c ;
}
if(d>punto.y)
{
punto.x =3;
punto.y=d;
}
punto de retorno;
}
/ /Hay cuatro piezas de ajedrez del mismo color
p>void CMy3_1View::searchcandown4(int i, int j, int n)
{
/ / Punto C;
int k
////////
/////////////////////// num[0] "--"
if(n==0)
for(k=0;k<5;k++)
//Si el primero está vacío
if(wzq[i][j]==0)
{
//Si hay una pieza blanca debajo
if(wzq[i+1][j]==1)
{
//Puedes jugar al ajedrez en la posición inferior, ya hay cuatro ajedrez blancos
wpointcan4.x=i;
wpointcan4.y =j;
break;
}
else
{
//Puedes jugar al ajedrez en en la siguiente posición, ya hay cuatro piezas de ajedrez negras
bpointcan4.x=i;
bpointcan4.y=j;
break;
}
}
// ¡Si encuentras la posición de ajedrez, definitivamente la encontrarás!
else if(wzq[i+k][j]==0)
{
//Si el primero es blanco
if(wzq[j][j]==1)
{
wpointcan4.x=i+k;
wpointcan4.y = j;
break;
}
//De lo contrario, el primero es negro
else
{
bpointcan4.x=i+k;
bpointcan4.y=j;
descanso;
}
}
///////////////////////////// num[1] "|"
si(n==1)
for(k=0;k<5;k++)
{
si(wzq[i ] [j]==0)
if(wzq[i][j+1]==1)
{
wpointcan4.x=i ;
wpointcan4.y=j;
romper;
}
más
{
bpointcan4.x=i;
bpointcan4.y=j;
romper;
}
else if( wzq [i][j+k]==0)
{
if(wzq[i][j]==1)
{< / p>
wpointcan4.x=i;
wpointcan4.y=j+k;
descanso;
}
else
{
bpointcan4.x=i;
bpointcan4.y=j+k;
descanso;
}
}
}
///////////////////////////////// num[2] "\" p>
si(n==2)
for(k=0;k<5;k++)
{
si(wzq[ i] [j]==0)
if(wzq[i+1][j+1]==1)
{
wpointcan4. x= i;
wpointcan4.y=j;
romper;
}
más
{
p>
bpointcan4.x=i;
bpointcan4.y=j;
romper;
} p>
si no (wzq[i+k][j+k]==0)
{
si(wzq[i][j]==1 )
{
wpointcan4.x=i+k;
wpointcan4.y=j+k;
descanso; p>
}
más
{
bpointcan4.x=i+k;
bpointcan4.y=j+ k;
descanso;
}
}
}
//////// /////// //////////////// num[3] "/"
if(n==3)
for(k=0;k <5;k++)
{
if(wzq[i][j]==0)
if( wzq[i-1][j +1]==1)
{
wpointcan4.x=i;
wpointcan4.y=j;
romper
}
más
{
bpointcan4.x=i;
bpointcan4.y=j;
romper;
}
else if(wzq[i-k][j+k]==0) p>
{ p>
if(wzq[i][j]==1)
{
wpointcan4.x=i-k;
wpointcan4.y= j+k;
descanso;
}
más
{
bpointcan4.x=i-k;
bpointcan4.y=j+k;
romper;
}
} p>
} p>
}
//Hay hasta tres del mismo color
void CMy3_1View::searchcandown3(int i, int j , int n)
{
int k=0;
/////////
////////////////////// num[0] "--"
if(n==0)
for (k=0;k<5;k++)
//Encontrar la posición
if(wzq[i+k][j]==0)
{
//El siguiente es blanco
if(wzq[i+k+1][j]==1)
{ p>
//Puedes jugar al ajedrez en la posición inferior, ya hay tres ajedrez blancos
wpointcan3.x=i+k
wpointcan3.y; =j;
}
//El siguiente es negro
else if(wzq[i+k+1][j]==-1 )
{
bpointcan3.x=i+k
bpointcan3.y=j;
}
}
///////////////////////////// num[1] "|"
si(n== 1)
for(k=0;k<5;k++)
si(wzq[i][j+k]==0 )
{
if(wzq[i][j+k-1]==1)
{
wpointcan3. x=i;
wpointcan3.y=j+k;
}
else if(wzq[i][j+k+1]== -1)
{
bpointcan3.x=i;
bpointcan3.y=j+k;
}
}
///////////////////////////////// num[2] " \"
si (n==2)
para(k=0;k<5;k++)
si(wzq[i+k] [j+k]==0)
{
if(wzq[i+k+1][j+k+1]==1)
{
wpointcan3.x=i+k;
wpointcan3.y=j+k;
}
más si (wzq[i+k+1][ j+k+1]==-1)
{
bpointcan3.x=i+k;
bpointcan3.y=j+k;
}
}
////////////////// /////////// // num[3] "/"
if(n==3)
for(k=0;k<5 ;k++)
if (wzq[i-k][j+k]==0)
{
if(wzq[i-k-1][j +k+1]==1) p>
{
wpointcan3.x=i-k;
wpointcan3.y=j
+k;
}
más si(wzq[i-k-1][j+k+1]==-1)
{
bpointcan3.x=i-k;
bpointcan3.y=j+k;
}
}
}
//Hay como máximo dos del mismo color
void CMy3_1View::searchcandown2(int i, int j, int n)
{
int k=0,m=0,a=0,b=0;
////////////////////// ///// /// num[0] "--"
if(n==0)
{
//Determina cuántos posiciones vacías hay
p>for(k=0;k<5;k++)
if(wzq[i+k][j]==0)
m+=1;
//Si solo hay una posición vacía
if(m==1)
for(a=0 ;a<5;a++)
//Encontrar la posición vacía
if(wzq[i+a][j]==0)
{
//Los dos siguientes La suma de los valores de las piezas
b=wzq[i+a+1][j]+wzq[i+a+2 ][j];
//Todos son negros Ajedrez
if(b==-2)
{
// Puedes jugar al ajedrez en la posición inferior, y hay dos ajedrez negros al lado
bpointcan2.x=i+a;
bpointcan2.y=j;
}
//Todas son piezas blancas
if(b==2)
{
wpointcan2.x= i+a;
wpointcan2.y=j;
}
}
//Si hay tres posiciones vacías, significa que los otros dos son del mismo color
if(m==3)
{
for(a=0;a<5;a++)
//Si ambas son piezas negras
if(wzq[i+a ][j]==-1)
{
for(b=0;b<5;b++)
//Si se encuentra una posición vacía
if(wzq[i+b][j]==0 )
{
// Puedes jugar al ajedrez en la posición inferior, y hay dos piezas de ajedrez negras al lado
bpointcan2.x=i+b ;
bpointcan2.y=j; romper;
}
}
else
//Si ambas son piezas blancas
if(wzq[i+a][j]==1)
{
for(b=0;b<5 ;b++)
if(wzq[i+b][j]==0)
{ p>
wpointcan2.x=i+b; p>
wpointcan2.y=j; romper;
}
}
}
}
/// /////////////////////////// num[1] "|"
m=0;
if(n==1)
{
for(k=0;k<5;k++)
if(wzq[i][ j+ k]==0)
m++;
if(m==1)
for(a=0;a<5;a++)
if(wzq[i][j+a]==0)
{
b=wzq[i][j+a+1]+ wzq [i][j+a+2];
if(b==-2)
{
bpointcan2.x=i; p >
bpointcan2.y=j+a;
}
if(b==2)
{
wpointcan2 .x=i;
wpointcan2.y=j+a;
}
}
si(m==3 )
{
for(a=0;a<5;a++)
if(wzq[i][j+a]==-1 )
{
for(b=0;b<5;b++)
if(wzq[i][j+b]==0)
{
bpointcan2.x=i;
bpointcan2.y=j+b; romper;
}
}
más
if(wzq[i][j+a]==1)
{
para ( b=0;b<5;b++)
if(wzq[i][j+b]==0)
{
wpointcan2. x =i;
wpointcan2.y=j+b; romper;
}
}
}
}
///////////////////////////////// num[2] "\"
m=0;
if(n==2)
{
for(k=0;k<5; k++)
if(wzq[i+k][j+k]==0)
m++;
if(m==1)
for(a=0;a<5;a++)
if(wzq[i+a][j+a]==0)
{
b=wzq[i+a+1][j+a+1]+wzq[i+a+2][j+a+2];
si( b== -2)
{
bpointcan2.x=i+a;
bpointcan2.y=j+a;
}
if(b==2)
{
wpointcan2.x=i +a;
wpointcan2.y=j+a;
}
}
si(m==3) p>
{
for(a=0;a<5;a++)
if(wzq[i+a][j+a]==-1)
{
for(b=0;b<5;b++)
if(wzq[i+b][j+b]==0 )
{
bpointcan2.x=i+b;
bpointcan2.y=j+b;
}
}
más
if(wzq[i+a][j+a]==1)
{
for(b=0;b<5;b++)
if(wzq[i+b][j+b]==0)
{ p>
wpointcan2.x=i+b;
wpointcan2.y=j+b; romper;
}
}
}
}
//////////////////////////////// número [3] "/"
m=0;
if(n==3)
{
for(k = 0;k<5;k++)
if(wzq[i-k][j+k]==0)
m++;
if(m = =1)
for(a=0;a<5;a++)
if(wzq[i-a][j+a]==0)
{
b=wzq[i-a-1][j+a+1]+wzq[i-a-2][j+a+2];
si(b = =-2)
{
bpointcan2.x=i-a;
bpointcan2.y=j+a;
}< / p>
if(b==2)
{
wpointcan2.x=i-a;
wpointcan2.y=j+a;
p>}
}
si(m==3)
{
para(a= 0;a <5;a++)
if(wzq[i-a][j+a]==-1)
{
for(b= 0;b <5;b++)
if(wzq[i-b][j+b]==0)
{
bpointcan2.x=i-b ; p>
bpointcan2.y=j+b; romper;
}
}
>
else
if(wzq[i-a][j+a]==1)
{
for(b=0;b< 5;b++)
if(wzq[i-b][j+b]==0)
{
wpointcan2.x=i-b;
wpointcan2.y=j+b; romper;
}
}
}
}
}
//Si la suma de las cinco posiciones es una
void CMy3_1View::searchcandown1(int i, int j, int n)
{
//Calcula el punto donde acaba de caer la pieza de ajedrez blanca
int ii=(vspoint.x-30)/20;
int jj =(vspoint. y-30)/20;
int a;
for(a=0;a<5;a++)
//Si no llega al límite
if(ii+a<19)
{
//A la derecha, si hay una posición vacía p>
if(wzq[ii +a][jj]==0)
{
//Juega con negras en esta posición
bpointcan1 .x=ii+a;
p>bpointcan1.y=jj;
retorno;
}
}
//Llegó a la frontera
else
//A la izquierda, si hay una posición vacía
if(wzq[ii- 1][jj]==0)
{
bpointcan1.x=ii-a;
bpointcan1.y=jj;
return;
}
}
//vscomputer: 2 significa persona a persona, 1 significa persona a máquina
void CMy3_1View::OnPlayer()
{ p>
// TODO: agregue el código del controlador de comandos aquí
vscomputer=2;
OnStart ();
}
void CMy3_1View::OnCpmputer()
{
// TODO: Agregue su código de controlador de comandos aquí
vscomputer=1;
OnStart();
}