fix: fixed the program reduce algorithm to be flexable and correctly use the different phase variables.

ref: N25B-294
This commit is contained in:
Björn Otgaar
2025-11-18 18:47:08 +01:00
parent 0bbb6101ae
commit bb4e9d0b26
7 changed files with 128 additions and 56 deletions

View File

@@ -1,6 +1,6 @@
import StartNode, { StartConnects, StartReduce } from "./nodes/StartNode";
import EndNode, { EndConnects, EndReduce } from "./nodes/EndNode";
import PhaseNode, { PhaseConnects, PhaseReduce } from "./nodes/PhaseNode";
import PhaseNode, { PhaseConnects, PhaseReduce, PhaseReduce2 } from "./nodes/PhaseNode";
import NormNode, { NormConnects, NormReduce } from "./nodes/NormNode";
import { EndNodeDefaults } from "./nodes/EndNode.default";
import { StartNodeDefaults } from "./nodes/StartNode.default";
@@ -11,6 +11,9 @@ import { GoalNodeDefaults } from "./nodes/GoalNode.default";
import TriggerNode, { TriggerConnects, TriggerReduce } from "./nodes/TriggerNode";
import { TriggerNodeDefaults } from "./nodes/TriggerNode.default";
/**
* The types of the nodes we have registered.
*/
export const NodeTypes = {
start: StartNode,
end: EndNode,
@@ -20,7 +23,9 @@ export const NodeTypes = {
trigger: TriggerNode,
};
// Default node data for creation
/**
* The default functions of the nodes we have registered.
*/
export const NodeDefaults = {
start: StartNodeDefaults,
end: EndNodeDefaults,
@@ -30,15 +35,23 @@ export const NodeDefaults = {
trigger: TriggerNodeDefaults,
};
/**
* The reduce functions of the nodes we have registered.
*/
export const NodeReduces = {
start: StartReduce,
end: EndReduce,
phase: PhaseReduce,
phase: PhaseReduce2,
norm: NormReduce,
goal: GoalReduce,
trigger: TriggerReduce,
}
/**
* The connection functionality of the nodes we have registered.
*/
export const NodeConnects = {
start: StartConnects,
end: EndConnects,
@@ -48,9 +61,21 @@ export const NodeConnects = {
trigger: TriggerConnects,
}
// Function to tell the visual program if we're allowed to delete them...
// Right now it doesn't take in any values, but that could also be done later.
/**
* Functions that define whether a node should be deleted, currently constant only for start and end.
* Any node types that aren't mentioned are 'true', and can be deleted by default.
*/
export const NodeDeletes = {
start: () => false,
end: () => false,
}
/**
* Defines which types are variables in the phase node-
* any node that is NOT mentioned here, is automatically seen as a variable of a phase.
*/
export const NodesInPhase = {
start: () => false,
end: () => false,
phase: () => false,
}