def __init__(self, cr):
     DistributedObject.DistributedObject.__init__(self, cr)
     self.openSfx = base.loadSfx('phase_3.5/audio/sfx/Door_Open_1.mp3')
     self.closeSfx = base.loadSfx('phase_3.5/audio/sfx/Door_Close_1.mp3')
     self.nametag = None
     self.fsm = FSM.FSM('DistributedDoor_right', [
         State.State('off', self.enterOff, self.exitOff,
                     ['closing', 'closed', 'opening', 'open']),
         State.State('closing', self.enterClosing, self.exitClosing,
                     ['closed', 'opening']),
         State.State('closed', self.enterClosed, self.exitClosed,
                     ['opening']),
         State.State('opening', self.enterOpening, self.exitOpening,
                     ['open']),
         State.State('open', self.enterOpen, self.exitOpen,
                     ['closing', 'open'])
     ], 'off', 'off')
     self.fsm.enterInitialState()
     self.exitDoorFSM = FSM.FSM('DistributedDoor_left', [
         State.State('off', self.exitDoorEnterOff, self.exitDoorExitOff,
                     ['closing', 'closed', 'opening', 'open']),
         State.State('closing', self.exitDoorEnterClosing,
                     self.exitDoorExitClosing, ['closed', 'opening']),
         State.State('closed', self.exitDoorEnterClosed,
                     self.exitDoorExitClosed, ['opening']),
         State.State('opening', self.exitDoorEnterOpening,
                     self.exitDoorExitOpening, ['open']),
         State.State('open', self.exitDoorEnterOpen, self.exitDoorExitOpen,
                     ['closing', 'open'])
     ], 'off', 'off')
     self.exitDoorFSM.enterInitialState()
     return
def checkStatus(totalThreatValue):
    global current_state
    global previousTotalThreatValue

    if current_state == "Low":
        thresold = 20
    elif current_state == "Medium":
        thresold = 40
    elif current_state == "High":
        thresold = 60
    elif current_state == "Critical":
        thresold = 80

    if totalThreatValue >= previousTotalThreatValue:
        if current_state != "Critical":
            if totalThreatValue > thresold:
                alarm_action = "rise"
                current_state = FSM.alarm_FSM(current_state, alarm_action)

    else:
        if totalThreatValue < (thresold - 20):
            if thresold == 20:
                current_state = "Low"
            else:
                alarm_action = "decrease"
                current_state = FSM.alarm_FSM(current_state, alarm_action)

    previousTotalThreatValue = totalThreatValue
Exemple #3
0
def runGame():
    playAgain = 'yes'
    while playAgain == 'yes':
        correctInput = False
        while correctInput != True:
            print("------------------------------------------")
            cardGame = input(
                "Choose the game you would like to play:\nChoices: Bartok <----> War <----> My Ship Sails <----> Linger Longer\n"
            ).lower()
            if cardGame == 'bartok':
                correctInput = True
                print("\nBartok is starting up...\nEnjoy your game!")
                print("------------------------------------------\n")
                newGame = FSM.BartokMachine()
            elif cardGame == 'war':
                correctInput = True
                print("\nWar is starting up...\nEnjoy your game!")
                print("------------------------------------------\n")
                newGame = FSM.WarMachine()
            elif cardGame == 'my ship sails':
                correctInput = True
                print("\nMy Ship Sails is starting up...\nEnjoy your game!")
                print("------------------------------------------\n")
                newGame = FSM.MyShipSailsMachine()
            elif cardGame == 'linger longer':
                correctInput = True
                print("\nLinger Longer is starting up...\nEnjoy your game!")
                print("------------------------------------------\n")
                newGame = FSM.LingerLongerMachine()
            else:
                print("Invalid input. Please enter a valid card game.\n")
        playAgain = input(
            "\nWould you like to play another game? (Yes/No)\n").lower()
    print("\nSystem exiting...")
    print("Thank you for playing!")
def checkStatus(totalThreatValue):
    global current_state
    global previousTotalThreatValue

    if current_state == "Low":
        thresold = 20
    elif current_state == "Medium":
        thresold = 40
    elif current_state == "High":
        thresold = 60
    elif current_state == "Critical":
        thresold = 80

    if totalThreatValue >= previousTotalThreatValue:
        if current_state != "Critical":      
            if totalThreatValue > thresold:
                alarm_action = "rise"
                current_state = FSM.alarm_FSM(current_state,alarm_action)

    else:
        if totalThreatValue < (thresold-20):
            if thresold == 20:
                current_state = "Low"
            else:
                alarm_action = "decrease"
                current_state = FSM.alarm_FSM(current_state,alarm_action)
    
    previousTotalThreatValue = totalThreatValue
def simpleTest():
    fsa = buildSourceModel(vocabulary, suffixes)
    fst = buildChannelModel()

    print "==== Trying source model on strings 'ace+ed' ===="
    #was [fsa]
    output = FSM.runFST([fsa], ["ace+ed"])
    print "==== Result: ", str(output), " ===="

    print "==== Trying source model on strings 'panic+ing' ===="
    #was [fsa]
    output = FSM.runFST([fsa], ["panic+ing"])
    print "==== Result: ", str(output), " ===="
    
    #for w in vocabulary:
        #for s in suffixes:
            #analysis = w + s
            #output = FSM.runFST([fsa],[analysis])[0][0]
            #if output != analysis:
                #print "FAILED"
                #sys.exit(1)

    print "==== Generating random paths for 'aced', using only channel model ===="
    output = FSM.runFST([fst], ["aced"], maxNumPaths=10, randomPaths=True)
    print "==== Result: ", str(output), " ===="

    print "==== Generating random paths for 'aced', using only channel model ===="
    output = FSM.runFST([fst], ["panicked"], maxNumPaths=10, randomPaths=True)
    print "==== Result: ", str(output), " ===="

    print "==== Disambiguating a few phrases: aced, panicked, paniced, sprucing ===="
    output = FSM.runFST([fsa,fst], ["aced", "paniced", "panicked", "sprucing"])
    print "==== Result: ", str(output), " ===="
