// File: /workspace/github_cpp_makefile_star2_O1/samuel500[P]NEAT/population.cpp
// Function: Population::Population(int, int, int)
Population::Population(int popsize, int insize, int outsize): pop_size(popsize), in_size(insize), out_size(outsize){

	generation = 0;

	max_fitness = 0;

	innov_num = new int;
	*innov_num = in_size+out_size;


	cout << "pop size " << pop_size << endl;

	cout << "innov_num " << *innov_num << endl;

	Individual *new_individual;

	Individual *cp_ind;

	bool activated;

	for(int i=0; i<pop_size; ++i){

		activated = false;

		new_individual = new Individual(&in_size, &out_size, &generation, innov_num); //, &all_nodes, &all_connections);
		// cout << "p1" << endl;

		new_individual->mutate_add_connection(&all_nodes, &all_connections);
		new_individual->mutate_add_node(&all_nodes, &all_connections);


		vector<Connection*>::iterator conPtr;
		vector<Node*>::iterator nodePtr;
		// cout << "p2" << endl;

		for(conPtr=new_individual->connections.begin(); conPtr!=new_individual->connections.end(); ++conPtr){
			all_connections.push_back((*conPtr));
		}
		// cout << "p3" << endl;

		for(nodePtr=new_individual->nodes.begin(); nodePtr!=new_individual->nodes.end(); ++nodePtr){
			all_nodes.push_back((*nodePtr));
		}


		// testing

		vector<double> inp = {1., 0.5, 0.1}; 

		activated = new_individual->activate(inp);
		// cout << "p4" << endl;

		if(!activated) cout<<"error, individual failed to activate"<<endl;

		vector<double> out = new_individual->get_outputs();
		// cout<<  "or"<<out[0]<<endl;

		new_individual->reset_activations();


		// cout << "p4" << endl;


		individuals.push_back(new_individual);

	}


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %ecx, %r12d
movl %edx, %r13d
movq %rdi, %rbx
leaq 0x18(%rdi), %r14
leaq 0x30(%rdi), %rax
movq %rax, -0x40(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rdi)
xorl %eax, %eax
movq %rax, 0x60(%rdi)
movups %xmm0, (%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x30(%rdi)
movq %rax, 0x40(%rdi)
movl %esi, 0x68(%rdi)
movl %edx, 0x6c(%rdi)
movl %ecx, 0x70(%rdi)
movl $0x0, 0x74(%rdi)
movq %rax, 0x80(%rdi)
movl $0x4, %edi
callq 0x1100
movq %rax, 0x78(%rbx)
addl %r13d, %r12d
movl %r12d, (%rax)
movq 0x86e9(%rip), %rdi      # 0x9fd8
leaq 0x5746(%rip), %rsi      # 0x703c
movl $0x9, %edx
callq 0x1120
movl 0x68(%rbx), %esi
movq 0x86ce(%rip), %rdi      # 0x9fd8
callq 0x1190
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
movq 0x8698(%rip), %rdi      # 0x9fd8
leaq 0x56dc(%rip), %rsi      # 0x7023
movl $0xa, %edx
callq 0x1120
movq 0x78(%rbx), %rax
movl (%rax), %esi
movq 0x867a(%rip), %rdi      # 0x9fd8
callq 0x1190
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
cmpl $0x0, 0x68(%rbx)
jle 0x1bab
leaq 0x6c(%rbx), %rax
movq %rax, -0x78(%rbp)
leaq 0x70(%rbx), %rax
movq %rax, -0x70(%rbp)
leaq 0x74(%rbx), %rax
movq %rax, -0x68(%rbp)
xorl %r12d, %r12d
movl $0x98, %edi
callq 0x1100
movq %rax, %r13
movq 0x78(%rbx), %r8
movq %rax, %rdi
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq -0x68(%rbp), %rcx
callq 0x55ec
movq %r13, -0x30(%rbp)
movq %r13, %rdi
movq %r14, %rsi
movq -0x40(%rbp), %rdx
callq 0x614a
movq -0x30(%rbp), %rdi
movq %r14, %rsi
movq -0x40(%rbp), %rdx
callq 0x5e68
movq -0x30(%rbp), %rax
movq 0x60(%rax), %r13
cmpq 0x68(%rax), %r13
je 0x1a36
movq 0x38(%rbx), %rsi
cmpq 0x40(%rbx), %rsi
je 0x1a20
movq (%r13), %rax
movq %rax, (%rsi)
addq $0x8, 0x38(%rbx)
jmp 0x1a2c
movq -0x40(%rbp), %rdi
movq %r13, %rdx
callq 0x2bd8
addq $0x8, %r13
movq -0x30(%rbp), %rax
jmp 0x1a02
movq 0x18(%rax), %r13
movq -0x30(%rbp), %rax
cmpq 0x20(%rax), %r13
je 0x1a6d
movq 0x20(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
je 0x1a5c
movq (%r13), %rax
movq %rax, (%rsi)
addq $0x8, 0x20(%rbx)
jmp 0x1a67
movq %r14, %rdi
movq %r13, %rdx
callq 0x2d18
addq $0x8, %r13
jmp 0x1a3a
movq %r14, %r15
movups 0x56d9(%rip), %xmm0     # 0x7150
movaps %xmm0, -0x60(%rbp)
movabsq $0x3fb999999999999a, %rax # imm = 0x3FB999999999999A
movq %rax, -0x50(%rbp)
movl $0x3, %edx
leaq -0xa8(%rbp), %r14
movq %r14, %rdi
leaq -0x60(%rbp), %rsi
leaq -0x31(%rbp), %rcx
callq 0x297e
movq -0x30(%rbp), %r13
leaq -0x90(%rbp), %rdi
movq %r14, %rsi
movq %r15, %r14
callq 0x29c4
movq %r13, %rdi
leaq -0x90(%rbp), %rsi
callq 0x5b76
movl %eax, %r13d
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x1ae5
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x1110
testb %r13b, %r13b
jne 0x1b34
movl $0x24, %edx
movq 0x84e2(%rip), %rdi      # 0x9fd8
leaq 0x55b3(%rip), %rsi      # 0x70b0
callq 0x1120
movq 0x84cf(%rip), %rcx      # 0x9fd8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq 0x84b1(%rip), %rdi      # 0x9fd8
callq 0x1030
movq %rax, %rdi
callq 0x10a0
movq -0x30(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x5cb8
movq -0x30(%rbp), %rdi
callq 0x5d42
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x1b62
movq -0x30(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x1b6e
movq %rbx, %rdi
leaq -0x30(%rbp), %rdx
callq 0x2f02
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x1b83
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x1110
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x1b9e
movq -0x98(%rbp), %rsi
subq %rdi, %rsi
callq 0x1110
incl %r12d
cmpl 0x68(%rbx), %r12d
jl 0x19b2
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1c2e
movq %rax, %r12
jmp 0x1c25
movq %rax, %r12
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x1c0a
movq -0x80(%rbp), %rsi
jmp 0x1bfd
jmp 0x1c07
movq %rax, %r12
movl $0x98, %esi
movq %r13, %rdi
callq 0x1110
jmp 0x1c31
movq %rax, %r12
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x1c0a
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x1110
jmp 0x1c0a
movq %rax, %r12
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x1c25
movq -0x98(%rbp), %rsi
subq %rdi, %rsi
callq 0x1110
movq %r15, %r14
jmp 0x1c31
jmp 0x1c2e
jmp 0x1c2e
movq %rax, %r12
leaq 0x50(%rbx), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1c49
movq 0x60(%rbx), %rsi
subq %rdi, %rsi
callq 0x1110
movq -0x40(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1c61
movq 0x40(%rbx), %rsi
subq %rdi, %rsi
callq 0x1110
movq (%r14), %rdi
testq %rdi, %rdi
je 0x1c75
movq 0x28(%rbx), %rsi
subq %rdi, %rsi
callq 0x1110
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x1c89
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x1110
movq %r12, %rdi
callq 0x11a0
nop