################################################### # our rule set contains 4 rules : # 1) roll if it is the 1st throw # 2) roll if SAVE doesn't make sense # 3) roll if the finish is within $Mean distance # 4) roll if we've less than the $Mean ################################################### my $Action = "SAVE"; # defense programming # trivial, BTW it is subset of rule 4) # if ($t == 0) { $Action = "ROLL"; $Game{History} .= "t"; } # use "<=" to not SAVE if our chance is not better # if ($pWin[$a1] <= $pWin[$a2] / (1 - $pWin[$a2])) { $Action = "ROLL"; $Game{History} .= "c"; } # use "<=" to include the border too # if (50 - $a1 <= ValueToPoints ($Mean)) { $Action = "ROLL"; $Game{History} .= "f"; } # use "<" b/c getting the mean is sufficient enough # if ($a1 - $Saved < ValueToPoints ($Mean)) { $Action = "ROLL"; $Game{History} .= "m"; } print $Socket "$Action", "\n"; Log 4, "$Action", "\n";