// File: tewalds[P]morat/hex/agentmcts.h
// Function: Morat::Hex::AgentMCTS::Node::value(float, bool, float) const
float value(float ravefactor, bool knowledge, float fpurgency) const {
			float val = fpurgency;
			float expnum = exp.num();
			float ravenum = rave.num();

			if(ravefactor <= min_rave){
				if(expnum > 0)
					val = exp.avg();
			}else if(ravenum > 0 || expnum > 0){
				float alpha = ravefactor/(ravefactor + expnum);
//				float alpha = sqrt(ravefactor/(ravefactor + 3.0f*expnum));
//				float alpha = ravenum/(expnum + ravenum + expnum*ravenum*ravefactor);

				val = 0;
				if(ravenum > 0) val += alpha*rave.avg();
				if(expnum  > 0) val += (1.0f-alpha)*exp.avg();
			}

			if(knowledge && know > 0){
				if(expnum <= 1)
					val += 0.01f * know;
				else if(expnum < 1000) //knowledge is only useful with little experience
					val += 0.01f * know / sqrt(expnum);
			}

			return val;
		}

// Assembly:
subq $0x48, %rsp
movb %sil, %al
movq %rdi, 0x40(%rsp)
vmovss %xmm0, 0x3c(%rsp)
andb $0x1, %al
movb %al, 0x3b(%rsp)
vmovss %xmm1, 0x34(%rsp)
movq 0x40(%rsp), %rdi
movq %rdi, 0x18(%rsp)
vmovss 0x34(%rsp), %xmm0
vmovss %xmm0, 0x30(%rsp)
addq $0x10, %rdi
callq 0x1c800
movq 0x18(%rsp), %rdi
vcvtusi2ss %rax, %xmm0, %xmm0
vmovss %xmm0, 0x2c(%rsp)
callq 0x1c800
vcvtusi2ss %rax, %xmm0, %xmm0
vmovss %xmm0, 0x28(%rsp)
vmovss 0x30949(%rip), %xmm0    # 0x4d220
vucomiss 0x3c(%rsp), %xmm0
jb 0x1c908
vmovss 0x2c(%rsp), %xmm0
vpxor %xmm1, %xmm1, %xmm1
vucomiss %xmm1, %xmm0
jbe 0x1c903
movq 0x18(%rsp), %rdi
addq $0x10, %rdi
callq 0x1cab0
vmovss %xmm0, 0x30(%rsp)
jmp 0x1c9dc
vmovss 0x28(%rsp), %xmm0
vpxor %xmm1, %xmm1, %xmm1
vucomiss %xmm1, %xmm0
ja 0x1c92c
vmovss 0x2c(%rsp), %xmm0
vpxor %xmm1, %xmm1, %xmm1
vucomiss %xmm1, %xmm0
jbe 0x1c9da
vmovss 0x3c(%rsp), %xmm0
vmovss 0x3c(%rsp), %xmm1
vaddss 0x2c(%rsp), %xmm1, %xmm1
vdivss %xmm1, %xmm0, %xmm0
vmovss %xmm0, 0x24(%rsp)
vpxor %xmm0, %xmm0, %xmm0
vmovss %xmm0, 0x30(%rsp)
vmovss 0x28(%rsp), %xmm0
vpxor %xmm1, %xmm1, %xmm1
vucomiss %xmm1, %xmm0
jbe 0x1c98f
movq 0x18(%rsp), %rdi
vmovss 0x24(%rsp), %xmm0
vmovss %xmm0, 0x14(%rsp)
callq 0x1cab0
vmovss 0x14(%rsp), %xmm1
vmovss 0x30(%rsp), %xmm2
vfmadd213ss %xmm2, %xmm1, %xmm0 # xmm0 = (xmm1 * xmm0) + xmm2
vmovss %xmm0, 0x30(%rsp)
vmovss 0x2c(%rsp), %xmm0
vpxor %xmm1, %xmm1, %xmm1
vucomiss %xmm1, %xmm0
jbe 0x1c9d8
movq 0x18(%rsp), %rdi
vmovss 0x30864(%rip), %xmm0    # 0x4d210
vsubss 0x24(%rsp), %xmm0, %xmm0
vmovss %xmm0, 0x10(%rsp)
addq $0x10, %rdi
callq 0x1cab0
vmovss 0x10(%rsp), %xmm1
vmovss 0x30(%rsp), %xmm2
vfmadd213ss %xmm2, %xmm1, %xmm0 # xmm0 = (xmm1 * xmm0) + xmm2
vmovss %xmm0, 0x30(%rsp)
jmp 0x1c9da
jmp 0x1c9dc
testb $0x1, 0x3b(%rsp)
je 0x1ca9d
movq 0x18(%rsp), %rax
movswl 0x20(%rax), %eax
cmpl $0x0, %eax
jle 0x1ca9d
vmovss 0x3080f(%rip), %xmm0    # 0x4d210
vucomiss 0x2c(%rsp), %xmm0
jb 0x1ca31
movq 0x18(%rsp), %rax
movswl 0x20(%rax), %eax
vcvtsi2ss %eax, %xmm0, %xmm1
vmovss 0x30(%rsp), %xmm2
vmovss 0x30804(%rip), %xmm0    # 0x4d228
vfmadd213ss %xmm2, %xmm1, %xmm0 # xmm0 = (xmm1 * xmm0) + xmm2
vmovss %xmm0, 0x30(%rsp)
jmp 0x1ca9b
vmovss 0x307eb(%rip), %xmm0    # 0x4d224
vucomiss 0x2c(%rsp), %xmm0
jbe 0x1ca99
movq 0x18(%rsp), %rax
movswl 0x20(%rax), %eax
vcvtsi2ss %eax, %xmm0, %xmm1
vmovss 0x307d2(%rip), %xmm0    # 0x4d228
vmulss %xmm1, %xmm0, %xmm1
vcvtss2sd %xmm1, %xmm0, %xmm0
vmovsd %xmm0, 0x8(%rsp)
vmovss 0x2c(%rsp), %xmm1
vcvtss2sd %xmm1, %xmm0, %xmm0
callq 0x5320
vmovaps %xmm0, %xmm1
vmovsd 0x8(%rsp), %xmm0
vdivsd %xmm1, %xmm0, %xmm1
vmovss 0x30(%rsp), %xmm2
vcvtss2sd %xmm2, %xmm0, %xmm0
vaddsd %xmm1, %xmm0, %xmm1
vcvtsd2ss %xmm1, %xmm0, %xmm0
vmovss %xmm0, 0x30(%rsp)
jmp 0x1ca9b
jmp 0x1ca9d
vmovss 0x30(%rsp), %xmm0
addq $0x48, %rsp
retq
nopl (%rax,%rax)