#
# Duelling cowboys
#  See http://hakank.org/webppl/duelling_cowboys.wppl
# 
# Here I try to recover the probability that A survives when
# A or B start with equal probability.
# The test is
#   0.3 0.7 ?
# The expected value is 0.24683544303797486
#
# Here is one fairly good solution (the error is basically 0):
# 
# All solutions with the best fitness (6.071532165918825E-15):
# A / (A + (((B - A) * (B - (B - (B / (2.0 - B))))) + B)) [1]
# 0.3 0.7    Result: 0.2468354430379747
#
# In[2]:= A / (A + (((B - A) * (B - (B - (B / (2.0 - B))))) + B)) // FullSimplify                  #          
#
#          0.5 A (-2. + B)
# Out[2]= ------------------
#         A (-1. + B) - 1. B
#
#
# Similar solution:
#
# A / ((A + B) - (B * (B - (((B - A) / (2.0 - B)) + B)))) [1]
# It was 1 different solutions with fitness 5.904998712225051E-15
# 0.3 0.7    Result: 0.24683544303797464
# In[2]:= A / ((A + B) - (B * (B - (((B - A) / (2.0 - B)) + B))))  // FullSimplify                 #          
#
#          0.5 A (-2. + B)
# Out[2]= ------------------
#         A (-1. + B) - 1. B
#
#
presentation: Duelling cowboys
return_type: DoubleClass
num_input_variables: 2
variable_names: A B PA
# output_variable: 2
functions: Multiply,Divide,Add,Subtract
terminal_range: -10 10
max_init_depth: 4
population_size: 1500
max_crossover_depth: 8
num_evolutions: 800
max_nodes: 21
show_population: false
show_similiar: true
stop_criteria_fitness: 0.01
data
# a b  prob(A survives)
0.1,0.1,0.5,
0.1,0.2,0.32142857142857095,
0.1,0.3,0.22972972972972974,
0.1,0.4,0.17391304347826053,
0.1,0.5,0.13636363636363646,
0.1,0.6,0.10937499999999976,
0.1,0.7,0.08904109589041062,
0.1,0.8,0.07317073170731696,
0.1,0.9,0.0604395604395603,
0.2,0.2,0.5,
0.2,0.3,0.38636363636363663,
0.2,0.4,0.3076923076923075,
0.2,0.5,0.24999999999999978,
0.2,0.6,0.20588235294117652,
0.2,0.7,0.17105263157894735,
0.2,0.8,0.1428571428571429,
0.2,0.9,0.11956521739130402,
0.3,0.3,0.5,
0.3,0.4,0.4137931034482764,
0.3,0.5,0.34615384615384626,
0.3,0.6,0.29166666666666646,
0.3,0.7,0.24683544303797486,
0.3,0.8,0.20930232558139525,
0.3,0.9,0.17741935483870974,
0.4,0.4,0.5,
0.4,0.5,0.4285714285714287,
0.4,0.6,0.3684210526315791,
0.4,0.7,0.3170731707317074,
0.4,0.8,0.27272727272727276,
0.4,0.9,0.2340425531914893,
0.5,0.5,0.5,
0.5,0.6,0.4374999999999997,
0.5,0.7,0.38235294117647045,
0.5,0.8,0.33333333333333326,
0.5,0.9,0.2894736842105264,
0.6,0.6,0.5,
0.6,0.7,0.4431818181818181,
0.6,0.8,0.39130434782608736,
0.6,0.9,0.34375000000000006,
0.7,0.7,0.5,
0.7,0.8,0.4468085106382979,
0.7,0.9,0.3969072164948454,
0.8,0.8,0.5,
0.8,0.9,0.44897959183673464,
0.9,0.9,0.5
0.3,0.7,?