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

📄 state.cpp

📁 人工智能里的A-star算法,用于机器人的路径规划和寻优.
💻 CPP
字号:
// State.cpp: implementation of the CState class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "DStar.h"
#include "State.h"

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


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

CState::CState()
{
	m_dCost = 0.0;
	m_CurPt = CPoint( 0, 0 );
	m_pLastPt = &CPoint( 0, 0 );
	m_dWillCost = 0.0;
	m_dCosted = 0.0;
}

CState::CState( CPoint pt )
{
	m_dCost = 0.0;
	m_CurPt = pt;
	m_pLastPt = &CPoint( 0, 0 );
	m_dWillCost = 0.0;
	m_dCosted = 0.0;
}

CState::CState( CPoint pt,double iCosted, double iWillCost, double Cost, CPoint& ptBack )
{
	m_CurPt = pt;
	m_dCost = Cost;
	m_dCosted = iCosted;
	m_dWillCost = iWillCost;
	m_pLastPt = &ptBack;
}

CState::~CState()
{
	
}

CState::SetCost( int iMode, double willcost )
{
	m_dWillCost = willcost;
//	if ( iMode == 1 )
//		m_dCost = 0.9*m_dWillCost + 0.1*m_dCosted;
//	if ( iMode == 0 )
		m_dCost = 0.5*m_dWillCost + 0.5*m_dCosted;
}

CState::SetForPt( CPoint& pt )
{
	m_pLastPt = &pt;
}

CState::SetCurPt( CPoint pt )
{
	m_CurPt = pt;
}

CState CState::operator = ( const CState& cs )
{
	this->m_dWillCost = cs.m_dWillCost;
	this->m_pLastPt = cs.m_pLastPt;
	this->m_dCosted = cs.m_dCosted;
	this->m_dCost = cs.m_dCost;
	this->m_CurPt = cs.m_CurPt;

	return *this;
}

BOOL CState::operator == ( const CState& cs )
{
	if ( this->m_CurPt  == cs.m_CurPt )
		return TRUE;
	else 
		return FALSE;
}

⌨️ 快捷键说明

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