Ejemplo n.º 1
0
 function Element($action_potential = NULL, $threshold = NULL, $is_input = NULL, $is_output = NULL)
 {
     if ($action_potential == NULL) {
         $action_potential = random_float(0, 1);
     }
     if ($threshold == NULL) {
         $threshold = rand(0, 1);
     }
     if ($is_input == NULL) {
         $is_input = (int) probability($this->genome['percent_of_inputs']);
     }
     if ($is_output == NULL) {
         $is_output = (int) probability($this->genome['percent_of_outputs']);
     }
     return array('potential' => $action_potential, 'threshold' => $threshold, 'is_input' => $is_input, 'is_output' => $is_output);
 }
function seed($seed_data, $participants, $coders_info)
{
    $newseed = array();
    foreach ($seed_data as $Idi => $ratingi) {
        $newseed[$Idi] = 1;
    }
    foreach ($seed_data as $Idi => $ratingi) {
        if ($coders_info->is_new_coder($Idi)) {
            $newseed[$Idi] = 1 + $participants / 2;
        } else {
            foreach ($seed_data as $Idj => $ratingj) {
                if ($Idi == $Idj) {
                    continue;
                } else {
                    $newseed[$Idi] += probability($ratingj, $ratingi);
                }
            }
        }
    }
    return $newseed;
}
Ejemplo n.º 3
0
function lanes($c, $s, $conf)
{
    //acceptes the same conditions,
    //$c contains 5 champions
    //$s is an array containing 10 spells
    $arrangement = array(0, 0, 0, 0, 0);
    for ($i = 0; $i < 5; $i++) {
        # set the arrangement by calculating the probability of each champion
        $arrangement[$i] = rLane(probability($c[$i], $s[2 * $i], $s[2 * $i + 1]), false);
        $conf[$i] = confidence(probability($c[$i], $s[2 * $i], $s[2 * $i + 1]));
    }
    return array_merge(distTeam($arrangement), $conf);
}
function average_probability($length = 8, $type = 'alpha_numeric', $tests = 100, $max = 1000000)
{
    heading('Probability for length= ' . $length . ', type=' . $type);
    $iterations = 0;
    $low = INF;
    $high = 0;
    for ($i = 0; $i < $tests; $i++) {
        printf("Running test %d of %d\r", $i, $tests);
        //printf("Test progress: %f%s\r", $i / $tests, '%');
        $result = probability($length, $type, $max);
        $low = $result < $low ? $result : $low;
        $high = $result > $high ? $result : $high;
        $iterations += $result;
        //printf("Iteration count: %d\n", $iterations);
    }
    $average = $iterations / $tests;
    printf("Iteration range: %d - %d\n", $low, $high);
    printf("Average probability tests_run[%d] max_iterations[%d]: 1 / %d\n", $tests, $max, $average);
}
Ejemplo n.º 5
-22
function team($c, $s)
{
    $arrangement = array(-1, -1, -1, -1, -1);
    for ($i = 0; $i < 5; $i++) {
        $arrangement[$i] = pLane(probability($c[$i], array_slice($s, $i * 2, 2)));
    }
    if (array_count_values($arrangement)[0] > 1) {
        $arrangement = topFix($arrangement, $s);
    }
    if (array_count_values($arrangement)[-1] > 1) {
        # figure this mess out later
    } else {
        if (array_count_values($arrangement)[-1] == 1) {
            $arrangement = distribute($arrangement);
        }
    }
    $multiple = verify($arrangement);
    if ($multiple !== true) {
        # we have an unresolveable conflict
        return array(-1, -1, -1, -1, -1);
    }
    return $arrangement;
}