Fix (hopefully) duplicate transitions inside generated gamesystems
Some checks failed
E2E Testing / test (push) Failing after 1m31s
Some checks failed
E2E Testing / test (push) Failing after 1m31s
This commit is contained in:
parent
de5b622e6d
commit
9c20f169c6
@ -64,22 +64,17 @@ export abstract class AbstractProductGamesystemGenerator {
|
|||||||
if(startingState != undefined) {
|
if(startingState != undefined) {
|
||||||
const endingState_right = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
|
const endingState_right = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
|
||||||
if(endingState_right != undefined) {
|
if(endingState_right != undefined) {
|
||||||
const transition_right = this.generateBinaryProductTransition(startingState, endingState_right, rightState.outgoingTransitions[j])
|
this.generateBinaryProductTransition(startingState, endingState_right, rightState.outgoingTransitions[j], generatedProductTransitions);
|
||||||
generatedProductTransitions.push(transition_right)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const endingState_left = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates);
|
const endingState_left = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates);
|
||||||
if(endingState_left != undefined) {
|
if(endingState_left != undefined) {
|
||||||
const transition = this.generateBinaryProductTransition(startingState, endingState_left, leftState.outgoingTransitions[i])
|
this.generateBinaryProductTransition(startingState, endingState_left, leftState.outgoingTransitions[i], generatedProductTransitions)
|
||||||
generatedProductTransitions.push(transition)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const endingState_left_right = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
|
const endingState_left_right = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
|
||||||
if(endingState_left_right != undefined) {
|
if(endingState_left_right != undefined) {
|
||||||
const transition = this.generateBinaryProductTransitionMulti(startingState, endingState_left_right, leftState.outgoingTransitions[i], rightState.outgoingTransitions[j]);
|
this.generateBinaryProductTransitionMulti(startingState, endingState_left_right, leftState.outgoingTransitions[i], rightState.outgoingTransitions[j], generatedProductTransitions);
|
||||||
if(transition != undefined) {
|
|
||||||
generatedProductTransitions.push(transition);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,8 +84,8 @@ export abstract class AbstractProductGamesystemGenerator {
|
|||||||
const endingState = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates);
|
const endingState = this.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, generatedProductStates);
|
||||||
|
|
||||||
if(startingState != undefined && endingState != undefined) {
|
if(startingState != undefined && endingState != undefined) {
|
||||||
const transition = this.generateBinaryProductTransition(startingState, endingState, leftState.outgoingTransitions[i])
|
this.generateBinaryProductTransition(startingState, endingState, leftState.outgoingTransitions[i], generatedProductTransitions)
|
||||||
generatedProductTransitions.push(transition)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,8 +96,8 @@ export abstract class AbstractProductGamesystemGenerator {
|
|||||||
const endingState = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
|
const endingState = this.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, generatedProductStates);
|
||||||
|
|
||||||
if(startingState != undefined && endingState != undefined) {
|
if(startingState != undefined && endingState != undefined) {
|
||||||
const transition = this.generateBinaryProductTransition(startingState, endingState, rightState.outgoingTransitions[j]);
|
this.generateBinaryProductTransition(startingState, endingState, rightState.outgoingTransitions[j], generatedProductTransitions);
|
||||||
generatedProductTransitions.push(transition)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -113,9 +108,9 @@ export abstract class AbstractProductGamesystemGenerator {
|
|||||||
return new ProductGeneratorResult(generatedProductStates, generatedProductTransitions);
|
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
|
protected abstract generateBinaryProductState(leftState: State<any>, rightState: State<any>, generadedStates: ProductState[]): ProductState | undefined
|
||||||
|
|
||||||
|
@ -13,15 +13,17 @@ import {AbstractProductGamesystemGenerator} from "./AbstractProductGamesystemGen
|
|||||||
export class ProductGamesystemGenerator extends AbstractProductGamesystemGenerator{
|
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);
|
const transition = new ProductTransition(startingState, endingState);
|
||||||
transition.scriptAccountActions = [... usedTransition.scriptAccountActions];
|
transition.scriptAccountActions = [... usedTransition.scriptAccountActions];
|
||||||
transition.scriptAccountConditions = [... usedTransition.scriptAccountConditions];
|
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 leftConditions = leftTransition.scriptAccountConditions;
|
||||||
const rightConditions = rightTransition.scriptAccountConditions;
|
const rightConditions = rightTransition.scriptAccountConditions;
|
||||||
|
|
||||||
|
@ -57,4 +57,8 @@ export abstract class Transition<S extends State<any>> {
|
|||||||
findScriptAccountConditionByScriptAccount(scriptAccount: ScriptAccount): ScriptAccountCondition | undefined {
|
findScriptAccountConditionByScriptAccount(scriptAccount: ScriptAccount): ScriptAccountCondition | undefined {
|
||||||
return this.scriptAccountConditions.find(condition => condition.scriptAccount === scriptAccount);
|
return this.scriptAccountConditions.find(condition => condition.scriptAccount === scriptAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
equalsTransition(transition: Transition<any>): boolean {
|
||||||
|
return this.startingState.equals(transition.startingState) && this.endingState.equals(transition.endingState)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user