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

📄 move.cpp

📁 警察小偷爸爸妈妈儿子女儿过河
💻 CPP
字号:
// Move.cpp: implementation of the Move class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "River.h"
#include "Move.h"

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

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

Move::Move()
{

}

Move::~Move()
{

}

BOOL Move::Test(CArray<InWhere, InWhere>& p_Ain)
{
	//测试某2点是否能够通过
	InWhere a = p_Ain.GetAt(m_nNow);
	InWhere b = a;

	InWhere c = p_Ain.GetAt(m_nNext);
	InWhere d = c;
	
	int num(0);
	//如果是开始在船上的话
	if(a.boat == 2)
	{
		++num;
	}
	if(c.boat == 2)
	{
		++num;
	}
	//头和尾只能有且有一个在船上
	if(num != 1)
		return FALSE;

	//只要在船上的状态等于岸边的状态就表示此路是行的通的


	//从船上到岸上的
	if(a.boat == 2)
	{
		//---*--->*
		if(a.daughter1 == 2)
			a.daughter1 = 3;
		if(a.daughter2 == 2)
			a.daughter2 = 3;
		if(a.father == 2)
			a.father = 3;
		if(a.mother == 2)
			a.mother = 3;
		if(a.plice == 2)
			a.plice = 3;
		if(a.shife == 2)
			a.shife = 3;
		if(a.son1 == 2)
			a.son1 = 3;
		if(a.son2 == 2)
			a.son2 = 3;
		a.boat =3;
		if(a == p_Ain.GetAt(m_nNext))
		return TRUE;
		//*<----*-----
		if(b.daughter1 == 2)
			b.daughter1 = 1;
		if(b.daughter2 == 2)
			b.daughter2 = 1;
		if(b.father == 2)
			b.father = 1;
		if(b.mother == 2)
			b.mother = 1;
		if(b.plice == 2)
			b.plice = 1;
		if(b.shife == 2)
			b.shife = 1;
		if(b.son1 == 2)
			b.son1 = 1;
		if(b.son2 == 2)
			b.son2 = 1;
		b.boat =1;
		if(b == p_Ain.GetAt(m_nNext))
		return TRUE;
		
	}
	//从岸到船上
	if(c.boat == 2)
	{
		//----*<---*
		if(c.daughter1 == 2)
			c.daughter1 = 3;
		if(c.daughter2 == 2)
			c.daughter2 = 3;
		if(c.father == 2)
			c.father = 3;
		if(c.mother == 2)
			c.mother = 3;
		if(c.plice == 2)
			c.plice = 3;
		if(c.shife == 2)
			c.shife = 3;
		if(c.son1 == 2)
			c.son1 = 3;
		if(c.son2 == 2)
			c.son2 = 3;
		c.boat =3;
		if(c == p_Ain.GetAt(m_nNow))
		return TRUE;

		//*---->*----
		if(d.daughter1 == 2)
			d.daughter1 = 1;
		if(d.daughter2 == 2)
			d.daughter2 = 1;
		if(d.father == 2)
			d.father = 1;
		if(d.mother == 2)
			d.mother = 1;
		if(d.plice == 2)
			d.plice = 1;
		if(d.shife == 2)
			d.shife = 1;
		if(d.son1 == 2)
			d.son1 = 1;
		if(d.son2 == 2)
			d.son2 = 1;
		d.boat =1;
		if(d == p_Ain.GetAt(m_nNow))
		return TRUE;

	}
	return FALSE;
	
}

⌨️ 快捷键说明

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