Exemple #6
0
	def __init__(self,size,enemy_list,font):
		self.size=size
		self.font=font
		self.entities={}
		self.bullets={}
		self.champ=None
		self.chapters=[]
		self.bullet_id=0
		self.entity_id=0
		self.background=pygame.surface.Surface(commons.screen_size).convert()
		self.background.fill((200,255,255))
		self.enemy_freq={}
		self.enemy_list=enemy_list
		self.boss=None
		self.status=False #pass or not
		self.FSM=FSM()
		self.time=0
		self.current_chapter=None
		self.clear=False
		self.FSM.add_state(pushing(self))
		self.FSM.add_state(last_enemy(self))
		self.FSM.add_state(complete(self))
		self.FSM.add_state(endless(self))
		self.FSM.add_state(gameover(self))
		self.FSM.add_state(congrats(self))
		self.check_point=0
		self.pannel=None
 def __init__(self, cr):
     DistributedObject.DistributedObject.__init__(self, cr)
     self.countdownTask = None
     self.localToonOnBoard = 0
     self.openSfx = base.loadSfx('phase_5/audio/sfx/elevator_door_open.mp3')
     self.closeSfx = base.loadSfx(
         'phase_5/audio/sfx/elevator_door_close.mp3')
     self.nametag = None
     self.fsm = FSM.FSM('DistributedElevatorExt', [
         State.State('off', self.enterOff, self.exitOff, [
             'opening', 'waitEmpty', 'waitCountdown', 'closing', 'closed'
         ]),
         State.State('opening', self.enterOpening, self.exitOpening,
                     ['waitEmpty']),
         State.State('waitEmpty', self.enterWaitEmpty, self.exitWaitEmpty,
                     ['waitCountdown']),
         State.State('waitCountdown', self.enterWaitCountdown,
                     self.exitWaitCountdown, ['waitEmpty', 'closing']),
         State.State('closing', self.enterClosing, self.exitClosing,
                     ['closed', 'waitEmpty']),
         State.State('closed', self.enterClosed, self.exitClosed,
                     ['opening'])
     ], 'off', 'off')
     self.fsm.enterInitialState()
     self.currentFloor = -1
     self.isSetup = 0
     return None
     return
 def __init__(self, tcr, doneEvent):
     self.notify.debug('__init__')
     StateData.StateData.__init__(self, doneEvent)
     GuiScreen.GuiScreen.__init__(self)
     self.tcr = tcr
     self.loginInterface = self.tcr.loginInterface
     self.allowNewAccounts = tcr.accountServerConstants.getBool(
         'allowNewAccounts')
     self.userName = ''
     self.password = ''
     self.fsm = FSM.FSM('LoginScreen', [
         State.State('off', self.enterOff, self.exitOff,
                     ['login', 'waitForLoginResponse']),
         State.State(
             'login', self.enterLogin, self.exitLogin,
             ['waitForLoginResponse', 'login', 'showLoginFailDialog']),
         State.State('showLoginFailDialog', self.enterShowLoginFailDialog,
                     self.exitShowLoginFailDialog,
                     ['login', 'showLoginFailDialog']),
         State.State('waitForLoginResponse', self.enterWaitForLoginResponse,
                     self.exitWaitForLoginResponse, [
                         'login', 'showLoginFailDialog',
                         'showConnectionProblemDialog'
                     ]),
         State.State('showConnectionProblemDialog',
                     self.enterShowConnectionProblemDialog,
                     self.exitShowConnectionProblemDialog, ['login'])
     ], 'off', 'off')
     self.fsm.enterInitialState()
Exemple #9
0
def button_state_machine():
    """Button toggle state manually for demos state machine"""

    # declare state machine for siren
    bfsm = FSM.FSM ('INIT', [])
    bfsm.set_default_transition (button_up, 'INIT')
    bfsm.add_transition_any  ('INIT', None, 'INIT')

    # initialize
    bfsm.add_transition      ('setOff', 'INIT', button_up, 'BUTTONUP')
    bfsm.add_transition      ('setOn', 'INIT', button_down, 'BUTTONDOWN')

    # on
    bfsm.add_transition      ('setOn', 'BUTTONUP', button_down, 'BUTTONDOWN')
    bfsm.add_transition      ('setOn', 'BUTTONDOWN', button_down, 'BUTTONDOWN')

    # off
    bfsm.add_transition      ('setOff', 'BUTTONUP', button_up, 'BUTTONUP')
    bfsm.add_transition      ('setOff', 'BUTTONDOWN', button_up, 'BUTTONUP')

    # eventloop
    while(1):
        # poll button state
        if (IO.digitalRead(BTNPIN) != 0):
            my_button_next_state = 'setOff'
        else:
            my_button_next_state = 'setOn'
        logging.info("button processing: " + my_button_next_state)
        bfsm.process(my_button_next_state)
 def __init__(self, parentFSM, doneEvent):
     StateData.StateData.__init__(self, doneEvent)
     self.fsm = FSM.FSM('PlayGame', [
         State.State('start', self.enterStart, self.exitStart,
                     ['quietZone']),
         State.State('quietZone', self.enterQuietZone, self.exitQuietZone, [
             'TTHood', 'DDHood', 'BRHood', 'MMHood', 'DGHood', 'DLHood',
             'TutorialHood', 'EstateLoader'
         ]),
         State.State('TTHood', self.enterTTHood, self.exitTTHood,
                     ['quietZone']),
         State.State('DDHood', self.enterDDHood, self.exitDDHood,
                     ['quietZone']),
         State.State('BRHood', self.enterBRHood, self.exitBRHood,
                     ['quietZone']),
         State.State('MMHood', self.enterMMHood, self.exitMMHood,
                     ['quietZone']),
         State.State('DGHood', self.enterDGHood, self.exitDGHood,
                     ['quietZone']),
         State.State('DLHood', self.enterDLHood, self.exitDLHood,
                     ['quietZone']),
         State.State('TutorialHood', self.enterTutorialHood,
                     self.exitTutorialHood, ['quietZone']),
         State.State('EstateLoader', self.enterEstateLoader,
                     self.exitEstateLoader, ['quietZone'])
     ], 'start', 'start')
     self.fsm.enterInitialState()
     self.parentFSM = parentFSM
     self.parentFSM.getStateNamed('playGame').addChild(self.fsm)
     self.hoodDoneEvent = 'hoodDone'
     self.estateLoaderDoneEvent = 'estateLoaderDone'
     self.hood = None
     self.estateLoader = None
 def __init__(self, cr):
     DistributedObject.DistributedObject.__init__(self, cr)
     self.suitDoorOrigin = None
     self.elevatorModel = None
     self.fsm = FSM.FSM('DistributedBuilding', [
         State.State('off', self.enterOff, self.exitOff, [
             'waitForVictors', 'becomingToon', 'toon',
             'clearOutToonInterior', 'becomingSuit', 'suit'
         ]),
         State.State('waitForVictors', self.enterWaitForVictors,
                     self.exitWaitForVictors, ['becomingToon']),
         State.State('becomingToon', self.enterBecomingToon,
                     self.exitBecomingToon, ['toon']),
         State.State('toon', self.enterToon, self.exitToon,
                     ['clearOutToonInterior']),
         State.State('clearOutToonInterior', self.enterClearOutToonInterior,
                     self.exitClearOutToonInterior, ['becomingSuit']),
         State.State('becomingSuit', self.enterBecomingSuit,
                     self.exitBecomingSuit, ['suit']),
         State.State('suit', self.enterSuit, self.exitSuit,
                     ['waitForVictors', 'becomingToon'])
     ], 'off', 'off')
     self.fsm.enterInitialState()
     self.bossLevel = 0
     self.transitionTrack = None
     self.elevatorNodePath = None
     self.victorList = [0, 0, 0, 0]
     self.waitingMessage = None
     self.cogDropSound = None
     self.cogLandSound = None
     self.cogSettleSound = None
     self.cogWeakenSound = None
     self.toonGrowSound = None
     self.toonSettleSound = None
     return
Exemple #12
0
 def __init__(self, parentFSM, doneEvent, dnaStore):
     StateData.StateData.__init__(self, doneEvent)
     self.fsm = FSM.FSM('Hood', [
      State.State('start', self.enterStart, self.exitStart, [
       'townLoader', 'safeZoneLoader']),
      State.State('townLoader', self.enterTownLoader, self.exitTownLoader, [
       'quietZone', 'safeZoneLoader', 'suitInterior']),
      State.State('shop', self.enterShop, self.exitShop, [
       'safeZoneLoader']),
      State.State('safeZoneLoader', self.enterSafeZoneLoader, self.exitSafeZoneLoader, [
       'quietZone', 'suitInterior', 'townLoader', 'shop', 'minigame']),
      State.State('purchase', self.enterPurchase, self.exitPurchase, [
       'quietZone', 'minigame', 'safeZoneLoader']),
      State.State('suitInterior', self.enterSuitInterior, self.exitSuitInterior, [
       'quietZone', 'townLoader', 'safeZoneLoader']),
      State.State('minigame', self.enterMinigame, self.exitMinigame, [
       'purchase']),
      State.State('quietZone', self.enterQuietZone, self.exitQuietZone, [
       'safeZoneLoader', 'townLoader', 'suitInterior', 'minigame']),
      State.State('final', self.enterFinal, self.exitFinal, [])], 'start', 'final')
     self.fsm.enterInitialState()
     self.parentFSM = parentFSM
     self.dnaStore = dnaStore
     self.loaderDoneEvent = 'loaderDone'
     self.suitInteriorDoneEvent = 'suitInteriorDone'
     self.minigameDoneEvent = 'minigameDone'
     self.id = None
     self.titleText = None
     self.titleColor = (
      1, 1, 1, 1)
     return
