AI learning program, kind of.

so let me explain how this works. This is less of a Machine learning program, and more of an evolution simulator. each neuron goes through a test, in what I have right now, they are just multiplied by a number, and Neuron5 will always be the largest. whichever neuron has the largest value will have its level(value) used as the base level for the next generation, and the cycle continues.


I need help with the pointer "*NeuronCarier" I cant actually set it to be a pointer where I input into my "NeuralPorcessor" function under "NeuronMain".


also in the for loop I have, which allows multiple generations to be made, I need a way to use that pointer to substitute the largest value of a generation back into the for loop as the starting lvl of the next generation.

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

#include "pch.h"
#include "AILogic.h"

#include <vector>
#include <iostream>

//////////////////////////////////////////CLASSDEFINITIONS//////////////////////
void NeuralNet::NeuronMain()
{

	int n = 0;
	std::cout << "how many generations do you want to run for: ";
	std::cin >> n;

    int l = 0;

	for (int i = 0; i < n; ++i)
	{
		NeuronPath(Neuron1, 1);
		NeuronPath(Neuron2, 2);
		NeuronPath(Neuron3, 3);
		NeuronPath(Neuron4, 4);
		NeuronPath(Neuron5, 5);

		NeuralProcessor(
			Neuron1,
			Neuron2,
			Neuron3,
			Neuron4,
			Neuron5,
			NeuralCarier);
		
		std::cout << "Play next generation ";
		std::cin >> l;
	}
}
//////////////////////////////////////////CLASS ////////////////////////////////
int main()
{
   
	NeuralNet UseDatSquishyBrain;
	UseDatSquishyBrain.NeuronMain();

}
//////////////////////////////////////////FUNCTIONS////////////////////////////////////////////////
void NeuralNet::NeuralProcessor(double Neuron1, double Neuron2, double Neuron3, double Neuron4, double Neuron5, double *NeuronCarier)
{
	if (Neuron1 > Neuron2 && Neuron3 && Neuron4 && Neuron5)
	{
		*NeuronCarier = Neuron1;
	}
	if (Neuron2 > Neuron1 && Neuron3 && Neuron4 && Neuron5)
	{
		*NeuronCarier = Neuron2;
	}
	if (Neuron3 > Neuron2 && Neuron1 && Neuron4 && Neuron5)
	{
		*NeuronCarier = Neuron3;
	}
	if (Neuron4 > Neuron2 && Neuron3 && Neuron1 && Neuron5)
	{
		*NeuronCarier = Neuron4;
	}
	if (Neuron5 > Neuron2 && Neuron3 && Neuron4 && Neuron1)
	{
		*NeuronCarier = Neuron5;
	}
}



this is the header file:

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
31
32
33
34
35
36
37
38
39
40
#pragma once

//Global_obj_ptr_var holds global info shared between all classes
class Global_obj_ptr_var 
{
public:
//Neurons represent individuals. Their values can me thought of as levels. they all start at level 1
	double
		Neuron1 = 1,
		Neuron2 = 1,
		Neuron3 = 1,
		Neuron4 = 1,
		Neuron5 = 1;

	double *NeuralCarier;
	
};


class NeuralNet : public Global_obj_ptr_var
{
public:
	void NeuronMain();

	void NeuronPath(double Neuronx, double Multiple)
    	{
		Neuronx * Multiple;
    	}

	void NeuralProcessor(
		double Neuron1,
		double Neuron2,
		double Neuron3,
		double Neuron4,
		double Neuron5,
		double *NeuronCarier);
};



the code is a little messy, but I will clean it up after I get it working properly.
Last edited on
I need help with the pointer "*NeuronCarier" I cant actually set it to be a pointer where I input into my "NeuralPorcessor" function under "NeuronMain".

explain this again, with more words.
I see line 32 above where it is indeed a pointer and is being input into the function. Is there an error message there? Or something you need done differently?

There is probably something I am not understanding about what you are trying to do, but it looks to me like these
*NeuronCarier = Neuron5;
should possibly be
NeuronCarier = &Neuron5; //maybe? you are not using its pointer-ness, you are always dereferencing it so it may as well not be a pointer?

And, more importantly, if you do mean to do it the way you did, where are you getting memory for the pointer?
Last edited on
there is no error, I just cant put a * behind it, but I guess I dont need to? and I am not to good with pointers and I always forget to put the & behind the variables. I may just remove the pointer all together, as I have my classes inheriting the same info anyway I dont need a pointer. I just need something to take the largest value and input it back into the for statement as the base level for the next generation.
Last edited on
I guess maybe instead of setting each Neuron equal to 1 as base, I could set them all equal to Neuralcarier.
Last edited on
don't guess. Just help me help you ...
where does it get memory or refer to a variable for the pointer?

it does not matter anymore. I changed how the program works.

But if your still interested, the pointer was meant to get info from whichever Neuron was the largest, then plug that back into the other neurons so they all start at whatever number the largest Neuron was at in the last generation.
Topic archived. No new replies allowed.