Skip to content

Commit

Permalink
Merge pull request #246 from Phuire-Research/Refinement
Browse files Browse the repository at this point in the history
Restored Bad Action Functionality 2.46
  • Loading branch information
REllEK-IO authored Jan 7, 2025
2 parents 31df8c6 + d77733b commit d4f5984
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ When in doubt simplify.
* [Muxified Turing Machine](https://github.com/Phuire-Research/Stratimux/blob/main/The-Muxified-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
### Verbose Bad Actions 0.2.46
* The Muxium Bad Action Quality is now being utilized and setting the muxium's bad action property as intended.
### Restored Dialog Functionality 0.2.44
* Moved the handling of the decision action node notes to the consumer function itself.
### QoL 0.2.42
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.2.44",
"version": "0.2.46",
"description": "Muxified Turing Machine",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
23 changes: 16 additions & 7 deletions src/concepts/muxium/muxium.mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,21 @@ $>*/
import { Subject } from 'rxjs';
import { ActionDeck, Concepts, Mode } from '../../model/concept/concept.type';
import { primeAction } from '../../model/action/action';
import { MuxiumState } from './muxium.concept';
import { MuxiumDeck, MuxiumState } from './muxium.concept';
import { MuxifiedSubject } from '../../model/stagePlanner/stagePlanner';
import { getMuxiumState } from '../../model/muxium/muxiumHelpers';
import { MuxiumBadActionPayload } from './qualities';
import { updateAtomicSelects } from '../../model/selector/selectorAdvanced';
import { Deck } from '../../model/deck';
import { accessDeck, Deck } from '../../model/deck';
import { Action, AnyAction } from '../../model/action/action.type';

export const isActionable = (muxiumState: MuxiumState<any, any>, action: Action): boolean => {
let actionable = true;
// We are logically determining these semaphore values by hand for now.
if (
// Logical Determination: muxiumBadActionType
action.semaphore[3] === 1 ||
// Logical Determination: muxiumConcludeType
action.semaphore[3] === 3) {
actionable = false;
if (muxiumState.logging && action.semaphore[3] === 1) {
console.warn('Bad Action', action);
}
}
return actionable;
};
Expand Down Expand Up @@ -73,6 +68,13 @@ export const permissiveMode: Mode = (
} else {
blockingMode([action, concepts, action$, concepts$]);
}
} else if (action.semaphore[3] !== 3) {
const badAction = accessDeck<MuxiumDeck>(concepts).muxium.e.muxiumBadAction({
badActions: [
action
]
});
action$.next(badAction as unknown as Action);
}
};

Expand Down Expand Up @@ -122,6 +124,13 @@ export const blockingMode: Mode = (
]);
}
}
} else if (action.semaphore[3] !== 3) {
const badAction = accessDeck<MuxiumDeck>(concepts).muxium.e.muxiumBadAction({
badActions: [
action
]
});
action$.next(badAction as unknown as Action);
}
};
/*#>*/
2 changes: 1 addition & 1 deletion src/concepts/muxium/qualities/badAction.quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const muxiumBadAction = createQualityCardWithPayload<MuxiumState<unknown,
reducer: (state, action) => {
const payload = action.payload.badActions;
if (state.logging) {
console.log('Muxium Received a Bad Action: ', action);
console.log('Muxium Received a Bad Action: ', action, payload);
}
return {
badActions: [
Expand Down
30 changes: 30 additions & 0 deletions src/test/badActions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*<$
For the asynchronous graph programming framework Stratimux, generate a test to demonstrate the effectiveness of semaphores and bad actions.
$>*/
/*<#*/
import { createCounterConcept } from '../concepts/counter/counter.concept';
import { createAction } from '../model/action/action';
import { muxification } from '../model/muxium/muxium';

test('Test bad actions functionality', (done) => {
const muxium = muxification('Mock Muxium', {counter: createCounterConcept()}, {
logging: true
});
muxium.plan('Check Concepts', ({stage, stageO, d__}) => [
stageO(() => d__.muxium.e.muxiumKick()),
stage(({dispatch}) => {
dispatch(createAction('Will be a bad action'), {
iterateStage: true
});
}),
stage(({concepts, k, stagePlanner}) => {
expect(k.badActions.select().length).toBe(1);
stagePlanner.conclude();
setTimeout(() => {
done();
}, 500);
})
]);
});

/*#>*/

0 comments on commit d4f5984

Please sign in to comment.