Consider state conditions in product transition generation
All checks were successful
E2E Testing / test (push) Successful in 1m29s
All checks were successful
E2E Testing / test (push) Successful in 1m29s
This commit is contained in:
parent
b488049c28
commit
777cf9bc1d
@ -7,6 +7,7 @@ import {SimpleState} from "./states/SimpleState";
|
|||||||
import {SimpleGamesystem} from "./SimpleGamesystem";
|
import {SimpleGamesystem} from "./SimpleGamesystem";
|
||||||
import {GameModel} from "../GameModel";
|
import {GameModel} from "../GameModel";
|
||||||
import {ProductStateTrainer} from "../../../../e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer";
|
import {ProductStateTrainer} from "../../../../e2e/game-model/gamesystems/productGamesystems/ProductStateTrainer";
|
||||||
|
import {ScriptAccountCondition} from "./conditions/ScriptAccountCondition";
|
||||||
|
|
||||||
export class ProductGamesystem extends Gamesystem<ProductState, ProductTransition> {
|
export class ProductGamesystem extends Gamesystem<ProductState, ProductTransition> {
|
||||||
|
|
||||||
@ -99,32 +100,52 @@ export class ProductGamesystem extends Gamesystem<ProductState, ProductTransitio
|
|||||||
for(let i=0; i<leftState.outgoingTransitions.length; i++) {
|
for(let i=0; i<leftState.outgoingTransitions.length; i++) {
|
||||||
for(let j=0; j<rightState.outgoingTransitions.length; j++) {
|
for(let j=0; j<rightState.outgoingTransitions.length; j++) {
|
||||||
const startingState = productGamesystem.generateBinaryProductState(leftState, rightState, left_temp);
|
const startingState = productGamesystem.generateBinaryProductState(leftState, rightState, left_temp);
|
||||||
|
|
||||||
|
if(startingState != undefined) {
|
||||||
const endingState_right = productGamesystem.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, left_temp);
|
const endingState_right = productGamesystem.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, left_temp);
|
||||||
|
if(endingState_right != undefined) {
|
||||||
const transition_right = productGamesystem.createTransition(startingState, endingState_right)!;
|
const transition_right = productGamesystem.createTransition(startingState, endingState_right)!;
|
||||||
|
}
|
||||||
|
|
||||||
const endingState_left = productGamesystem.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, left_temp);
|
const endingState_left = productGamesystem.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, left_temp);
|
||||||
|
if(endingState_left != undefined) {
|
||||||
const transition_left = productGamesystem.createTransition(startingState, endingState_left)!;
|
const transition_left = productGamesystem.createTransition(startingState, endingState_left)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const endingState_left_right = productGamesystem.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState.outgoingTransitions[j].endingState, left_temp);
|
const endingState_left_right = productGamesystem.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState.outgoingTransitions[j].endingState, left_temp);
|
||||||
|
if(endingState_left_right != undefined) {
|
||||||
const transition_left_right = productGamesystem.createTransition(startingState, endingState_left_right)!;
|
const transition_left_right = productGamesystem.createTransition(startingState, endingState_left_right)!;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if(rightState.outgoingTransitions.length == 0) {
|
if(rightState.outgoingTransitions.length == 0) {
|
||||||
const startingState = productGamesystem.generateBinaryProductState(leftState, rightState, left_temp);
|
const startingState = productGamesystem.generateBinaryProductState(leftState, rightState, left_temp);
|
||||||
const endingState = productGamesystem.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, left_temp);
|
const endingState = productGamesystem.generateBinaryProductState(leftState.outgoingTransitions[i].endingState, rightState, left_temp);
|
||||||
|
|
||||||
|
if(startingState != undefined && endingState != undefined) {
|
||||||
const transition = productGamesystem.createTransition(startingState, endingState);
|
const transition = productGamesystem.createTransition(startingState, endingState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(leftState.outgoingTransitions.length == 0) {
|
if(leftState.outgoingTransitions.length == 0) {
|
||||||
for(let j=0; j<rightState.outgoingTransitions.length; j++) {
|
for(let j=0; j<rightState.outgoingTransitions.length; j++) {
|
||||||
const startingState = productGamesystem.generateBinaryProductState(leftState, rightState, left_temp);
|
const startingState = productGamesystem.generateBinaryProductState(leftState, rightState, left_temp);
|
||||||
const endingState = productGamesystem.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, left_temp);
|
const endingState = productGamesystem.generateBinaryProductState(leftState, rightState.outgoingTransitions[j].endingState, left_temp);
|
||||||
|
|
||||||
|
if(startingState != undefined && endingState != undefined) {
|
||||||
const transition = productGamesystem.createTransition(startingState, endingState);
|
const transition = productGamesystem.createTransition(startingState, endingState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
return productGamesystem;
|
return productGamesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +167,17 @@ export class ProductGamesystem extends Gamesystem<ProductState, ProductTransitio
|
|||||||
|
|
||||||
let productInitial = true;
|
let productInitial = true;
|
||||||
binary_productState.innerStates.forEach(innerState => productInitial = productInitial && innerState.initial)
|
binary_productState.innerStates.forEach(innerState => productInitial = productInitial && innerState.initial)
|
||||||
|
binary_productState!.initial = productInitial
|
||||||
|
|
||||||
|
const combinedStateConditions: ScriptAccountCondition[] = leftInnerState.conditions.concat(rightInnerState.conditions)
|
||||||
|
const conditionsContradicting = false
|
||||||
|
for(let i=0; i<combinedStateConditions.length; i++) {
|
||||||
|
for(let j=0; j<combinedStateConditions.length; j++) {
|
||||||
|
if(combinedStateConditions[i].isContradicting(combinedStateConditions[j])) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return binary_productState!;
|
return binary_productState!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
80
testModel/gamesystems/Weathersystem/Season.json
Normal file
80
testModel/gamesystems/Weathersystem/Season.json
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
{
|
||||||
|
"componentName": "Season",
|
||||||
|
"componentDescription": "Ein simples Gamesystem zur Modellierung verschiedener Jahreszeiten und deren Übergänge",
|
||||||
|
"states": [
|
||||||
|
{
|
||||||
|
"initial": true,
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"scriptAccount": "Temperature",
|
||||||
|
"minValue": 0,
|
||||||
|
"maxValue": "10"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateLabel": "Frühling",
|
||||||
|
"stateDescription": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"initial": false,
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"scriptAccount": "Temperature",
|
||||||
|
"minValue": "10",
|
||||||
|
"maxValue": "30"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateLabel": "Sommer",
|
||||||
|
"stateDescription": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"initial": false,
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"scriptAccount": "Temperature",
|
||||||
|
"minValue": "10",
|
||||||
|
"maxValue": "20"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateLabel": "Herbst",
|
||||||
|
"stateDescription": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"initial": false,
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"scriptAccount": "Temperature",
|
||||||
|
"minValue": "-10",
|
||||||
|
"maxValue": "10"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateLabel": "Winter",
|
||||||
|
"stateDescription": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"transitions": [
|
||||||
|
{
|
||||||
|
"scriptAccountActions": [],
|
||||||
|
"scriptAccountConditions": [],
|
||||||
|
"startingState": "Frühling",
|
||||||
|
"endingState": "Sommer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scriptAccountActions": [],
|
||||||
|
"scriptAccountConditions": [],
|
||||||
|
"startingState": "Sommer",
|
||||||
|
"endingState": "Herbst"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scriptAccountActions": [],
|
||||||
|
"scriptAccountConditions": [],
|
||||||
|
"startingState": "Herbst",
|
||||||
|
"endingState": "Winter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scriptAccountActions": [],
|
||||||
|
"scriptAccountConditions": [],
|
||||||
|
"startingState": "Winter",
|
||||||
|
"endingState": "Frühling"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
"componentDescription": "A small Gamesystem about local weather events",
|
"componentDescription": "A small Gamesystem about local weather events",
|
||||||
"states": [
|
"states": [
|
||||||
{
|
{
|
||||||
"initial": false,
|
"initial": true,
|
||||||
"conditions": [],
|
"conditions": [],
|
||||||
"stateLabel": "Sonne",
|
"stateLabel": "Sonne",
|
||||||
"stateDescription": ""
|
"stateDescription": ""
|
||||||
|
Loading…
Reference in New Issue
Block a user