Exemple #13
0
 def __init__(self, elevatorState, doneEvent, distElevator):
     StateData.StateData.__init__(self, doneEvent)
     self.fsm = FSM.FSM('Elevator', [
         State.State('start', self.enterStart, self.exitStart,
                     ['elevatorDFA']),
         State.State('elevatorDFA', self.enterElevatorDFA,
                     self.exitElevatorDFA, ['requestBoard', 'final']),
         State.State('requestBoard', self.enterRequestBoard,
                     self.exitRequestBoard, ['boarding']),
         State.State('boarding', self.enterBoarding, self.exitBoarding,
                     ['boarded']),
         State.State('boarded', self.enterBoarded, self.exitBoarded,
                     ['requestExit', 'elevatorClosing', 'final']),
         State.State('requestExit', self.enterRequestExit,
                     self.exitRequestExit, ['exiting', 'elevatorClosing']),
         State.State('elevatorClosing', self.enterElevatorClosing,
                     self.exitElevatorClosing, ['final']),
         State.State('exiting', self.enterExiting, self.exitExiting,
                     ['final']),
         State.State('final', self.enterFinal, self.exitFinal, ['start'])
     ], 'start', 'final')
     self.dfaDoneEvent = 'elevatorDfaDoneEvent'
     self.elevatorState = elevatorState
     self.distElevator = distElevator
     return None
     return
