From 1ca8a4c710804926abed3f99a818b36e5b1b4492 Mon Sep 17 00:00:00 2001 From: REllEK-IO Date: Wed, 15 May 2024 09:41:58 -0700 Subject: [PATCH 1/2] Refinment --- src/test/strategyPriority.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/strategyPriority.test.ts b/src/test/strategyPriority.test.ts index 1ce897c..2995617 100644 --- a/src/test/strategyPriority.test.ts +++ b/src/test/strategyPriority.test.ts @@ -17,10 +17,13 @@ import { handlePriority } from '../model/priority'; test('Axium Counting Strategy Priority Test', (done) => { const concluded = [false, false, false]; const [count1, strategy1] = generateRandomCountingStrategy(0); + strategy1.topic += 1; strategy1.priority = 100; const [count2, strategy2] = generateRandomCountingStrategy(0); + strategy1.topic += 2; const [count3, strategy3] = generateRandomCountingStrategy(0); strategy3.priority = 50; + strategy1.topic += 3; const axium = createAxium('axiumStrategyTest', [createCounterConcept()], {logging: true, storeDialog: true}); const plan = axium.plan('Counting Strategy with Priority Plan', [ From 2af21c43e27694ef95b7d0fbac309e58cbce3302 Mon Sep 17 00:00:00 2001 From: REllEK-IO Date: Wed, 15 May 2024 10:17:33 -0700 Subject: [PATCH 2/2] v0.1.69 --- README.md | 4 ++++ package.json | 2 +- src/concepts/axium/axium.principle.ts | 3 ++- src/concepts/axium/strategies/addConcept.strategy.ts | 1 + src/concepts/axium/strategies/initialization.strategy.ts | 1 + src/concepts/axium/strategies/removeConcept.strategy.ts | 1 + src/index.ts | 2 +- src/model/axium.ts | 7 +++---- src/model/selector.ts | 2 +- src/test/addConcepts.test.ts | 6 +++++- src/test/beatSelectorChanges/beatSelectorChanges.test.ts | 4 ++-- src/test/onChange.test.ts | 1 + src/test/setStageOptions.test.ts | 6 +++--- 13 files changed, 26 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 40f5ed5..d6999ed 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,10 @@ When in doubt simplify. * [Unified Turing Machine](https://github.com/Phuire-Research/Stratimux/blob/main/The-Unified-Turing-Machine.md) - The governing concept for this entire framework. ## Change Log ![Tests](https://github.com/Phuire-Research/Stratimux/actions/workflows/node.js.yml/badge.svg) +### v0.1.69 5/15/2024 +* Added priority to axium strategies. +* Improved consistency of logic due the above change. +* Exported **isAxiumOpen** helper function. ### Strategy Priority v0.1.68 5/15/2024 * Added priority to strategies, this priority will be assigned to each step issued by such. * With this change you may now have strategies jump all lines upon creation, ensuring some change prior to other action's taking effect. diff --git a/package.json b/package.json index b10513a..0d5beba 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "stratimux", "license": "GPL-3.0", - "version": "0.1.68", + "version": "0.1.69", "description": "Unified Turing Machine", "main": "dist/index.js", "module": "dist/index.mjs", diff --git a/src/concepts/axium/axium.principle.ts b/src/concepts/axium/axium.principle.ts index b1ddfd9..fb61d55 100644 --- a/src/concepts/axium/axium.principle.ts +++ b/src/concepts/axium/axium.principle.ts @@ -180,7 +180,8 @@ export const axiumPrinciple: PrincipleFunction = ( failureNode: null }), failureNode: null - }) + }), + priority: Infinity }))); }; /*#>*/ \ No newline at end of file diff --git a/src/concepts/axium/strategies/addConcept.strategy.ts b/src/concepts/axium/strategies/addConcept.strategy.ts index d739108..98b5171 100644 --- a/src/concepts/axium/strategies/addConcept.strategy.ts +++ b/src/concepts/axium/strategies/addConcept.strategy.ts @@ -70,6 +70,7 @@ export function addConceptsFromQueThenUnblockStrategy(conceptualSet: Concepts): const params: ActionStrategyParameters = { topic: addConceptsFromQueThenUnblockTopic, initialNode: stepOne, + priority: Infinity }; return createStrategy(params); diff --git a/src/concepts/axium/strategies/initialization.strategy.ts b/src/concepts/axium/strategies/initialization.strategy.ts index a27c918..60ff7e7 100644 --- a/src/concepts/axium/strategies/initialization.strategy.ts +++ b/src/concepts/axium/strategies/initialization.strategy.ts @@ -43,6 +43,7 @@ export function initializationStrategy(concepts: Concepts): ActionStrategy { const params: ActionStrategyParameters = { topic: initializeTopic, initialNode: stepOne, + priority: Infinity }; return createStrategy(params); diff --git a/src/concepts/axium/strategies/removeConcept.strategy.ts b/src/concepts/axium/strategies/removeConcept.strategy.ts index 04bfb68..6216673 100644 --- a/src/concepts/axium/strategies/removeConcept.strategy.ts +++ b/src/concepts/axium/strategies/removeConcept.strategy.ts @@ -63,6 +63,7 @@ export function removeConceptsViaQueThenUnblockStrategy(concepts: Concepts): Act const params: ActionStrategyParameters = { topic: removeConceptsViaQueThenUnblockTopic, initialNode: stepOne, + priority: Infinity }; return createStrategy(params); diff --git a/src/index.ts b/src/index.ts index 388e829..e9d56db 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ For the asynchronous graph programming framework Stratimux, define the current index file that exports all public functionality for the framework as a module. $>*/ /*<#*/ -export { createAxium, getAxiumState, Axium } from './model/axium'; +export { createAxium, getAxiumState, Axium, isAxiumOpen } from './model/axium'; export type { ActionNode, ActionNotes, diff --git a/src/model/axium.ts b/src/model/axium.ts index 2fa7a2e..1d4f869 100644 --- a/src/model/axium.ts +++ b/src/model/axium.ts @@ -43,13 +43,13 @@ export const blockingMethodSubscription = (concepts: Concepts, tail: Action[], a strategyData: action.strategy.data, }); if (isPriorityValid(action)) { + appendToDialog.priority = action.priority; const state = getAxiumState(concepts); handlePriority(state, action); - appendToDialog.priority = action.priority; handlePriority(state, appendToDialog); } else { - tail.push(appendToDialog); tail.push(action); + tail.push(appendToDialog); } } else if ( action.strategy && @@ -61,7 +61,6 @@ export const blockingMethodSubscription = (concepts: Concepts, tail: Action[], a } else { tail.push(action); } - tail.push(action); } }; @@ -84,8 +83,8 @@ export const defaultMethodSubscription = (concepts: Concepts, tail: Action[], ac appendToDialog.priority = action.priority; handlePriority(state, appendToDialog); } else { - tail.push(appendToDialog); tail.push(action); + tail.push(appendToDialog); } if (async) { axiumTimeOut(concepts, () => { diff --git a/src/model/selector.ts b/src/model/selector.ts index 4c5dc4e..223a34f 100644 --- a/src/model/selector.ts +++ b/src/model/selector.ts @@ -208,7 +208,7 @@ export function selectState(concepts: Concepts, name: string): T | undefined const length = conceptKeys.length; const select = (index: number): T | undefined => { if (concepts[conceptKeys[index]].name === name) { - return concepts[index].state as T; + return concepts[conceptKeys[index]].state as T; } else if (index < length - 1) { return select(index + 1); } else { diff --git a/src/test/addConcepts.test.ts b/src/test/addConcepts.test.ts index 8961696..a0acf3e 100644 --- a/src/test/addConcepts.test.ts +++ b/src/test/addConcepts.test.ts @@ -10,12 +10,14 @@ import { addConceptsToAddQueThenBlockStrategy } from '../concepts/axium/strategi import { AxiumState } from '../concepts/axium/axium.concept'; import { countingTopic } from '../concepts/counter/strategies/counting.strategy'; import { forEachConcept } from '../model/concept'; -import { createStage } from '../model/stagePlanner'; +import { createStage, stageWaitForOpenThenIterate } from '../model/stagePlanner'; import { axiumSelectOpen } from '../concepts/axium/axium.selector'; +import { axiumKick } from '../concepts/axium/qualities/kick.quality'; test('Axium add Concepts Strategy Test', (done) => { const axium = createAxium('axiumAddConceptTest',[], {logging: true, storeDialog: true}); const plan = axium.plan('Add Concepts Stage',[ + stageWaitForOpenThenIterate(() => axiumKick()), createStage((concepts, dispatch) => { console.log('Add Counter Concept'); dispatch( @@ -48,7 +50,9 @@ test('Axium add Concepts Strategy Test', (done) => { const axiumState = concepts[0].state as AxiumState; console.log('Check for final counting topic', axiumState.lastStrategy, concepts[1]?.state); if (axiumState.lastStrategy === countingTopic) { + console.log('CHECK CONCEPTS', concepts); const counter = selectState(concepts, counterName); + console.log('SHOULD HIT, but isn\'t'); expect(counter?.count).toBe(1); setTimeout(() => {done();}, 500); plan.conclude(); diff --git a/src/test/beatSelectorChanges/beatSelectorChanges.test.ts b/src/test/beatSelectorChanges/beatSelectorChanges.test.ts index a443a73..15e4482 100644 --- a/src/test/beatSelectorChanges/beatSelectorChanges.test.ts +++ b/src/test/beatSelectorChanges/beatSelectorChanges.test.ts @@ -3,7 +3,7 @@ For the asynchronous graph programming framework Stratimux generate a test that utilizing the provided BeatSelectorChanges concept $>*/ /*<#*/ -import { createAxium, getAxiumState } from '../../model/axium'; +import { createAxium, getAxiumState, isAxiumOpen } from '../../model/axium'; import { createStage } from '../../model/stagePlanner'; import { generateRandomCountingStrategy } from './strategies/generateCountingStrategy.strategy'; import { beatSelectorChangesName, createBeatSelectorChangesConcept } from './beatSelectorChanges.concept'; @@ -28,7 +28,7 @@ test('Deferred Beat Selector Changes Test', (done) => { ]); const plan = axium.plan('Prolonged Counting Strategy', [ createStage((concepts, dispatch) => { - if (getAxiumState(concepts).lastStrategy === initializeTopic) { + if (isAxiumOpen(concepts)) { dispatch(strategyBegin(strategy), { iterateStage: true }); diff --git a/src/test/onChange.test.ts b/src/test/onChange.test.ts index 36eea08..6fdeb3c 100644 --- a/src/test/onChange.test.ts +++ b/src/test/onChange.test.ts @@ -25,6 +25,7 @@ test('Axium onChange Test', (done) => { const plan = axium.plan('Counting Strategy Plan with selectors', [ createStage((concepts, dispatch) => { + console.log('WHAT IS THIS', selectSlice(concepts, axiumSelectLastStrategy)); if (selectSlice(concepts, axiumSelectLastStrategy) === initializeTopic) { dispatch(strategyBegin(countingStrategy()), { iterateStage: true diff --git a/src/test/setStageOptions.test.ts b/src/test/setStageOptions.test.ts index 2df50c6..b77e3e1 100644 --- a/src/test/setStageOptions.test.ts +++ b/src/test/setStageOptions.test.ts @@ -2,7 +2,7 @@ For the asynchronous graph programming framework Stratimux, generate a test that the setStageOption derivatives.are functioning as intended $>*/ /*<#*/ -import { createAxium } from '../model/axium'; +import { createAxium, isAxiumOpen } from '../model/axium'; import { strategyBegin } from '../model/actionStrategy'; import { selectSlice, selectState } from '../model/selector'; import { CounterState, createCounterConcept, countingStrategy, counterName } from '../concepts/counter/counter.concept'; @@ -19,7 +19,7 @@ test('Axium setStageSelectors Test', (done) => { const plan = axium.plan('Counting Strategy Plan using setStageSelectors', [ createStage((concepts, dispatch) => { - if (selectSlice(concepts, axiumSelectLastStrategy) === initializeTopic) { + if (isAxiumOpen(concepts)) { dispatch(strategyBegin(countingStrategy()), { iterateStage: true, setStageSelectors: { @@ -54,7 +54,7 @@ test('Axium setStageBeat Test', (done) => { const plan = axium.plan('Counting Strategy Plan using setStageBeat', [ createStage((concepts, dispatch) => { - if (selectSlice(concepts, axiumSelectLastStrategy) === initializeTopic) { + if (isAxiumOpen(concepts)) { dispatch(strategyBegin(countingStrategy()), { iterateStage: true, setStageBeat: {