randompredictor.cpp

来自「游戏编程AI源码」· C++ 代码 · 共 36 行

CPP
36
字号
//----------------------------------------------------------------------------------------------
// Sequential Prediction Demo: The positioning pattern
// 
// Author:  Fri Mommersteeg
// Date:    10-09-2001
// File:    RandomPredictor.cpp
//----------------------------------------------------------------------------------------------

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

#include "stdafx.h"
#include "randompredictor.h"

//----------------------------------------------------------------------------------------------
// Setup(): sets up the random predictor (seeds the random number generator)
//----------------------------------------------------------------------------------------------

void CRandomPredictor::Setup(int nAlphabetSize, unsigned int nSeed) {
	m_nAlphabetSize = nAlphabetSize;
	srand(nSeed);
}

//----------------------------------------------------------------------------------------------
// GetPrediction(): returns a random prediction
//----------------------------------------------------------------------------------------------

bool CRandomPredictor::GetPrediction(int &Prediction) {

	Prediction = rand() % m_nAlphabetSize;

	// always assume that the prediction is good
	return true;
}

⌨️ 快捷键说明

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