mirror of
https://github.com/DoomKitty87/seafoam.git
synced 2025-02-06 18:25:09 +01:00
optimization is needed for the loading process
This commit is contained in:
parent
ce212350bf
commit
3926d0939f
2 changed files with 21 additions and 7 deletions
|
@ -127,7 +127,8 @@
|
||||||
<h3 class="infodesc">Your route is being generated. Please wait.</h3>
|
<h3 class="infodesc">Your route is being generated. Please wait.</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="routeresults">
|
<div class="routeresults">
|
||||||
<p class="routeoutput">Route loading...</p>
|
<div class="routebox"><p id="routeout" class="routeoutput">Route loading...</p></div>
|
||||||
|
<h3 id="routestats" class="routestats"></h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -206,7 +207,8 @@
|
||||||
var highestDensityDist = Infinity;
|
var highestDensityDist = Infinity;
|
||||||
console.log(padCoords.length / 3);
|
console.log(padCoords.length / 3);
|
||||||
for (var i = 0; i < padCoords.length / 3; i++) {
|
for (var i = 0; i < padCoords.length / 3; i++) {
|
||||||
console.log(`Generating route... ${Math.floor(i / (padCoords.length / 3) * 100)}%`);
|
//console.log(`Generating route... ${Math.floor(i / (padCoords.length / 3) * 100)}%`);
|
||||||
|
//document.getElementById("routeout").innerHTML = `Generating route... ${Math.floor(i / (padCoords.length / 3) * 100)}%`;
|
||||||
const path = [];
|
const path = [];
|
||||||
path.push(padCoords[i * 3]);
|
path.push(padCoords[i * 3]);
|
||||||
path.push(padCoords[i * 3 + 1]);
|
path.push(padCoords[i * 3 + 1]);
|
||||||
|
@ -235,7 +237,6 @@
|
||||||
//Include settable angle weighting later
|
//Include settable angle weighting later
|
||||||
|
|
||||||
weight = angleWeight * (Math.pow(dist, 2) + Math.pow(startdist, 1 * ((usedPads.length + 1) / desiredPathLength))) / ((gemDensity - 44) * 4);
|
weight = angleWeight * (Math.pow(dist, 2) + Math.pow(startdist, 1 * ((usedPads.length + 1) / desiredPathLength))) / ((gemDensity - 44) * 4);
|
||||||
if (weight == Infinity) console.log("Infinity");
|
|
||||||
if (dist > 62) weight = Infinity;
|
if (dist > 62) weight = Infinity;
|
||||||
|
|
||||||
weightChart.push(weight);
|
weightChart.push(weight);
|
||||||
|
@ -307,11 +308,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lowestWeight == Infinity) {
|
if (lowestWeight == Infinity) {
|
||||||
console.log("Route blocked.");
|
//console.log("Route blocked.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (lowestIndex == i) {
|
if (lowestIndex == i) {
|
||||||
console.log("Route complete.");
|
//console.log("Route complete.");
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -340,7 +341,7 @@
|
||||||
highestDensityPath = path;
|
highestDensityPath = path;
|
||||||
highestDensityDist = avgDist;
|
highestDensityDist = avgDist;
|
||||||
}
|
}
|
||||||
console.log(path.length / 3, density, avgDist);
|
//console.log(path.length / 3, density, avgDist);
|
||||||
}
|
}
|
||||||
//Choose between density and dist in settings as well though
|
//Choose between density and dist in settings as well though
|
||||||
var outPath = [];
|
var outPath = [];
|
||||||
|
@ -362,8 +363,9 @@
|
||||||
if (i != outPath.length / 3 - 1) pathOutput += ",";
|
if (i != outPath.length / 3 - 1) pathOutput += ",";
|
||||||
}
|
}
|
||||||
pathOutput += "]";
|
pathOutput += "]";
|
||||||
document.getElementsByClassName("routeoutput")[0].innerHTML = pathOutput;
|
document.getElementById("routeout").innerHTML = pathOutput;
|
||||||
console.log(outPath.length / 3, outPathDensity, outPathDist);
|
console.log(outPath.length / 3, outPathDensity, outPathDist);
|
||||||
|
document.getElementById("routestats").innerHTML = `Waypoints: ${outPath.length / 3}<br>Density: ${outPathDensity}<br>Distance: ${outPathDist}`;
|
||||||
return pathOutput, outPath.length / 3, outPathDensity, outPathDist;
|
return pathOutput, outPath.length / 3, outPathDensity, outPathDist;
|
||||||
}
|
}
|
||||||
var activeSquare = -1;
|
var activeSquare = -1;
|
||||||
|
|
|
@ -295,3 +295,15 @@ label.anglesettings {
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
user-select: text;
|
user-select: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.routebox {
|
||||||
|
height: 10rem;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.routestats {
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: 300;
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
Loading…
Reference in a new issue