update zum PC

This commit is contained in:
silas
2018-11-12 18:10:45 +01:00
parent 651f6c90ec
commit 4d7f566656
4 changed files with 97 additions and 48 deletions

View File

@@ -118,7 +118,7 @@ class LevelManager extends StandardManager
public function generateLevels()
{
$levelsToGenerate = [
//(0) 80
80 => //(0) 80
[
"wordLength" => 10,
"numWords" => 4,
@@ -127,8 +127,9 @@ class LevelManager extends StandardManager
"difficulty" => function () {
return 1000;
},
"creationRatio" => 1,
],
//(1) 81
81 => //(1) 81
[
"wordLength" => 10,
"numWords" => 4,
@@ -137,8 +138,9 @@ class LevelManager extends StandardManager
"difficulty" => function () {
return 1000;
},
"creationRatio" => 1,
],
//(2) 82
82 => //(2) 82
[
"wordLength" => 10,
"numWords" => 4,
@@ -147,8 +149,9 @@ class LevelManager extends StandardManager
"difficulty" => function () {
return 1000;
},
"creationRatio" => 1,
],
//(3) 83
83 => //(3) 83
[
"wordLength" => 10,
"numWords" => 4,
@@ -157,8 +160,9 @@ class LevelManager extends StandardManager
"difficulty" => function () {
return 1000;
},
"creationRatio" => 1,
],
//(4) 100
100 => //(4) 100
[
"wordLength" => 8,
"numWords" => 6,
@@ -167,8 +171,9 @@ class LevelManager extends StandardManager
"difficulty" => function () {
return 1000;
},
"creationRatio" => 8,
],
//(5) 110
110 => //(5) 110
[
"wordLength" => 10,
"numWords" => 4,
@@ -177,8 +182,9 @@ class LevelManager extends StandardManager
"difficulty" => function () {
return 1000;
},
"creationRatio" => 5.333333,
],
//(6) 111
111 => //(6) 111
[
"wordLength" => 10,
"numWords" => 4,
@@ -187,8 +193,9 @@ class LevelManager extends StandardManager
"difficulty" => function () {
return 1000;
},
"creationRatio" => 5.333333,
],
//(7) 112
112 => //(7) 112
[
"wordLength" => 10,
"numWords" => 4,
@@ -197,8 +204,9 @@ class LevelManager extends StandardManager
"difficulty" => function () {
return 1000;
},
"creationRatio" => 5.333333,
],
//(8) 120
120 => //(8) 120
[
"wordLength" => 8,
"numWords" => 4,
@@ -207,8 +215,9 @@ class LevelManager extends StandardManager
"difficulty" => function () {
return 1000;
},
"creationRatio" => 32,
],
//(9) 140
140 => //(9) 140
[
"wordLength" => 12,
"numWords" => 6,
@@ -217,8 +226,9 @@ class LevelManager extends StandardManager
"difficulty" => function () {
return 1000;
},
"creationRatio" => 64,
],
//(10) 160
160 => //(10) 160
[
"wordLength" => 12,
"numWords" => 4,
@@ -227,51 +237,42 @@ class LevelManager extends StandardManager
"difficulty" => function () {
return 1000;
},
"creationRatio" => 128,
],
];
$creationRation = [
0 => 1,
1 => 1,
2 => 1,
3 => 1,
4 => 16,
5 => 5.333333,
6 => 5.333333,
7 => 5.333333,
8 => 24,
9 => 28,
10 => 52
];
$currentNumbers = [];
for ($i = 0; $i < count($levelsToGenerate); $i++) {
$currentNumbers[$i] = $this->countWhere(["renderer" => $levelsToGenerate[$i]["renderer"], "difficulty" => 1000]);
foreach ($levelsToGenerate as $renderer => $levelInfo) {
$currentNumbers[$renderer] = $this->countWhere(["renderer" => $levelInfo["renderer"], "difficulty" => 1000]);
}
$renderers = array_keys($levelsToGenerate);
$levelGenerated = 0;
$currentIndex = count($levelsToGenerate) - 1;
$currentIndex = 0;
$words = [];
do {
// var_dump($levelsToGenerate);
if ($currentIndex === 0 || $currentNumbers[$currentIndex] >= $currentNumbers[0] * $creationRation[$currentIndex]) {
$currentIndex = ($currentIndex + 1) % count($levelsToGenerate);
while ($currentIndex === 0 || $currentNumbers[$renderers[$currentIndex]] >= $currentNumbers[$renderers[0]] * $levelsToGenerate[$renderers[$currentIndex]]["creationRatio"]) {
$currentIndex = ($currentIndex + 1) % count($renderers);
if ($currentIndex === 0){
break;
}
}
$words[$levelsToGenerate[$renderers[$currentIndex]]["wordLength"]] = $words[$levelsToGenerate[$renderers[$currentIndex]]["wordLength"]] ?? $this->wordManager->findWordsForLength($levelsToGenerate[$renderers[$currentIndex]]["wordLength"]);
$words[$levelsToGenerate[$currentIndex]["wordLength"]] = $words[$levelsToGenerate[$currentIndex]["wordLength"]] ?? $this->wordManager->findWordsForLength($levelsToGenerate[$currentIndex]["wordLength"]);
$currentWords = $words[$levelsToGenerate[$renderers[$currentIndex]]["wordLength"]];
$currentWords = $words[$levelsToGenerate[$currentIndex]["wordLength"]];
$level = $this->generateLevelWithData($levelsToGenerate[$currentIndex], $currentWords);
$level = $this->generateLevelWithData($levelsToGenerate[$renderers[$currentIndex]], $currentWords);
if ($level) {
$words[$levelsToGenerate[$currentIndex]["wordLength"]] = $currentWords;
$words[$levelsToGenerate[$renderers[$currentIndex]]["wordLength"]] = $currentWords;
$this->save($level, false);
$levelGenerated++;
$currentNumbers[$currentIndex]++;
$currentNumbers[$renderers[$currentIndex]]++;
} else {
var_dump($renderers[$currentIndex]);
break;
}