sure i can do that np.
it is a pointer that im passing btw because i thought through that same problem myself.
just a little back story. I'm creating the the most basic framework for illustrating the basic principal behind evolutionary/learning algorithms. It will make hypotheses, test them, apply a fitness, cull the low fitness classes and replace them with new random hypotheses. no breeding and mutation yet, just random guesses, fitness and culling, ill work into the harder stuff later.
strObj.pData is the stream of data that it will be trying to predict. strObj.pData[99] is the most recent, and 98, 97, 96 ect show the past. stream.update() will move the data forward one iteration.
ok so here is main.cpp
1 2 3 4 5 6 7 8 9 10 11
|
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include "stream.h"
#include "hypothesis.h"
int _tmain(int argc, _TCHAR* argv[])
{
stream strObj;
hypothesis hypObj(strObj.pData[0]);
}
|
stream.h
1 2 3 4 5 6 7 8 9 10 11 12
|
#pragma once
class stream
{
public:
stream();
void update();
bool* pData[100];
~stream();
private:
int counter;
bool data[100][10];
};
|
stream.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include "stream.h"
stream::stream()
{
counter = 0;
for (int i1 = 0; i1 < 100; ++i1) {
for (int i2 = 0; i2 < 10; ++i2) {
if (i1 % 10 == i2) {
data[i1][i2] = 1;
}
else {
data[i1][i2] = 0;
}
}
}
update();
}
void stream::update()
{
++counter;
for (int i = 0; i < 100; ++i) {
pData[i] = data[(i + counter) % 100];
}
}
stream::~stream(){}
|
*just noticed i need to reset this counter before it goes out of int bounds*
hypothesis .h
1 2 3 4 5 6 7 8 9
|
#pragma once
class hypothesis
{
public:
hypothesis(bool*);
bool* element[2];
~hypothesis();
};
|
and finally hypothesis.cpp
1 2 3 4 5 6 7 8 9 10
|
#include "hypothesis.h"
#include <stdlib.h>
hypothesis::hypothesis(bool* incoming)
{
element[0] = &incoming[rand() % 10];
element[1] = &incoming[rand() % 10];
}
hypothesis::~hypothesis() {}
|
anyway you can imagine why i need a lot of hypothesis' and why they need access to the stream of data inorder to make their guesses.
thanks again!