add hardware constraints config

This commit is contained in:
2025-09-08 14:19:50 -05:00
parent 6a7651a96f
commit a4d9e71019
3 changed files with 24 additions and 17 deletions
+9
View File
@@ -25,6 +25,15 @@
<input type="number" id="connectionDistance" value="250" autocomplete="off"> <input type="number" id="connectionDistance" value="250" autocomplete="off">
</div> </div>
</details> </details>
<details id="hardwareConstraints">
<summary>Hardware Constraints</summary>
<div id="hardwareConstraintsContent">
<label for="maxOutgoingConnections">Max Outgoing Connections</label>
<input type="number" id="maxOutgoingConnections" value="3" autocomplete="off">
<label for="maxIncomingConnections">Max Incoming Connections</label>
<input type="number" id="maxIncomingConnections" value="3" autocomplete="off">
</div>
</details>
<details id="engineSettings"> <details id="engineSettings">
<summary>Engine Settings</summary> <summary>Engine Settings</summary>
<div id="engineSettingsContent"> <div id="engineSettingsContent">
+13 -3
View File
@@ -2,6 +2,8 @@ var UPDATE_INTERVAL = 10;
var CONNECTION_DISTANCE = 250; var CONNECTION_DISTANCE = 250;
var DROP_PENALTY = 1.2; var DROP_PENALTY = 1.2;
var TTL = 5; var TTL = 5;
var MAX_OUTGOING_CONNECTIONS = 3;
var MAX_INCOMING_CONNECTIONS = 3;
function smoothColorTransition(color1, color2, min, max, current) { function smoothColorTransition(color1, color2, min, max, current) {
// Clamp current between min and max // Clamp current between min and max
@@ -329,7 +331,7 @@ function main() {
if (nodeTable[neighbor.node].incoming.length == 0) { if (nodeTable[neighbor.node].incoming.length == 0) {
connectionScore += 10000; connectionScore += 10000;
} }
if (nodeTable[neighbor.node].incoming.length >= 3) { if (nodeTable[neighbor.node].incoming.length >= MAX_INCOMING_CONNECTIONS) {
continue; continue;
} }
if (nodeTable[node1].outgoing.includes(neighbor.node)) { if (nodeTable[node1].outgoing.includes(neighbor.node)) {
@@ -341,7 +343,7 @@ function main() {
const neighborMap = new Map(neighbors.map(n => [n.node, n])); const neighborMap = new Map(neighbors.map(n => [n.node, n]));
const top3 = scores.slice(0, 3); const top3 = scores.slice(0, 3);
for (let score of top3) { for (let score of top3) {
if (nodeTable[node1].outgoing.length >= 3) { if (nodeTable[node1].outgoing.length >= MAX_OUTGOING_CONNECTIONS) {
let dropped = false; let dropped = false;
if (nodeTable[node1].outgoing.includes(score.node)) { if (nodeTable[node1].outgoing.includes(score.node)) {
//console.log(`${score.node} is already in outgoing; skipping drop attempt`); //console.log(`${score.node} is already in outgoing; skipping drop attempt`);
@@ -378,7 +380,7 @@ function main() {
} }
} }
// still at capacity and nothing was dropped — skip adding this candidate // still at capacity and nothing was dropped — skip adding this candidate
if (nodeTable[node1].outgoing.length >= 3 && !dropped) { if (nodeTable[node1].outgoing.length >= MAX_OUTGOING_CONNECTIONS && !dropped) {
continue; continue;
} }
} }
@@ -469,4 +471,12 @@ document.getElementById('dropPenalty').addEventListener('change', function() {
document.getElementById('ttl').addEventListener('change', function() { document.getElementById('ttl').addEventListener('change', function() {
TTL = parseInt(this.value); TTL = parseInt(this.value);
});
document.getElementById('maxOutgoingConnections').addEventListener('change', function() {
MAX_OUTGOING_CONNECTIONS = parseInt(this.value);
});
document.getElementById('maxIncomingConnections').addEventListener('change', function() {
MAX_INCOMING_CONNECTIONS = parseInt(this.value);
}); });
+2 -14
View File
@@ -68,7 +68,7 @@ html, body {
gap: 10px; gap: 10px;
} }
#simpleSettingsContent { #simpleSettingsContent, #engineSettingsContent, #hardwareConstraintsContent {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 10px; gap: 10px;
@@ -76,18 +76,6 @@ html, body {
padding-top: 10px; padding-top: 10px;
} }
#engineSettingsContent { #simpleSettings, #hardwareConstraints, #engineSettings {
display: flex;
flex-direction: column;
gap: 10px;
padding-left: 20px;
padding-top: 10px;
}
#simpleSettings {
margin-bottom: 10px;
}
#engineSettings {
margin-bottom: 10px; margin-bottom: 10px;
} }