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">
</div>
</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">
<summary>Engine Settings</summary>
<div id="engineSettingsContent">
+13 -3
View File
@@ -2,6 +2,8 @@ var UPDATE_INTERVAL = 10;
var CONNECTION_DISTANCE = 250;
var DROP_PENALTY = 1.2;
var TTL = 5;
var MAX_OUTGOING_CONNECTIONS = 3;
var MAX_INCOMING_CONNECTIONS = 3;
function smoothColorTransition(color1, color2, min, max, current) {
// Clamp current between min and max
@@ -329,7 +331,7 @@ function main() {
if (nodeTable[neighbor.node].incoming.length == 0) {
connectionScore += 10000;
}
if (nodeTable[neighbor.node].incoming.length >= 3) {
if (nodeTable[neighbor.node].incoming.length >= MAX_INCOMING_CONNECTIONS) {
continue;
}
if (nodeTable[node1].outgoing.includes(neighbor.node)) {
@@ -341,7 +343,7 @@ function main() {
const neighborMap = new Map(neighbors.map(n => [n.node, n]));
const top3 = scores.slice(0, 3);
for (let score of top3) {
if (nodeTable[node1].outgoing.length >= 3) {
if (nodeTable[node1].outgoing.length >= MAX_OUTGOING_CONNECTIONS) {
let dropped = false;
if (nodeTable[node1].outgoing.includes(score.node)) {
//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
if (nodeTable[node1].outgoing.length >= 3 && !dropped) {
if (nodeTable[node1].outgoing.length >= MAX_OUTGOING_CONNECTIONS && !dropped) {
continue;
}
}
@@ -470,3 +472,11 @@ document.getElementById('dropPenalty').addEventListener('change', function() {
document.getElementById('ttl').addEventListener('change', function() {
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;
}
#simpleSettingsContent {
#simpleSettingsContent, #engineSettingsContent, #hardwareConstraintsContent {
display: flex;
flex-direction: column;
gap: 10px;
@@ -76,18 +76,6 @@ html, body {
padding-top: 10px;
}
#engineSettingsContent {
display: flex;
flex-direction: column;
gap: 10px;
padding-left: 20px;
padding-top: 10px;
}
#simpleSettings {
margin-bottom: 10px;
}
#engineSettings {
#simpleSettings, #hardwareConstraints, #engineSettings {
margin-bottom: 10px;
}