diff options
author | Minteck <contact@minteck.org> | 2023-02-23 19:34:56 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2023-02-23 19:34:56 +0100 |
commit | 3d1cd02f27518f1a04374c7c8320cd5d82ede6e9 (patch) | |
tree | 75be5fba4368472fb11c8015aee026b2b9a71888 /autoschedule/main.php | |
parent | 8cc1f13c17fa2fb5a4410542d39e650e02945634 (diff) | |
download | pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.gz pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.bz2 pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.zip |
Updated 40 files, added 37 files, deleted 1103 files and renamed 3905 files (automated)
Diffstat (limited to 'autoschedule/main.php')
-rw-r--r-- | autoschedule/main.php | 287 |
1 files changed, 0 insertions, 287 deletions
diff --git a/autoschedule/main.php b/autoschedule/main.php deleted file mode 100644 index e3ae2bf..0000000 --- a/autoschedule/main.php +++ /dev/null @@ -1,287 +0,0 @@ -<?php - -$_SERVER['DOCUMENT_ROOT'] = ".."; - -require_once "../includes/score.inc"; -require_once "../includes/bitset.inc"; -require_once "../includes/functions.inc"; - -$days = []; -$today_date = date('Y-m-d', time() + 86400); -$today_weekday = (int)date('N', time() + 86400); -$today = []; -$weekend = $today_weekday > 5; - -require_once "./ponies.php"; global $ponies_raindrops; global $ponies_cloudburst; - -$candidates_cloudburst = []; -$candidates_cloudburst_sorted = [ - "night" => [[], [], [], []], - "morning" => [[], [], [], []], - "afternoon" => [[], [], [], []], - "evening" => [[], [], [], []] -]; -$candidates_cloudburst_best = []; - -foreach ($ponies_cloudburst as $pony) { - $dates = $pony["_dates"]; - echo($pony["name"] . ": " . $dates[0] . ", " . $dates[1] . "\n"); - - $candidates_cloudburst[] = $pony["id"]; - if (isset($dates[0])) $candidates_cloudburst_sorted[$dates[1]][1][] = $pony["id"]; - if (isset($dates[1])) $candidates_cloudburst_sorted[$dates[0]][0][] = $pony["id"]; - if (isset($dates[2])) $candidates_cloudburst_sorted[$dates[2]][2][] = $pony["id"]; - if (isset($dates[3])) $candidates_cloudburst_sorted[$dates[3]][3][] = $pony["id"]; -} - -unset($candidates_cloudburst_sorted[""]); - -$candidates_cloudburst_sorted["night"] = [ - ...$candidates_cloudburst_sorted["night"][0], - ...$candidates_cloudburst_sorted["night"][1], - ...$candidates_cloudburst_sorted["night"][2], - ...$candidates_cloudburst_sorted["night"][3] -]; -$candidates_cloudburst_sorted["morning"] = [ - ...$candidates_cloudburst_sorted["morning"][0], - ...$candidates_cloudburst_sorted["morning"][1], - ...$candidates_cloudburst_sorted["morning"][2], - ...$candidates_cloudburst_sorted["morning"][3] -]; -$candidates_cloudburst_sorted["afternoon"] = [ - ...$candidates_cloudburst_sorted["afternoon"][0], - ...$candidates_cloudburst_sorted["afternoon"][1], - ...$candidates_cloudburst_sorted["afternoon"][2], - ...$candidates_cloudburst_sorted["afternoon"][3] -]; -$candidates_cloudburst_sorted["evening"] = [ - ...$candidates_cloudburst_sorted["evening"][0], - ...$candidates_cloudburst_sorted["evening"][1], - ...$candidates_cloudburst_sorted["evening"][2], - ...$candidates_cloudburst_sorted["evening"][3] -]; - -$candidates_cloudburst_id = []; -$candidates_cloudburst_id["night"] = 0; -$candidates_cloudburst_id["morning"] = 0; -$candidates_cloudburst_id["afternoon"] = 0; -$candidates_cloudburst_id["evening"] = 0; - -$candidates_cloudburst_best["night"] = $candidates_cloudburst_sorted["night"][$candidates_cloudburst_id["night"]]; -$candidates_cloudburst_best["morning"] = $candidates_cloudburst_sorted["morning"][$candidates_cloudburst_id["morning"]]; -$candidates_cloudburst_best["afternoon"] = $candidates_cloudburst_sorted["afternoon"][$candidates_cloudburst_id["afternoon"]]; -$candidates_cloudburst_best["evening"] = $candidates_cloudburst_sorted["evening"][$candidates_cloudburst_id["evening"]]; - -$candidates_raindrops = []; -$candidates_raindrops_sorted = [ - "night" => [[], [], [], []], - "morning" => [[], [], [], []], - "afternoon" => [[], [], [], []], - "evening" => [[], [], [], []] -]; -$candidates_raindrops_best = []; - -foreach ($ponies_raindrops as $pony) { - $dates = $pony["_dates"]; - echo($pony["name"] . ": " . implode(", ", $dates) . "\n"); - - $add = false; - - if ($weekend && $pony["_metadata"]["shared_memory"] < 2) { - $add = true; - } else if ($weekend && $pony["_metadata"]["little"] === 2) { - $add = true; - } else if ($pony["_metadata"]["little"] !== 2 && !$pony["_metadata"]["shared_memory"] < 2) { - $add = true; - } - - if ($add) { - $candidates_raindrops[] = $pony["id"]; - if (isset($dates[0])) $candidates_raindrops_sorted[$dates[0]][0][] = $pony["id"]; - if (isset($dates[1])) $candidates_raindrops_sorted[$dates[1]][1][] = $pony["id"]; - if (isset($dates[2])) $candidates_raindrops_sorted[$dates[2]][2][] = $pony["id"]; - if (isset($dates[3])) $candidates_raindrops_sorted[$dates[3]][3][] = $pony["id"]; - } -} - -unset($candidates_raindrops_sorted[""]); - -$candidates_raindrops_sorted["night"] = [ - ...$candidates_raindrops_sorted["night"][0], - ...$candidates_raindrops_sorted["night"][1], - ...$candidates_raindrops_sorted["night"][2], - ...$candidates_raindrops_sorted["night"][3] -]; -$candidates_raindrops_sorted["morning"] = [ - ...$candidates_raindrops_sorted["morning"][0], - ...$candidates_raindrops_sorted["morning"][1], - ...$candidates_raindrops_sorted["morning"][2], - ...$candidates_raindrops_sorted["morning"][3] -]; -$candidates_raindrops_sorted["afternoon"] = [ - ...$candidates_raindrops_sorted["afternoon"][0], - ...$candidates_raindrops_sorted["afternoon"][1], - ...$candidates_raindrops_sorted["afternoon"][2], - ...$candidates_raindrops_sorted["afternoon"][3] -]; -$candidates_raindrops_sorted["evening"] = [ - ...$candidates_raindrops_sorted["evening"][0], - ...$candidates_raindrops_sorted["evening"][1], - ...$candidates_raindrops_sorted["evening"][2], - ...$candidates_raindrops_sorted["evening"][3] -]; - -$candidates_raindrops_id = []; -$candidates_raindrops_id["night"] = 0; -$candidates_raindrops_id["morning"] = 0; -$candidates_raindrops_id["afternoon"] = 0; -$candidates_raindrops_id["evening"] = 0; - -$candidates_raindrops_best["night"] = $candidates_raindrops_sorted["night"][$candidates_raindrops_id["night"]]; -$candidates_raindrops_best["morning"] = $candidates_raindrops_sorted["morning"][$candidates_raindrops_id["morning"]]; -$candidates_raindrops_best["afternoon"] = $candidates_raindrops_sorted["afternoon"][$candidates_raindrops_id["afternoon"]]; -$candidates_raindrops_best["evening"] = $candidates_raindrops_sorted["evening"][$candidates_raindrops_id["evening"]]; - -echo("--------------\n"); - -var_dump($candidates_cloudburst_best); -var_dump($candidates_raindrops_best); - -echo("--------------\n"); - -$correct = false; -$relationships = []; - -foreach (scoreOrderGlobal() as $pony) { - $relationships[$pony["id"]] = [ - ...array_map(function ($i) { - return explode("/", $i)[1]; - }, array_values(array_filter($pony["_metadata"]["marefriends"], function ($i) use ($pony) { - return explode("/", $i)[0] !== $pony["_system"]; - }))), - ...array_map(function ($i) { - return explode("/", $i)[1]; - }, array_values(array_filter($pony["_metadata"]["sisters"], function ($i) use ($pony) { - return explode("/", $i)[0] !== $pony["_system"]; - }))), - ...array_map(function ($i) { - return explode("/", $i)[1]; - }, array_values(array_filter($pony["_metadata"]["caretakers"], function ($i) use ($pony) { - return explode("/", $i)[0] !== $pony["_system"]; - }))) - ]; -} - -$runs = 0; -while (!$correct) { - $ponies = []; - $fixed = false; - - foreach (["morning", "afternoon", "evening", "night"] as $period) { - if (in_array($candidates_raindrops_best[$period], $ponies)) { - echo("Saw " . $candidates_raindrops_best[$period] . " (raindrops) more than once\n"); - - if (count($candidates_raindrops_sorted[$period]) > $candidates_raindrops_id[$period]) { - $candidates_raindrops_id[$period]++; - - if (isset($candidates_raindrops_sorted[$period][$candidates_raindrops_id[$period]])) { - $candidates_raindrops_best[$period] = $candidates_raindrops_sorted[$period][$candidates_raindrops_id[$period]]; - echo(" Conflict resolved\n"); - $fixed = true; - } else { - echo(" Unable to resolve conflict\n"); - } - } else { - echo(" Unable to resolve conflict\n"); - } - } else { - $ponies[] = $candidates_raindrops_best[$period]; - } - - if (in_array($candidates_cloudburst_best[$period], $ponies)) { - echo("Saw " . $candidates_cloudburst_best[$period] . " (cloudburst) more than once\n"); - - if (count($candidates_cloudburst_sorted[$period]) > $candidates_cloudburst_id[$period]) { - $candidates_cloudburst_id[$period]++; - - if (isset($candidates_cloudburst_sorted[$period][$candidates_cloudburst_id[$period]])) { - $candidates_cloudburst_best[$period] = $candidates_cloudburst_sorted[$period][$candidates_cloudburst_id[$period]]; - echo(" Conflict resolved\n"); - $fixed = true; - } else { - echo(" Unable to resolve conflict\n"); - } - } else { - echo(" Unable to resolve conflict\n"); - } - } else { - $ponies[] = $candidates_cloudburst_best[$period]; - } - - $relations_cloudburst = $relationships[$candidates_cloudburst_best[$period]]; - $relations_raindrops = $relationships[$candidates_raindrops_best[$period]]; - - if (!in_array($candidates_cloudburst_best[$period], $relations_raindrops)) { - echo($candidates_cloudburst_best[$period] . " (cloudburst) is not in a relationship with " . $candidates_raindrops_best[$period] . " (raindrops)\n"); - - $fixable = false; - $fixRelation = null; - - foreach ($relationships[$candidates_cloudburst_best[$period]] as $relationship) { - if (in_array($relationship, $candidates_raindrops_sorted[$period])) { - $fixable = true; - $fixRelation = $relationship; - break; - } - } - - if (!$fixable) { - echo(" Unable to resolve conflict\n"); - } else { - $fixed = true; - $candidates_raindrops_id[$period] = array_search($fixRelation, $candidates_raindrops_sorted[$period]); - $candidates_raindrops_best[$period] = $fixRelation; - echo(" Conflict resolved\n"); - } - } - - if (!in_array($candidates_raindrops_best[$period], $relations_cloudburst)) { - echo($candidates_raindrops_best[$period] . " (raindrops) is not in a relationship with " . $candidates_cloudburst_best[$period] . " (cloudburst)\n"); - - $fixable = false; - $fixRelation = null; - - foreach ($relationships[$candidates_raindrops_best[$period]] as $relationship) { - if (in_array($relationship, $candidates_cloudburst_sorted[$period])) { - $fixable = true; - $fixRelation = $relationship; - break; - } - } - - if (!$fixable) { - echo(" Unable to resolve conflict\n"); - } else { - $fixed = true; - $candidates_cloudburst_id[$period] = array_search($fixRelation, $candidates_cloudburst_sorted[$period]); - $candidates_cloudburst_best[$period] = $fixRelation; - echo(" Conflict resolved\n"); - } - } - } - - if (!$fixed) $correct = true; - - if ($runs > 8) { - $correct = true; - } - - $runs++; -} - -echo("--------------\n"); - -echo("Morning: " . getSystemMember("ynmuc", $candidates_cloudburst_best["morning"])["display_name"] . " with " . getSystemMember("gdapd", $candidates_raindrops_best["morning"])["display_name"] . "\n"); -echo("Afternoon: " . getSystemMember("ynmuc", $candidates_cloudburst_best["afternoon"])["display_name"] . " with " . getSystemMember("gdapd", $candidates_raindrops_best["afternoon"])["display_name"] . "\n"); -echo("Evening: " . getSystemMember("ynmuc", $candidates_cloudburst_best["evening"])["display_name"] . " with " . getSystemMember("gdapd", $candidates_raindrops_best["evening"])["display_name"] . "\n"); -echo("Night: " . getSystemMember("ynmuc", $candidates_cloudburst_best["night"])["display_name"] . " with " . getSystemMember("gdapd", $candidates_raindrops_best["night"])["display_name"] . "\n");
\ No newline at end of file |