Fix (hopefully) duplicate transitions inside generated gamesystems
Some checks failed
E2E Testing / test (push) Failing after 1m31s

This commit is contained in:
Sebastian Böckelmann 2024-04-12 18:28:52 +02:00
parent de5b622e6d
commit 9c20f169c6
3 changed files with 18 additions and 17 deletions

View File

@ -64,22 +64,17 @@ export abstract class AbstractProductGamesystemGenerator {
if(startingState != undefined) {
const endingState_right = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
if(endingState_right != undefined) {
const transition_right = this.generateBinaryProductTransition(startingState, endingState_right, rightState.outgoingTransitions[j])
generatedProductTransitions.push(transition_right)
this.generateBinaryProductTransition(startingState, endingState_right, rightState.outgoingTransitions[j], generatedProductTransitions);
}
const endingState_left = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates);
if(endingState_left != undefined) {
const transition = this.generateBinaryProductTransition(startingState, endingState_left, leftState.outgoingTransitions[i])
generatedProductTransitions.push(transition)
this.generateBinaryProductTransition(startingState, endingState_left, leftState.outgoingTransitions[i], generatedProductTransitions)
}
const endingState_left_right = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
if(endingState_left_right != undefined) {
const transition = this.generateBinaryProductTransitionMulti(startingState, endingState_left_right, leftState.outgoingTransitions[i], rightState.outgoingTransitions[j]);
if(transition != undefined) {
generatedProductTransitions.push(transition);
}
this.generateBinaryProductTransitionMulti(startingState, endingState_left_right, leftState.outgoingTransitions[i], rightState.outgoingTransitions[j], generatedProductTransitions);
}
}
}
@ -89,8 +84,8 @@ export abstract class AbstractProductGamesystemGenerator {
const endingState = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates);
if(startingState != undefined && endingState != undefined) {
const transition = this.generateBinaryProductTransition(startingState, endingState, leftState.outgoingTransitions[i])
generatedProductTransitions.push(transition)
this.generateBinaryProductTransition(startingState, endingState, leftState.outgoingTransitions[i], generatedProductTransitions)
}
}
}
@ -101,8 +96,8 @@ export abstract class AbstractProductGamesystemGenerator {
const endingState = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
if(startingState != undefined && endingState != undefined) {
const transition = this.generateBinaryProductTransition(startingState, endingState, rightState.outgoingTransitions[j]);
generatedProductTransitions.push(transition)
this.generateBinaryProductTransition(startingState, endingState, rightState.outgoingTransitions[j], generatedProductTransitions);
}
}
@ -113,9 +108,9 @@ export abstract class AbstractProductGamesystemGenerator {
return new ProductGeneratorResult(generatedProductStates, generatedProductTransitions);
}
protected abstract generateBinaryProductTransition(leftState: State<any>, rightState: State<any>, usedTransition: Transition<any>): ProductTransition;
protected abstract generateBinaryProductTransition(leftState: State<any>, rightState: State<any>, usedTransition: Transition<any>, generatedTransitions: ProductTransition[]): void;
protected abstract generateBinaryProductTransitionMulti(leftState: State<any>, rightState: State<any>, leftTransition: Transition<any>, rightTransition: Transition<any>): ProductTransition | undefined
protected abstract generateBinaryProductTransitionMulti(leftState: State<any>, rightState: State<any>, leftTransition: Transition<any>, rightTransition: Transition<any>, generatedTransitions: ProductTransition[]): void
protected abstract generateBinaryProductState(leftState: State<any>, rightState: State<any>, generadedStates: ProductState[]): ProductState | undefined

View File

@ -13,15 +13,17 @@ import {AbstractProductGamesystemGenerator} from "./AbstractProductGamesystemGen
export class ProductGamesystemGenerator extends AbstractProductGamesystemGenerator{
protected generateBinaryProductTransition(startingState: ProductState, endingState: ProductState, usedTransition: Transition<any>) {
protected generateBinaryProductTransition(startingState: ProductState, endingState: ProductState, usedTransition: Transition<any>, generatedTransitions: ProductTransition[]) {
const transition = new ProductTransition(startingState, endingState);
transition.scriptAccountActions = [... usedTransition.scriptAccountActions];
transition.scriptAccountConditions = [... usedTransition.scriptAccountConditions];
return transition;
if(generatedTransitions.find(generatedTransition => generatedTransition.equalsTransition(transition)) == undefined) {
generatedTransitions.push(transition)
}
}
protected generateBinaryProductTransitionMulti(startingState: ProductState, endingState: ProductState, leftTransition: Transition<any>, rightTransition: Transition<any>) {
protected generateBinaryProductTransitionMulti(startingState: ProductState, endingState: ProductState, leftTransition: Transition<any>, rightTransition: Transition<any>, generatedTransitions: ProductTransition[]) {
const leftConditions = leftTransition.scriptAccountConditions;
const rightConditions = rightTransition.scriptAccountConditions;

View File

@ -57,4 +57,8 @@ export abstract class Transition<S extends State<any>> {
findScriptAccountConditionByScriptAccount(scriptAccount: ScriptAccount): ScriptAccountCondition | undefined {
return this.scriptAccountConditions.find(condition => condition.scriptAccount === scriptAccount);
}
equalsTransition(transition: Transition<any>): boolean {
return this.startingState.equals(transition.startingState) && this.endingState.equals(transition.endingState)
}
}