Exemple #14
0
 def __init__(self, cr):
     DistributedMinigame.__init__(self, cr)
     self.gameFSM = FSM.FSM('DistributedRaceGame', [
         State.State('off', self.enterOff, self.exitOff, [
             'inputChoice']),
         State.State('inputChoice', self.enterInputChoice, self.exitInputChoice, [
             'waitServerChoices',
             'moveAvatars',
             'cleanup']),
         State.State('waitServerChoices', self.enterWaitServerChoices, self.exitWaitServerChoices, [
             'moveAvatars',
             'cleanup']),
         State.State('moveAvatars', self.enterMoveAvatars, self.exitMoveAvatars, [
             'inputChoice',
             'winMovie',
             'cleanup']),
         State.State('winMovie', self.enterWinMovie, self.exitWinMovie, [
             'cleanup']),
         State.State('cleanup', self.enterCleanup, self.exitCleanup, [])], 'off', 'cleanup')
     self.addChildGameFSM(self.gameFSM)
     self.posHprArray = (((-9.0299999999999994, 0.059999999999999998, 0.025000000000000001, -152.90000000000001), (-7.4299999999999997, -2.7599999999999998, 0.025000000000000001, -152.68000000000001), (-6.0199999999999996, -5.4800000000000004, 0.025000000000000001, -157.53999999999999), (-5.0099999999999998, -8.3200000000000003, 0.025000000000000001, -160.66), (-4.0499999999999998, -11.359999999999999, 0.025000000000000001, -170.22), (-3.4900000000000002, -14.18, 0.025000000000000001, -175.75999999999999), (-3.1200000000000001, -17.149999999999999, 0.025000000000000001, -177.72999999999999), (-3.0, -20.32, 0.025000000000000001, 178.49000000000001), (-3.0899999999999999, -23.440000000000001, 0.025000000000000001, 176.59), (-3.4300000000000002, -26.539999999999999, 0.025000000000000001, 171.44), (-4.0700000000000003, -29.440000000000001, 0.025000000000000001, 163.75), (-5.0899999999999999, -32.270000000000003, 0.025000000000000001, 158.19999999999999), (-6.1100000000000003, -35.159999999999997, 0.025000000000000001, 154.97999999999999), (-7.5700000000000003, -37.780000000000001, 0.025000000000000001, 154.97999999999999), (-9.2799999999999994, -40.649999999999999, 0.025000000000000001, 150.41)), ((-6.1200000000000001, 1.6200000000000001, 0.025000000000000001, -152.90000000000001), (-4.3799999999999999, -1.3500000000000001, 0.025000000000000001, -150.91999999999999), (-3.0800000000000001, -4.2999999999999998, 0.025000000000000001, -157.90000000000001), (-1.8500000000000001, -7.2599999999999998, 0.025000000000000001, -162.53999999999999), (-0.93000000000000005, -10.49, 0.025000000000000001, -167.71000000000001), (-0.20999999999999999, -13.710000000000001, 0.025000000000000001, -171.78999999999999), (0.20999999999999999, -17.079999999999998, 0.025000000000000001, -174.91999999999999), (0.31, -20.199999999999999, 0.025000000000000001, 177.09999999999999), (0.17000000000000001, -23.66, 0.025000000000000001, 174.81999999999999), (-0.23000000000000001, -26.91, 0.025000000000000001, 170.50999999999999), (-0.98999999999999999, -30.199999999999999, 0.025000000000000001, 162.53999999999999), (-2.02, -33.280000000000001, 0.025000000000000001, 160.47999999999999), (-3.2799999999999998, -36.380000000000003, 0.025000000000000001, 157.96000000000001), (-4.6699999999999999, -39.170000000000002, 0.025000000000000001, 154.13), (-6.3099999999999996, -42.149999999999999, 0.025000000000000001, 154.13)), ((-2.9900000000000002, 3.0899999999999999, 0.025000000000000001, -154.37), (-1.3799999999999999, -0.050000000000000003, 0.025000000000000001, -154.75), (-0.19, -3.29, 0.025000000000000001, -159.22), (1.1699999999999999, -6.5099999999999998, 0.025000000000000001, -162.74000000000001), (2.2799999999999998, -9.8000000000000007, 0.025000000000000001, -168.72999999999999), (3.0899999999999999, -13.279999999999999, 0.025000000000000001, -173.49000000000001), (3.46, -16.629999999999999, 0.025000000000000001, -176.81), (3.6899999999999999, -20.379999999999999, 0.025000000000000001, 179.13999999999999), (3.6099999999999999, -24.120000000000001, 0.025000000000000001, 175.78), (3.0, -27.550000000000001, 0.025000000000000001, 170.87), (2.1499999999999999, -30.719999999999999, 0.025000000000000001, 167.41), (1.04, -34.259999999999998, 0.025000000000000001, 162.11000000000001), (-0.14999999999999999, -37.439999999999998, 0.025000000000000001, 158.59), (-1.6399999999999999, -40.520000000000003, 0.025000000000000001, 153.88999999999999), (-3.4199999999999999, -43.630000000000003, 0.025000000000000001, 153.88999999999999)), ((0.0, 4.3499999999999996, 0.025000000000000001, -154.37), (1.52, 1.3, 0.025000000000000001, -155.66999999999999), (3.1699999999999999, -2.0699999999999998, 0.025000000000000001, -155.66999999999999), (4.4699999999999998, -5.4100000000000001, 0.025000000000000001, -163.0), (5.5599999999999996, -9.1899999999999995, 0.025000000000000001, -168.88999999999999), (6.2199999999999998, -12.66, 0.025000000000000001, -171.66999999999999), (6.6699999999999999, -16.559999999999999, 0.025000000000000001, -176.53), (6.9299999999999997, -20.329999999999998, 0.025000000000000001, 179.87), (6.8099999999999996, -24.32, 0.025000000000000001, 175.19), (6.2199999999999998, -27.969999999999999, 0.025000000000000001, 170.81), (5.5899999999999999, -31.73, 0.025000000000000001, 167.53999999999999), (4.4800000000000004, -35.420000000000002, 0.025000000000000001, 161.91999999999999), (3.0600000000000001, -38.82, 0.025000000000000001, 158.56), (1.3999999999999999, -42.0, 0.025000000000000001, 154.31999999999999), (-0.70999999999999996, -45.170000000000002, 0.025000000000000001, 153.27000000000001)))
     self.avatarPositions = { }
     self.modelCount = 8
     self.cameraTopView = (-22.780000000000001, -41.649999999999999, 31.530000000000001, -51.549999999999997, -42.68, -2.96)
     self.timer = None
     self.timerStartTime = None
 def __init__(self, avId, avName, avDisableName):
     DirectFrame.__init__(self, pos = (0.29999999999999999, 0.10000000000000001, 0.65000000000000002), image_color = ToontownGlobals.GlobalDialogColor, image_scale = (1.0, 1.0, 0.59999999999999998), text = '', text_wordwrap = 13.5, text_scale = 0.059999999999999998, text_pos = (0.0, 0.17999999999999999))
     self['image'] = getDefaultDialogGeom()
     self.avId = avId
     self.avName = avName
     self.avDisableName = avDisableName
     self.fsm = FSM.FSM('TeleportPanel', [
         State.State('off', self.enterOff, self.exitOff),
         State.State('begin', self.enterBegin, self.exitBegin),
         State.State('checkAvailability', self.enterCheckAvailability, self.exitCheckAvailability),
         State.State('notAvailable', self.enterNotAvailable, self.exitNotAvailable),
         State.State('ignored', self.enterIgnored, self.exitIgnored),
         State.State('notOnline', self.enterNotOnline, self.exitNotOnline),
         State.State('wentAway', self.enterWentAway, self.exitWentAway),
         State.State('self', self.enterSelf, self.exitSelf),
         State.State('unknownHood', self.enterUnknownHood, self.exitUnknownHood),
         State.State('unavailableHood', self.enterUnavailableHood, self.exitUnavailableHood),
         State.State('otherShard', self.enterOtherShard, self.exitOtherShard),
         State.State('teleport', self.enterTeleport, self.exitTeleport)], 'off', 'off')
     FriendInviter.hideFriendInviter()
     AvatarDetailPanel.hideAvatarDetail()
     buttons = loader.loadModelOnce('phase_3/models/gui/dialog_box_buttons_gui')
     self.bOk = DirectButton(self, image = (buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr')), relief = None, text = 'OK', text_scale = 0.050000000000000003, text_pos = (0.0, -0.10000000000000001), pos = (0.0, 0.0, -0.10000000000000001), command = self._TeleportPanel__handleOk)
     self.bOk.hide()
     self.bCancel = DirectButton(self, image = (buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr')), relief = None, text = 'Cancel', text_scale = 0.050000000000000003, text_pos = (0.0, -0.10000000000000001), pos = (0.0, 0.0, -0.10000000000000001), command = self._TeleportPanel__handleCancel)
     self.bCancel.hide()
     self.bYes = DirectButton(self, image = (buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr')), relief = None, text = 'Yes', text_scale = 0.050000000000000003, text_pos = (0.0, -0.10000000000000001), pos = (-0.14999999999999999, 0.0, -0.14999999999999999), command = self._TeleportPanel__handleYes)
     self.bYes.hide()
     self.bNo = DirectButton(self, image = (buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr')), relief = None, text = 'No', text_scale = 0.050000000000000003, text_pos = (0.0, -0.10000000000000001), pos = (0.14999999999999999, 0.0, -0.14999999999999999), command = self._TeleportPanel__handleNo)
     self.bNo.hide()
     buttons.removeNode()
     self.accept(self.avDisableName, self._TeleportPanel__handleDisableAvatar)
     self.show()
     self.fsm.enterInitialState()
     self.fsm.request('begin')
Exemple #16
0
 def __init__(self, loader, parentFSMState, doneEvent):
     Place.Place.__init__(self, loader, doneEvent)
     self.dnaFile = 'phase_7/models/modules/toon_interior'
     self.isInterior = 1
     self.tfaDoneEvent = 'tfaDoneEvent'
     self.fsm = FSM.FSM('ToonInterior', [
         State.State('start', self.enterStart, self.exitStart,
                     ['doorIn', 'teleportIn', 'tutorial']),
         State.State('walk', self.enterWalk, self.exitWalk, [
             'stickerBook', 'doorOut', 'DFA', 'teleportOut', 'quest',
             'purchase'
         ]),
         State.State('stickerBook', self.enterStickerBook,
                     self.exitStickerBook, ['walk', 'DFA']),
         State.State('DFA', self.enterDFA, self.exitDFA,
                     ['DFAReject', 'teleportOut', 'doorOut']),
         State.State('DFAReject', self.enterDFAReject, self.exitDFAReject,
                     ['walk']),
         State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']),
         State.State('doorOut', self.enterDoorOut, self.exitDoorOut,
                     ['walk']),
         State.State('teleportIn', self.enterTeleportIn,
                     self.exitTeleportIn, ['walk']),
         State.State('teleportOut', self.enterTeleportOut,
                     self.exitTeleportOut, ['teleportIn']),
         State.State('quest', self.enterQuest, self.exitQuest,
                     ['walk', 'doorOut']),
         State.State('tutorial', self.enterTutorial, self.exitTutorial,
                     ['walk', 'quest']),
         State.State('purchase', self.enterPurchase, self.exitPurchase,
                     ['walk', 'doorOut']),
         State.State('final', self.enterFinal, self.exitFinal, ['start'])
     ], 'start', 'final')
     self.parentFSMState = parentFSMState
 def __init__(self, parentFSMState, doneEvent):
     StateData.StateData.__init__(self, doneEvent)
     self.parentFSMState = parentFSMState
     self.place = None
     self.fsm = FSM.FSM('EstateLoader', [
         State.State('start', self.enterStart, self.exitStart,
                     ['quietZone', 'estate', 'house']),
         State.State('estate', self.enterEstate, self.exitEstate,
                     ['quietZone']),
         State.State('house', self.enterHouse, self.exitHouse,
                     ['quietZone']),
         State.State('quietZone', self.enterQuietZone, self.exitQuietZone,
                     ['house', 'estate']),
         State.State('final', self.enterFinal, self.exitFinal, ['start'])
     ], 'start', 'final')
     self.id = MyEstate
     self.estateOwnerId = None
     self.branchZone = None
     self.houseDoneEvent = 'houseDone'
     self.estateDoneEvent = 'estateDone'
     self.estateDNAFile = 'phase_5.5/dna/estate_1.dna'
     self.estateStorageDNAFile = 'phase_5.5/dna/storage_estate.dna'
     self.popupInfo = None
     self.enteredHouse = None
     self.fsm.enterInitialState()
Exemple #18
0
 def __init__(self, loader, parentFSM, doneEvent):
     Place.Place.__init__(self, loader, doneEvent)
     self.fsm = FSM.FSM('SuitInterior', [
         State.State('entrance', self.enterEntrance, self.exitEntrance,
                     ['battle', 'walk']),
         State.State('Elevator', self.enterElevator, self.exitElevator,
                     ['battle', 'walk']),
         State.State('battle', self.enterBattle, self.exitBattle, ['walk']),
         State.State('walk', self.enterWalk, self.exitWalk,
                     ['stickerBook', 'teleportOut', 'Elevator', 'DFA']),
         State.State('stickerBook', self.enterStickerBook,
                     self.exitStickerBook, ['walk', 'DFA']),
         State.State('DFA', self.enterDFA, self.exitDFA,
                     ['DFAReject', 'teleportOut']),
         State.State('DFAReject', self.enterDFAReject, self.exitDFAReject,
                     ['walk']),
         State.State('teleportIn', self.enterTeleportIn,
                     self.exitTeleportIn, ['walk']),
         State.State('teleportOut', self.enterTeleportOut,
                     self.exitTeleportOut, ['teleportIn']),
         State.State('elevatorOut', self.enterElevatorOut,
                     self.exitElevatorOut, [])
     ], 'entrance', 'elevatorOut')
     self.parentFSM = parentFSM
     self.elevatorDoneEvent = 'elevatorDoneSI'
     self.__zoneId = 0
     self.currentFloor = 0
Exemple #19
0
 def __init__(self, safeZone, parentFSM, doneEvent):
     StateData.StateData.__init__(self, doneEvent)
     self.fsm = FSM.FSM('Trolley', [
         State.State('start', self.enterStart, self.exitStart,
                     ['requestBoard', 'trolleyHFA', 'trolleyTFA']),
         State.State('trolleyHFA', self.enterTrolleyHFA,
                     self.exitTrolleyHFA, ['final']),
         State.State('trolleyTFA', self.enterTrolleyTFA,
                     self.exitTrolleyTFA, ['final']),
         State.State('requestBoard', self.enterRequestBoard,
                     self.exitRequestBoard, ['boarding']),
         State.State('boarding', self.enterBoarding, self.exitBoarding,
                     ['boarded']),
         State.State('boarded', self.enterBoarded, self.exitBoarded,
                     ['requestExit', 'trolleyLeaving', 'final']),
         State.State('requestExit', self.enterRequestExit,
                     self.exitRequestExit, ['exiting', 'trolleyLeaving']),
         State.State('trolleyLeaving', self.enterTrolleyLeaving,
                     self.exitTrolleyLeaving, ['final']),
         State.State('exiting', self.enterExiting, self.exitExiting,
                     ['final']),
         State.State('final', self.enterFinal, self.exitFinal, ['start'])
     ], 'start', 'final')
     self.parentFSM = parentFSM
     return None
     return
Exemple #20
0
def upload():
    fname = request.files['img']  #获取上传的文件

    if fname:
        # t = time.strftime('%Y%m%d%H%M%S')
        new_fname = r'pdf/' + fname.filename
        fname.save(new_fname)  #保存文件到指定路径
        # 生成html和txt
        html_and_txt(fname.filename[:-4])
        # 得到关键字
        words_list = textrank.words(fname.filename[:-4])
        # 生成高亮html
        FSM.light(words_list, fname.filename[:-4])
        return send_file('./pdf/{}.html'.format(fname.filename[:-4]))
    else:
        return '{"msg": "请上传文件!"}'
 def __init__(self, cr):
     DistributedMinigame.__init__(self, cr)
     self.gameFSM = FSM.FSM('DistributedCannonGame', [
         State.State('off', self.enterOff, self.exitOff, [
             'aim']),
         State.State('aim', self.enterAim, self.exitAim, [
             'shoot',
             'waitForToonsToLand',
             'cleanup']),
         State.State('shoot', self.enterShoot, self.exitShoot, [
             'aim',
             'waitForToonsToLand',
             'cleanup']),
         State.State('waitForToonsToLand', self.enterWaitForToonsToLand, self.exitWaitForToonsToLand, [
             'cleanup']),
         State.State('cleanup', self.enterCleanup, self.exitCleanup, [])], 'off', 'cleanup')
     self.addChildGameFSM(self.gameFSM)
     self.cannonLocationDict = { }
     self.cannonPositionDict = { }
     self.cannonDict = { }
     self.toonModelDict = { }
     self.dropShadowDict = { }
     self.toonHeadDict = { }
     self.toonScaleDict = { }
     self.toonIntervalDict = { }
     self.leftPressed = 0
     self.rightPressed = 0
     self.upPressed = 0
     self.downPressed = 0
     self.cannonMoving = 0
     self.modelCount = 14
 def __init__(self, parent):
     wx.Panel.__init__(self, parent)
     
     panel = wx.Panel(self, size=(WINDOW_WIDTH, WINDOW_HEIGHT))
     nb = wx.Notebook(panel)
     
     cd = CharacterData(nb)
     cs = CharacterSprites(nb)
     ht = HitBox(nb)
     an = Animations(nb)
     sc = SparksCharacter(nb)
     co = Commands(nb)
     hc = HitStatesCharacter(nb)
     fm = FSM(nb)
     ai = AI(nb)
     
     nb.AddPage(cd, "Data")
     nb.AddPage(cs, "Sprites")
     nb.AddPage(ht, "Hitbox")
     nb.AddPage(an, "Animations")
     nb.AddPage(sc, "Sparks")
     nb.AddPage(co, "Commands")
     nb.AddPage(hc, "HitStates")
     nb.AddPage(fm, "FSM")
     nb.AddPage(ai, "AI")
     
     sizer = wx.BoxSizer()
     sizer.Add(nb, 1, wx.EXPAND)
     
     self.SetSizer(sizer)
 def __init__(self, cr):
     DistributedObject.DistributedObject.__init__(self, cr)
     self.toons = []
     self.activeIntervals = {}
     self.openSfx = base.loadSfx('phase_5/audio/sfx/elevator_door_open.mp3')
     self.closeSfx = base.loadSfx(
         'phase_5/audio/sfx/elevator_door_close.mp3')
     self.suits = []
     self.reserveSuits = []
     self.joiningReserves = []
     self.distBldgDoId = None
     self.currentFloor = -1
     self.numFloors = None
     self.elevatorName = self._DistributedSuitInterior__uniqueName(
         'elevator')
     self.floorModel = None
     self.elevatorOutOpen = 0
     self.BottomFloor_SuitPositions = [
         Point3(0, 15, 0),
         Point3(10, 20, 0),
         Point3(-7, 24, 0),
         Point3(-10, 0, 0)
     ]
     self.BottomFloor_SuitHs = [75, 170, -91, -44]
     self.Cubicle_SuitPositions = [
         Point3(0, 18, 0),
         Point3(10, 12, 0),
         Point3(-9, 11, 0),
         Point3(-3, 13, 0)
     ]
     self.Cubicle_SuitHs = [170, 56, -52, 10]
     self.BossOffice_SuitPositions = [
         Point3(0, 15, 0),
         Point3(10, 20, 0),
         Point3(-10, 6, 0),
         Point3(-17, 34, 11)
     ]
     self.BossOffice_SuitHs = [170, 120, 12, 38]
     self.waitMusic = base.loadMusic(
         'phase_7/audio/bgm/encntr_toon_winning_indoor.mid')
     self.elevatorMusic = base.loadMusic(
         'phase_7/audio/bgm/tt_elevator.mid')
     self.fsm = FSM.FSM('DistributedSuitInterior', [
         State.State('WaitForAllToonsInside',
                     self.enterWaitForAllToonsInside,
                     self.exitWaitForAllToonsInside, ['Elevator']),
         State.State('Elevator', self.enterElevator, self.exitElevator,
                     ['Battle']),
         State.State('Battle', self.enterBattle, self.exitBattle,
                     ['Resting', 'Reward', 'ReservesJoining']),
         State.State('ReservesJoining', self.enterReservesJoining,
                     self.exitReservesJoining, ['Battle']),
         State.State('Resting', self.enterResting, self.exitResting,
                     ['Elevator']),
         State.State('Reward', self.enterReward, self.exitReward, ['Off']),
         State.State('Off', self.enterOff, self.exitOff,
                     ['Elevator', 'WaitForAllToonsInside', 'Battle'])
     ], 'Off', 'Off')
     self.fsm.enterInitialState()
Exemple #24
0
 def __init__(self, parentFSM, doneEvent, avList, index, isPaid):
     StateData.StateData.__init__(self, doneEvent)
     self.isPaid = isPaid
     self.avList = avList
     self.index = index
     self.shopsVisited = []
     self.avId = -1
     self.names = [
      '', '', '', '']
     self.toon = None
     self.boy = 0
     self.girl = 0
     self.allTitles = []
     self.allFirsts = []
     self.allPrefixes = []
     self.allSuffixes = []
     self.titleIndex = 0
     self.firstIndex = 0
     self.prefixIndex = 0
     self.suffixIndex = 0
     self.titleActive = 0
     self.firstActive = 0
     self.lastActive = 0
     self.quickFind = 0
     self.listsLoaded = 0
     self.addedGenderSpecific = 0
     self.chastise = 0
     self.nameIndices = [-1, -1, -1, -1]
     self.nameFlags = [1, 1, 1, 0]
     self.dummyReturn = 2
     self.nameAction = 0
     self.pickANameGUIElements = []
     self.typeANameGUIElements = []
     self.textRolloverColor = Vec4(1, 1, 0, 1)
     self.textDownColor = Vec4(0.5, 0.9, 1, 1)
     self.textDisabledColor = Vec4(0.4, 0.8, 0.4, 1)
     self.fsm = FSM.FSM('NameShop', [
      State.State('Init', self.enterInit, self.exitInit, [
       'PayState']),
      State.State('PayState', self.enterPayState, self.exitPayState, [
       'PickAName']),
      State.State('PickAName', self.enterPickANameState, self.exitPickANameState, [
       'TypeAName', 'Done']),
      State.State('TypeAName', self.enterTypeANameState, self.exitTypeANameState, [
       'PickAName', 'Approval', 'Accepted', 'Rejected']),
      State.State('Approval', self.enterApprovalState, self.exitApprovalState, [
       'PickAName', 'Done']),
      State.State('Accepted', self.enterAcceptedState, self.exitAcceptedState, [
       'Done']),
      State.State('Rejected', self.enterRejectedState, self.exitRejectedState, [
       'TypeAName']),
      State.State('Done', self.enterDone, self.exitDone, [
       'Init'])], 'Init', 'Done')
     self.parentFSM = parentFSM
     self.parentFSM.getStateNamed('NameShop').addChild(self.fsm)
     self.nameGen = NameGenerator.NameGenerator()
     self.fsm.enterInitialState()
     return None
     return
def singlePacketAttack(code,severity):
    global current_state

    print ('ALERT:\t', alarmCodeList[code] , '\t', 
           severity , '\t', datetime.datetime.now())

    alarm_action = "rise"
    current_state = FSM.alarm_FSM(current_state,alarm_action)
 def __init__(self, cr):
     DistributedMinigame.__init__(self, cr)
     self.gameFSM = FSM.FSM('DistributedMinigameTemplate', [
         State.State('off', self.enterOff, self.exitOff, ['play']),
         State.State('play', self.enterPlay, self.exitPlay, ['cleanup']),
         State.State('cleanup', self.enterCleanup, self.exitCleanup, [])
     ], 'off', 'cleanup')
     self.addChildGameFSM(self.gameFSM)
 def __init__(self, cr):
     DistributedMinigame.__init__(self, cr)
     self.gameFSM = FSM.FSM('DistributedRingGame', [
         State.State('off', self.enterOff, self.exitOff, ['swim']),
         State.State('swim', self.enterSwim, self.exitSwim, ['cleanup']),
         State.State('cleanup', self.enterCleanup, self.exitCleanup, [])
     ], 'off', 'cleanup')
     self.addChildGameFSM(self.gameFSM)
def singlePacketAttack(code, severity):
    global current_state

    print('ALERT:\t', alarmCodeList[code], '\t', severity, '\t',
          datetime.datetime.now())

    alarm_action = "rise"
    current_state = FSM.alarm_FSM(current_state, alarm_action)
Exemple #29
0
def makeAnotherTest(numberOfStates, numberOfInputs):
    fsmname = "/home/andrey/z3/bin/python/otherFSMs/Uncomplete.fsm"
    testFullName = "/home/andrey/z3/bin/python/otherFSMs/Uncomplete.fsm.test"
    k = generateFSM("/home/andrey/z3/bin/python/", fsmname, numberOfStates,
                    numberOfInputs, numberOfInputs)
    if (k != 0):
        print("error! " + str(k))
        print("pause")
        pause_variable = input()
    k1 = generateTest(fsmname, testFullName, "TT")
    if (k1 != 0):
        print("error2!!!!")
        print("pause")
        pause_variable = input()
    fsm = FSM()
    fsm.readFSMfromFile(fsmname)
    print("made another test")
    return (fsm, testFullName)
Exemple #30
0
 def __init__(self):
     self.background = pygame.surface.Surface((780, 720)).convert()
     self.background.fill((0, 0, 0))
     self.time = 0
     self.size = Vector2(780, 720)
     self.chapter = None
     self.position = (0, 0)
     self.panel = None
     self.ship = None
     self.enemies = {}
     self.bullets = {}
     self.bullet_id = 0
     self.enemy_id = 0
     self.FSM = FSM()
     self.FSM.add_state(Gameover(self))
     self.FSM.add_state(Complete(self))
     self.FSM.add_state(Begin(self))
     self.stars = []
 def __init__(self, tcr, doneEvent):
     StateData.StateData.__init__(self, doneEvent)
     GuiScreen.GuiScreen.__init__(self)
     self.tcr = tcr
     self.fsm = FSM.FSM('FreeTimeInformScreen', [
      State.State('off', self.enterOff, self.exitOff, [
       'inform']),
      State.State('inform', self.enterInform, self.exitInform, [])], 'off', 'off')
     self.fsm.enterInitialState()
Exemple #32
0
 def __init__(self, loader, parentFSM, doneEvent):
     Place.Place.__init__(self, loader, doneEvent)
     self.tfaDoneEvent = 'tfaDoneEvent'
     self.fsm = FSM.FSM('Playground', [
      State.State('start', self.enterStart, self.exitStart, [
       'walk', 'deathAck', 'doorIn', 'tunnelIn']),
      State.State('walk', self.enterWalk, self.exitWalk, [
       'stickerBook', 'TFA', 'DFA', 'trolley', 'final', 'doorOut', 'options', 'quest', 'purchase', 'fishing']),
      State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, [
       'walk', 'DFA', 'TFA']),
      State.State('trolley', self.enterTrolley, self.exitTrolley, [
       'walk']),
      State.State('doorIn', self.enterDoorIn, self.exitDoorIn, [
       'walk']),
      State.State('doorOut', self.enterDoorOut, self.exitDoorOut, [
       'walk']),
      State.State('TFA', self.enterTFA, self.exitTFA, [
       'TFAReject', 'DFA']),
      State.State('TFAReject', self.enterTFAReject, self.exitTFAReject, [
       'walk']),
      State.State('DFA', self.enterDFA, self.exitDFA, [
       'DFAReject', 'NPCFA', 'HFA']),
      State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, [
       'walk']),
      State.State('NPCFA', self.enterNPCFA, self.exitNPCFA, [
       'NPCFAReject', 'HFA']),
      State.State('NPCFAReject', self.enterNPCFAReject, self.exitNPCFAReject, [
       'walk']),
      State.State('HFA', self.enterHFA, self.exitHFA, [
       'HFAReject', 'teleportOut', 'tunnelOut']),
      State.State('HFAReject', self.enterHFAReject, self.exitHFAReject, [
       'walk']),
      State.State('deathAck', self.enterDeathAck, self.exitDeathAck, [
       'teleportIn']),
      State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, [
       'walk', 'popup']),
      State.State('popup', self.enterPopup, self.exitPopup, [
       'walk']),
      State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, [
       'deathAck']),
      State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, [
       'walk']),
      State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, [
       'final']),
      State.State('quest', self.enterQuest, self.exitQuest, [
       'walk']),
      State.State('purchase', self.enterPurchase, self.exitPurchase, [
       'walk']),
      State.State('fishing', self.enterFishing, self.exitFishing, [
       'walk']),
      State.State('final', self.enterFinal, self.exitFinal, [
       'start'])], 'start', 'final')
     self.parentFSM = parentFSM
     self.tunnelOriginList = []
     self.trolleyDoneEvent = 'trolleyDone'
     self.hfaDoneEvent = 'hfaDoneEvent'
     self.npcfaDoneEvent = 'npcfaDoneEvent'
Exemple #33
0
 def __init__(self, tcr, doneEvent):
     StateData.StateData.__init__(self, doneEvent)
     GuiScreen.GuiScreen.__init__(self)
     self.tcr = tcr
     self.fsm = FSM.FSM('WelcomeScreen', [
         State.State('off', self.enterOff, self.exitOff, ['display']),
         State.State('display', self.enterDisplay, self.exitDisplay, [])
     ], 'off', 'off')
     self.fsm.enterInitialState()
def simpleTest():
    fsa = buildSourceModel(vocabulary, suffixes)
    fst = buildChannelModel()

    print "==== Trying source model on strings 'ace+ed' ===="
    output = FSM.runFST([fsa], ["ace+ed"])
    print "==== Result: ", str(output), " ===="

    print "==== Trying source model on strings 'panic+ing' ===="
    output = FSM.runFST([fsa], ["panic+ing"])
    print "==== Result: ", str(output), " ===="
    
    print "==== Generating random paths for 'aced', using only channel model ===="
    output = FSM.runFST([fst], ["aced"], maxNumPaths=10, randomPaths=True)
    print "==== Result: ", str(output), " ===="

    print "==== Disambiguating a few phrases: aced, panicked, paniced, sprucing ===="
    output = FSM.runFST([fsa,fst], ["aced", "paniced", "panicked", "sprucing"])
    print "==== Result: ", str(output), " ===="
def runTest(trainFile='bengali.train', devFile='bengali.dev', channel=stupidChannelModel, source=stupidSourceModel):
    (words, segs) = readData(trainFile)
    (wordsDev, segsDev) = readData(devFile)
    fst = channel(words, segs)
    fsa = source(segs)

    preTrainOutput = FSM.runFST([fsa, fst], wordsDev, quiet=True)
    for i in range(len(preTrainOutput)):
        if len(preTrainOutput[i]) == 0: preTrainOutput[i] = words[i]
        else:                           preTrainOutput[i] = preTrainOutput[i][0]
    preTrainEval   = evaluate(segsDev, preTrainOutput)
    print 'before training, P/R/F = ', str(preTrainEval)

    fst.trainFST(words, segs)

    postTrainOutput = FSM.runFST([fsa, fst], wordsDev, quiet=True)
    for i in range(len(postTrainOutput)):
        if len(postTrainOutput[i]) == 0: postTrainOutput[i] = words[i]
        else:                            postTrainOutput[i] = postTrainOutput[i][0]
    postTrainEval   = evaluate(segsDev, postTrainOutput)
    print 'after  training, P/R/F = ', str(postTrainEval)
    
    return postTrainOutput
def runTest(trainFile="bengali.train", devFile="data/oedclean.txt", source=bigramSourceModel):
    # def runTest(trainFile='bengali.train', devFile='OEDResultsUniq.txt', channel=stupidChannelModel, source=stupidSourceModel):
    (words, british, american) = readData(devFile)

    # (wordsDev, segsDev) = readData(devFile)
    # fst = channel(words, segs)
    uk_fsa = source(british)
    usa_fsa = source(american)

    correct = 0
    total = 0

    for country, src, loc, gender, trans in testFileLines():
        total += 1
        words = trans.split(",")
        FSM.runFST([usa_fsa], words, outfile=".tmp.usa.output", quiet=True)
        FSM.runFST([uk_fsa], words, outfile=".tmp.uk.output", quiet=True)

        result = compare_results(".tmp.usa.output", ".tmp.uk.output")

        if result > 0 and country == "usa":
            correct += 1
        elif result < 0 and country == "uk":
            correct += 1
        elif result == 0:
            print "Not sure. Result equals 0."
        else:
            print "Got one wrong.  Misabeled " + src
            print "Truth: " + country + ".  Result: " + str(result)
            print

        # break

    print "Summary:\n"
    print "Got " + str(correct) + " correct for an accuracy of " + str(100.0 * correct / total) + "%"

    return
Exemple #37
0
class Runner(object):
	def __init__(self, path, startstates=[]):
		self.path = path
		self.fsm = FSM()
		self.loader = Loader(path)
		self.startstates = startstates
	def prepare(self):
		self.loader.load()
		self.fsm.startstates = self.startstates
		self.fsm.actionset = self.loader.actions
		self.fsm.explore()
	def run(self):
		self.fsm.execute()
	def savesvg(self):
		self.fsm.savesvg()
Exemple #38
0
def start_new():
    FSM.game()
Exemple #39
0
	def __init__(self, path, startstates=[]):
		self.path = path
		self.fsm = FSM()
		self.loader = Loader(path)
		self.startstates = startstates
Exemple #40
0
def init():
  Ur.init()
  AbInitio.init()
  Particle.init()
  AttributeGroup.init()
  GroupInit()
  FSM.init()
  lfInit()
  Element.init()
  Component.init()
  List.init()
  elts.Init.init()
  validate.veInit()
  # Could this be computed from the reflectedName property of the types -- does
  # Python give access to the class hierarchy top-down?
  psviIndMap.update({'schema':DumpedSchema,
            'atomic':(SimpleType,AbInitio.AbInitio),
            'list':(SimpleType,List.List),
            'union':(SimpleType,Union),
            'complexTypeDefinition':ComplexType,
            'attributeUse':AttributeUse,
            'attributeDeclaration':Attribute,
            'particle':Particle.Particle,
            'modelGroupDefinition':(Group,ModelGroup),
            'modelGroup':Group,
            'elementDeclaration':Element.Element,
            'wildcard':Wildcard,
            'annotation':None,
            'enumeration':Enumeration,
            'whiteSpace':Whitespace,
            'pattern':Pattern,
            'maxInclusive':MaxInclusive,
            'minInclusive':MinInclusive,
            'fractionDigits':FractionDigits,
            'precision':Precision,
            'lexicalMappings':LexicalMappings,
            'attributeGroupDefinition':AttributeGroup.AttributeGroup,
            'key':Key,
            'keyref':Keyref,
            'unique':Unique,
            'xpath':xpathTemp})
  auxComponentMap.update({'namespaceSchemaInformation':namespaceSchemaInformation,
                          'valueConstraint':valueConstraint,
                          'namespaceConstraint':namespaceConstraint,
                          'contentType':contentType,
                          'schemaDocument':schemaDocument})
  _Nmtoken=("1.0",u'[-.:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0641-\u064a\u0671-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5\u06e5-\u06e6\u0905-\u0939\u093d\u0958-\u0961\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ae0\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0e01-\u0e2e\u0e30\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0f40-\u0f47\u0f49-\u0f69\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2126\u212a-\u212b\u212e\u2180-\u2182\u3041-\u3094\u30a1-\u30fa\u3105-\u312c\uac00-\ud7a3\u4e00-\u9fa5\u3007\u3021-\u30290-9\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be7-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u0300-\u0345\u0360-\u0361\u0483-\u0486\u0591-\u05a1\u05a3-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4\u064b-\u0652\u0670\u06d6-\u06dc\u06dd-\u06df\u06e0-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0901-\u0903\u093c\u093e-\u094c\u094d\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09bc\u09be\u09bf\u09c0-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09e2-\u09e3\u0a02\u0a3c\u0a3e\u0a3f\u0a40-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a70-\u0a71\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0b01-\u0b03\u0b3c\u0b3e-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b82-\u0b83\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c82-\u0c83\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0d02-\u0d03\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86-\u0f8b\u0f90-\u0f95\u0f97\u0f99-\u0fad\u0fb1-\u0fb7\u0fb9\u20d0-\u20dc\u20e1\u302a-\u302f\u3099\u309a\xb7\u02d0\u02d1\u0387\u0640\u0e46\u0ec6\u3005\u3031-\u3035\u309d-\u309e\u30fc-\u30fe]+')
  _Nmtoken11=("1.1",u'[-.0-9:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0300-\u037d\u037f-\u1fff\u200c-\u200d\u203f-\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]+')
  _Name=("1.0",u'[_:A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0641-\u064a\u0671-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5\u06e5-\u06e6\u0905-\u0939\u093d\u0958-\u0961\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ae0\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0e01-\u0e2e\u0e30\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0f40-\u0f47\u0f49-\u0f69\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2126\u212a-\u212b\u212e\u2180-\u2182\u3041-\u3094\u30a1-\u30fa\u3105-\u312c\uac00-\ud7a3\u4e00-\u9fa5\u3007\u3021-\u3029][-._:A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0641-\u064a\u0671-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5\u06e5-\u06e6\u0905-\u0939\u093d\u0958-\u0961\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ae0\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0e01-\u0e2e\u0e30\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0f40-\u0f47\u0f49-\u0f69\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2126\u212a-\u212b\u212e\u2180-\u2182\u3041-\u3094\u30a1-\u30fa\u3105-\u312c\uac00-\ud7a3\u4e00-\u9fa5\u3007\u3021-\u30290-9\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be7-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u0300-\u0345\u0360-\u0361\u0483-\u0486\u0591-\u05a1\u05a3-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4\u064b-\u0652\u0670\u06d6-\u06dc\u06dd-\u06df\u06e0-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0901-\u0903\u093c\u093e-\u094c\u094d\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09bc\u09be\u09bf\u09c0-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09e2-\u09e3\u0a02\u0a3c\u0a3e\u0a3f\u0a40-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a70-\u0a71\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0b01-\u0b03\u0b3c\u0b3e-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b82-\u0b83\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c82-\u0c83\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0d02-\u0d03\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86-\u0f8b\u0f90-\u0f95\u0f97\u0f99-\u0fad\u0fb1-\u0fb7\u0fb9\u20d0-\u20dc\u20e1\u302a-\u302f\u3099\u309a\xb7\u02d0\u02d1\u0387\u0640\u0e46\u0ec6\u3005\u3031-\u3035\u309d-\u309e\u30fc-\u30fe]*')
  _Name11=("1.1",u'[:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd][-.0-9:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0300-\u037d\u037f-\u1fff\u200c-\u200d\u203f-\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]*')
  _language="([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]+)(-[a-zA-Z]{1,8})*"
  _NCName="[^:]*"
  builtinPats.extend([_Name,_Name11,_Nmtoken,_Nmtoken11,_language,_NCName])
  builtinTypeNames.extend([
    ('normalizedString','string',((Whitespace,"replace"),),0),
    ('token','normalizedString',((Whitespace,"collapse"),),0),
    ('language','token',
    ((Pattern,[_language]),),0),
    ('NMTOKEN','token',((Pattern,[_Nmtoken,_Nmtoken11]),),0),
    ('Name','token',((Pattern,[_Name,_Name11]),),0),
    ('NCName','Name',((Pattern,[_NCName]),),0),
    ('ID','NCName',(),1), ('IDREF','NCName',(),2), ('ENTITY','NCName',(),0),
    ('aPDecimal','pDecimal',((LexicalMappings,['nodecimal', 'decimal']),
                             (Precision,0)),0),
    ('integer','decimal',((FractionDigits,0),),0),
    ('nonPositiveInteger','integer',((MaxInclusive,0),),0),
    ('negativeInteger','nonPositiveInteger', ((MaxInclusive,-1),),0),
    ('long','integer',((MinInclusive,-9223372036854775808L),
    (MaxInclusive,9223372036854775807L)),0),
    ('int','long',((MinInclusive,-2147483648L),(MaxInclusive,2147483647)),0),
    ('short','int',((MinInclusive,-32768),(MaxInclusive,32767)),0),
    ('byte','short',((MinInclusive,-128),(MaxInclusive,127)),0),
    ('nonNegativeInteger','integer',((MinInclusive,0),),0),
    ('unsignedLong','nonNegativeInteger',((MaxInclusive,18446744073709551615L),),0),
    ('unsignedInt','unsignedLong',((MaxInclusive,4294967295L),),0),
    ('unsignedShort','unsignedInt',((MaxInclusive,65535),),0),
    ('unsignedByte','unsignedShort',((MaxInclusive,255),),0),
    ('positiveInteger','nonNegativeInteger',((MinInclusive,1),),0)])

  XSV.NCNamePat = re.compile("(%s)$"%_Name[1]);
  XSV.NCNamePat11 = re.compile("(%s)$"%_Name11[1]);
Exemple #41
0
	if status['black'] != 'on':
		status['app'] = 'on'
	return status

def transfer_appon(status):
	if status['app'] != 'na' and status['black']!='on':
		status['app'] = 'on'
	return status
	
def transfer_appoff(status):
	if status['app'] != 'na':
		status['app'] = 'off'
	return status

if __name__ == '__main__':
	fsm = FSM()
	action1 = Action()
	action1.transfer = transfer_blackon 
	action1.name = 'black_on'

	action2 = Action()
	action2.transfer = transfer_blackoff
	action2.name = 'black_off'

	action3 = Action()
	action3.transfer = transfer_appin
	action3.name = 'app_in'

	action4 = Action()
	action4.transfer = transfer_appon
	action4.name = 'app_on'
Exemple #42
0
from FSM import *

print "Creating x as follows..."
x = FSM(1, [])
x.addTransition(1, 2, 'ab')
x.addTransition(1, 3, 'b')
x.addTransition(2, 3, 'b')
x.grantAcceptingState(3)
#print x.toString()

x.breakMultipleCharactersTransitions()

print x.toString()

k = FSM.kleene(x)

k.addTransition(1, 3, 'bb')
k.removeTransition(1, 3, 'b')
print k.toString()


print "Determinising..."
dfsm = FSM.determinise(k)
print dfsm.toString()
dfsm.draw()

print "Is abbbbbbabb in dfsm? : " + str(dfsm.match("abbbbbbabb")) 	# True
print "Is abb in dfsm? : " + str(dfsm.match("abb"))		# True
print "Is bb in dfsm? : " + str(dfsm.match("bb"))		# True
print "Is a in dfsm? : " + str(dfsm.match("a"))			# False