def createPlayer1(autEnabled): '''createPlayer1(autEnabled) -> Automaton Synthesises a transducer for Player 1 from the Enabled automaton autEnabled. Player 1 nondeterministically chooses one enabled transition (if such exists). ''' enabledTransd = autEnabled.toTransducer() # the transducer for "no transition enabled" noEnabledTransTransd = enabledTransd.renameStates(lambda s: s + '_noEn') noEnabledTransTransd = noEnabledTransTransd.filterTrans( lambda trans: (trans[1], trans[2]) != (SYMBOL_ENABLED, SYMBOL_ENABLED)) noEnabledTransTransd = noEnabledTransTransd.removeUseless() rename1 = lambda state: state + "_en1" rename2 = lambda state: state + "_en2" # the transducer for chosing one enabled transition oneChosenTransTransd1 = enabledTransd.renameStates(rename1) oneChosenTransTransd2 = enabledTransd.renameStates(rename2) oneChosenTransTransd1 = oneChosenTransTransd1.clearAcceptStates() oneChosenTransTransd2 = oneChosenTransTransd2.clearStartStates() oneChosenTransTransdMerged = Automaton.autUnion(oneChosenTransTransd1, oneChosenTransTransd2) for trans in enabledTransd.transitions: fstSymb = Automaton.getSymbol1(trans) sndSymb = Automaton.getSymbol2(trans) if (fstSymb, sndSymb) == (SYMBOL_ENABLED, SYMBOL_ENABLED): oneChosenTransTransdMerged.addTransTransd( rename1(Automaton.getSrcState(trans)), SYMBOL_ENABLED, SYMBOL_CHOSEN, rename2(Automaton.getTgtState(trans))) # result = Automaton.autUnion(oneChosenTransTransdMerged, noEnabledTransTransd) result = oneChosenTransTransdMerged result = result.singleStartState(PLAYER1_START_STATE) return result