simplepredictor.h

来自「C人工智能游戏开发的一些实例源代码 C Game development in 」· C头文件 代码 · 共 50 行

H
50
字号
//----------------------------------------------------------------------------------------------
// Sequential Prediction Demo: The positioning pattern
// 
// Author:  Fri Mommersteeg
// Date:    10-09-2001
// File:    SimplePredictor.h
//----------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------
//	A simple O(N^2) string-matching predictor (where N is the size of the window)
//----------------------------------------------------------------------------------------------

#ifndef __SIMPLEPREDICTOR_H
#define __SIMPLEPREDICTOR_H

//----------------------------------------------------------------------------------------------
// Include files
//----------------------------------------------------------------------------------------------

#include "predictor.h"
#include "slidingwindow.h"

//----------------------------------------------------------------------------------------------
// CSimplePredictor: predicts the next element in a sequence using string-matching prediction
//----------------------------------------------------------------------------------------------

class CSimplePredictor : public CPredictor {
public:
	CSimplePredictor() { MinPerformance = 1; }

	// implementation of interface CPredictor
	virtual void			Update(int NextElement)	 { window.Add(NextElement); }
	virtual bool			GetPrediction(int &Prediction);
	virtual void			Reset() { window.SetSize(WindowSize); }

	// configuration methods
	void					Setup(int nWindowSize, int nMinPerformance);

protected:

	CSlidingWindow <int>	window;
	int						WindowSize;
	int						MinPerformance;

};

//----------------------------------------------------------------------------------------------
#endif //__SIMPLEPREDICTOR_H

⌨️ 快捷键说明

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