⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datatype.cpp

📁 这里有一个用vc写的人工智能八数码源代码
💻 CPP
字号:
// DataType.cpp: implementation of the CPathNode class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Chess.h"
#include "DataType.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////////////////////
// CResult Class
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////


void CPathNode::DrawNode(CDC *pDC)
{
	int i;
	for(i=0;i<=N;i++)
	{
		pDC->MoveTo(P0.x,P0.y+i*width);
		pDC->LineTo(P0.x+N*width,P0.y+i*width);
		pDC->MoveTo(P0.x+i*width,P0.y);
		pDC->LineTo(P0.x+i*width,P0.y+N*width);
	}
	for(i=0;i<N*N;i++)
	{	
		if(state[i]=='0') continue;
		int row=i/N;
		int col=i%N;
		char buf[2];
		sprintf(buf,"%c",state[i]);
		pDC->TextOut(P0.x+col*width+3,P0.y+row*width+2,buf);
	}
}

CPathNode::CPathNode(BYTE n,int d, const CPoint &p,int w)
{
	state[16]='\0';
	N=n;
	depth=0;
	next=NULL;
	parent=NULL;
	width=w;
	P0.x=p.x;
	P0.y=p.y;
	P1.x=P0.x+N*width/2;
	P1.y=P0.y+N*width;

}

CPathNode::CPathNode(BYTE n,const CPoint &p,int w)
{
	state[16]='\0';
	N=n;
	depth=0;
	next=NULL;
	parent=NULL;
	width=w;
	P0.x=p.x;
	P0.y=p.y;
	P1.x=P0.x+N*width/2;
	P1.y=P0.y+N*width;
}

CPathNode::CPathNode()
{
	state[16]='\0';
	depth=0;
	next=NULL;
	parent=NULL;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -