Skip to content

Commit

Permalink
Merge pull request #222 from Phuire-Research/Consistency
Browse files Browse the repository at this point in the history
v0.1.69
  • Loading branch information
REllEK-IO committed May 15, 2024
2 parents 6fecc00 + 2af21c4 commit 3a7a0dd
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 14 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/concepts/axium/axium.principle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ export const axiumPrinciple: PrincipleFunction = (
failureNode: null
}),
failureNode: null
})
}),
priority: Infinity
})));
};
/*#>*/
1 change: 1 addition & 0 deletions src/concepts/axium/strategies/addConcept.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export function addConceptsFromQueThenUnblockStrategy(conceptualSet: Concepts):
const params: ActionStrategyParameters = {
topic: addConceptsFromQueThenUnblockTopic,
initialNode: stepOne,
priority: Infinity
};

return createStrategy(params);
Expand Down
1 change: 1 addition & 0 deletions src/concepts/axium/strategies/initialization.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function initializationStrategy(concepts: Concepts): ActionStrategy {
const params: ActionStrategyParameters = {
topic: initializeTopic,
initialNode: stepOne,
priority: Infinity
};

return createStrategy(params);
Expand Down
1 change: 1 addition & 0 deletions src/concepts/axium/strategies/removeConcept.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export function removeConceptsViaQueThenUnblockStrategy(concepts: Concepts): Act
const params: ActionStrategyParameters = {
topic: removeConceptsViaQueThenUnblockTopic,
initialNode: stepOne,
priority: Infinity
};

return createStrategy(params);
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 3 additions & 4 deletions src/model/axium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -61,7 +61,6 @@ export const blockingMethodSubscription = (concepts: Concepts, tail: Action[], a
} else {
tail.push(action);
}
tail.push(action);
}
};

Expand All @@ -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, () => {
Expand Down
2 changes: 1 addition & 1 deletion src/model/selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export function selectState<T>(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 {
Expand Down
6 changes: 5 additions & 1 deletion src/test/addConcepts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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<CounterState>(concepts, counterName);
console.log('SHOULD HIT, but isn\'t');
expect(counter?.count).toBe(1);
setTimeout(() => {done();}, 500);
plan.conclude();
Expand Down
4 changes: 2 additions & 2 deletions src/test/beatSelectorChanges/beatSelectorChanges.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
});
Expand Down
1 change: 1 addition & 0 deletions src/test/onChange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/test/setStageOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down
3 changes: 3 additions & 0 deletions src/test/strategyPriority.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
[
Expand Down

0 comments on commit 3a7a0dd

Please sign in to comment.