// File: /workspace/github_cpp_makefile_star2_O3/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 0x8749(%rip), %rdi      # 0x9fd8
leaq 0x57a6(%rip), %rsi      # 0x703c
movl $0x9, %edx
callq 0x1120
movl 0x68(%rbx), %esi
movq 0x872e(%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 0x86f8(%rip), %rdi      # 0x9fd8
leaq 0x573c(%rip), %rsi      # 0x7023
movl $0xa, %edx
callq 0x1120
movq 0x78(%rbx), %rax
movl (%rax), %esi
movq 0x86da(%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 0x1b4b
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 0x54f8
movq %r13, -0x30(%rbp)
movq %r13, %rdi
movq %r14, %rsi
movq -0x40(%rbp), %rdx
callq 0x6022
movq -0x30(%rbp), %rdi
movq %r14, %rsi
movq -0x40(%rbp), %rdx
callq 0x5d5e
movq -0x30(%rbp), %rax
movq 0x60(%rax), %r13
cmpq 0x68(%rax), %r13
je 0x19d6
movq 0x38(%rbx), %rsi
cmpq 0x40(%rbx), %rsi
je 0x19c0
movq (%r13), %rax
movq %rax, (%rsi)
addq $0x8, 0x38(%rbx)
jmp 0x19cc
movq -0x40(%rbp), %rdi
movq %r13, %rdx
callq 0x2bbe
addq $0x8, %r13
movq -0x30(%rbp), %rax
jmp 0x19a2
movq 0x18(%rax), %r13
cmpq 0x20(%rax), %r13
je 0x1a0d
movq 0x20(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
je 0x19f8
movq (%r13), %rax
movq %rax, (%rsi)
addq $0x8, 0x20(%rbx)
jmp 0x1a03
movq %r14, %rdi
movq %r13, %rdx
callq 0x2cfe
addq $0x8, %r13
movq -0x30(%rbp), %rax
jmp 0x19da
movq %r14, %r15
movups 0x5739(%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 0x2950
movq -0x30(%rbp), %r13
leaq -0x90(%rbp), %rdi
movq %r14, %rsi
movq %r15, %r14
callq 0x2996
movq %r13, %rdi
leaq -0x90(%rbp), %rsi
callq 0x5a7e
movl %eax, %r13d
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x1a85
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x1110
testb %r13b, %r13b
jne 0x1ad4
movl $0x24, %edx
movq 0x8542(%rip), %rdi      # 0x9fd8
leaq 0x5613(%rip), %rsi      # 0x70b0
callq 0x1120
movq 0x852f(%rip), %rcx      # 0x9fd8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq 0x8511(%rip), %rdi      # 0x9fd8
callq 0x1030
movq %rax, %rdi
callq 0x10a0
movq -0x30(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x5ba8
movq -0x30(%rbp), %rdi
callq 0x5c38
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x1b02
movq -0x30(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x1b0e
movq %rbx, %rdi
leaq -0x30(%rbp), %rdx
callq 0x2eda
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x1b23
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x1110
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x1b3e
movq -0x98(%rbp), %rsi
subq %rdi, %rsi
callq 0x1110
incl %r12d
cmpl 0x68(%rbx), %r12d
jl 0x1952
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1bce
movq %rax, %r12
jmp 0x1bc5
movq %rax, %r12
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x1baa
movq -0x80(%rbp), %rsi
jmp 0x1b9d
jmp 0x1ba7
movq %rax, %r12
movl $0x98, %esi
movq %r13, %rdi
callq 0x1110
jmp 0x1bd1
movq %rax, %r12
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x1baa
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x1110
jmp 0x1baa
movq %rax, %r12
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x1bc5
movq -0x98(%rbp), %rsi
subq %rdi, %rsi
callq 0x1110
movq %r15, %r14
jmp 0x1bd1
jmp 0x1bce
jmp 0x1bce
movq %rax, %r12
leaq 0x50(%rbx), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1be9
movq 0x60(%rbx), %rsi
subq %rdi, %rsi
callq 0x1110
movq -0x40(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1c01
movq 0x40(%rbx), %rsi
subq %rdi, %rsi
callq 0x1110
movq (%r14), %rdi
testq %rdi, %rdi
je 0x1c15
movq 0x28(%rbx), %rsi
subq %rdi, %rsi
callq 0x1110
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x1c29
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x1110
movq %r12, %rdi
callq 0x11a0
nop