function getHeight() { if ($_POST["sex"] == 'F') { return purebell(48, 72, 2.7); } return purebell(54, 78, 2.9); }
function purebell($min, $max, $std_deviation, $step = 1) { $rand1 = (double) mt_rand() / (double) mt_getrandmax(); $rand2 = (double) mt_rand() / (double) mt_getrandmax(); $gaussian_number = sqrt(-2 * log($rand1)) * cos(2 * M_PI * $rand2); $mean = ($max + $min) / 2; $random_number = $gaussian_number * $std_deviation + $mean; $random_number = round($random_number / $step) * $step; if ($random_number < $min || $random_number > $max) { $random_number = purebell($min, $max, $std_deviation); } return $random_number; }
function createSettelment() { $trait_table = "settlement_traits"; $table = "settlement"; $columns = getColumnNames($table); if (empty($_POST['size'])) { $i = rand(0, 2); if ($i == 0) { $size = "S"; } else { if ($i == 1) { $size = "M"; } else { $s = "L"; } } $_POST['size'] = $size; } if (empty($_POST['population'])) { $size = $_POST['size']; if ($size == "S") { $pop = purebell(20, 75, 5); } else { if ($size == "M") { $pop = purebell(76, 300, 10); } else { $pop = purebell(300, 1500, 100); } } $_POST['population'] = $pop; } // Pick a mayor if (empty($_POST['ruler_id'])) { createNpc(); $table = "npc"; $_POST['ruler_id'] = insertFromPostWithIdReturn($table); } foreach ($columns as $column) { if (empty($_POST[$column])) { $_POST[$column] = getTrait($trait_table, $column); } } }