Ejemplo n.º 1
0
    def __init__(self, window, outtrans, runit, dict, cb):
        self.windows = [window,]
        self.outtrans = outtrans

        self.__duration = dict.get('dur', 1)
        self.__multiElement = dict.get('coordinated')
        self.__childrenClip = dict.get('clipBoundary', 'children') == 'children'

        self.__callback = cb

        trtype = dict.get('trtype', 'fade')
        subtype = dict.get('subtype')
        klass = Transitions.TransitionFactory(trtype, subtype)
        self.__transitiontype = klass(self, dict)

        self.__fiber_id = None
        self.__running = 0

        self.__startprogress = dict.get('startProgress', 0)
        self.__endprogress = dict.get('endProgress', 1)
        if self.__endprogress <= self.__startprogress:
            self.__transperiod = 0
        elif self.__duration <= 0:
            self.__transperiod = 0
            self.__startprogress = self.__endprogress
        else:
            self.__transperiod = float(self.__endprogress - self.__startprogress) / self.__duration

        # shortcut flag for static (not video) transitions
        self._surf_updated = 0

        # rect for use with wnd._paintOnSurf
        # offset windowpos with respect to VisibleWindowPos
        self._paint_rect = None
Ejemplo n.º 2
0
    def __init__(self, window, outtrans, runit, dict, cb):
        self.windows = [
            window,
        ]
        self.outtrans = outtrans

        self.__duration = dict.get('dur', 1)
        self.__multiElement = dict.get('coordinated')
        self.__childrenClip = dict.get('clipBoundary',
                                       'children') == 'children'

        self.__callback = cb

        trtype = dict.get('trtype', 'fade')
        subtype = dict.get('subtype')
        klass = Transitions.TransitionFactory(trtype, subtype)
        self.__transitiontype = klass(self, dict)

        self.__fiber_id = None
        self.__running = 0

        self.__startprogress = dict.get('startProgress', 0)
        self.__endprogress = dict.get('endProgress', 1)
        if self.__endprogress <= self.__startprogress:
            self.__transperiod = 0
            #raise AssertionError
        elif self.__duration <= 0:
            self.__transperiod = 0
            self.__startprogress = self.__endprogress
        else:
            self.__transperiod = float(self.__endprogress -
                                       self.__startprogress) / self.__duration
Ejemplo n.º 3
0
def changeState(curr, new):
    """Verifies is the transition can be made or not.
       If yes, returns the new status name,
       otherwise raises an exception.

       :str curr: current status name
       :str new: new status name."""
    trans = Transitions()
    if new not in trans.states():
        raise TaskStateException("New '%s' status is not valid" %new)
    if curr not in trans:
        raise TaskStateException("Current '%s' status is not valid" %curr)
    if new not in trans[curr]:
        raise TaskStateException("Transition from '%s' to '%s' is forbidden." %(curr, new))
    ## transition is valid
    return new
Ejemplo n.º 4
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        panel = wx.Panel(self, size=(WINDOW_WIDTH, WINDOW_HEIGHT))
        nb = wx.Notebook(panel)

        sl = ScreensList(nb)
        ed = EditorScreens(nb)
        nt = Intro(nb)
        en = Ending(nb)
        st = StoryMode(nb)
        vt = Victory(nb)
        ib = IntroBattle(nb)
        tr = Transitions(nb)

        nb.AddPage(sl, "Screen Lists")
        nb.AddPage(ed, "Editor")
        nb.AddPage(st, "Story Mode")
        nb.AddPage(nt, "Intro")
        nb.AddPage(en, "Ending")
        nb.AddPage(vt, "Victory")
        nb.AddPage(ib, "Intro Battle")
        nb.AddPage(tr, "Transitions")

        sizer = wx.BoxSizer()
        sizer.Add(nb, 1, wx.EXPAND)

        self.SetSizer(sizer)
Ejemplo n.º 5
0
    def __init__(self, window, outtrans, runit, dict, cb):
        self.window = window
        self.outtrans = outtrans
        self.dict = dict
        self.cb = cb

        trtype = dict.get('trtype')
        subtype = dict.get('subtype')
        klass = Transitions.TransitionFactory(trtype, subtype)
        self.__transitiontype = klass(self, self.dict)

        self.__running = 0
        self._lastvalue = None
Ejemplo n.º 6
0
    def __init__(self, window, inout, runit, dict, cb):
        dur = dict.get('dur', 1)
        self.exclude_first_window = 0
        # if this is a coordinated transition with clipBoundary==children we should not
        # include the parent in the clip.
        if dict.get('coordinated') and dict.get('clipBoundary',
                                                'children') == 'children':
            self.exclude_first_window = 1
        self.windows = [window]
        self.outtransition = inout
        self.starttime = time.time()  # Correct?
        self.duration = dur
        self.running = runit
        self.value = 0
        trtype = dict.get('trtype', 'fade')
        subtype = dict.get('subtype')
        self.__callback = cb
        klass = Transitions.TransitionFactory(trtype, subtype)
        self.transitiontype = klass(self, dict)
        self.dstrgn = None
        self.verbatimrgn = None
        self.move_resize()
        self.currentparameters = None

        ##         self.reverse = (dict['direction'] == 'reverse')
        self.reverse = 0
        if not self.reverse:
            self.startprogress = dict.get('startProgress', 0)
            self.endprogress = dict.get('endProgress', 1)
        else:
            self.startprogress = 1.0 - dict.get('endProgress', 1)
            self.endprogress = 1.0 - dict.get('startProgress', 0)
        # Now recompute starttime and "duration" based on these values
        if self.endprogress != self.startprogress:
            self.duration = self.duration / (self.endprogress -
                                             self.startprogress)
        self.starttime = self.starttime - (self.startprogress * self.duration)

        self.__idleid = mw_globals.toplevel.setidleproc(self._idleproc)
Ejemplo n.º 7
0
    def __init__(self):
        self.config = ConfigConfigureGetConfigConfigShowbase
        if self.config.GetBool('use-vfs', 1):
            vfs = VirtualFileSystem.getGlobalPtr()
        else:
            vfs = None
        self.sfxActive = self.config.GetBool('audio-sfx-active', 1)
        self.musicActive = self.config.GetBool('audio-music-active', 1)
        self.wantFog = self.config.GetBool('want-fog', 1)
        self.screenshotExtension = self.config.GetString(
            'screenshot-extension', 'jpg')
        self.musicManager = None
        self.musicManagerIsValid = None
        self.sfxManagerList = []
        self.sfxManagerIsValidList = []
        self.wantStats = self.config.GetBool('want-stats', 0)
        self.exitFunc = None
        taskMgr.taskTimerVerbose = self.config.GetBool('task-timer-verbose', 0)
        taskMgr.extendedExceptions = self.config.GetBool(
            'extended-exceptions', 0)
        taskMgr.pStatsTasks = self.config.GetBool('pstats-tasks', 0)
        taskMgr.resumeFunc = PStatClient.resumeAfterPause
        fsmRedefine = self.config.GetBool('fsm-redefine', 0)
        State.FsmRedefine = fsmRedefine
        try:
            self.clusterSyncFlag = clusterSyncFlag
        except NameError:
            self.clusterSyncFlag = self.config.GetBool('cluster-sync', 0)
        else:
            self.hidden = NodePath('hidden')
            self.graphicsEngine = GraphicsEngine()
            self.setupRender()
            self.setupRender2d()
            self.setupDataGraph()
            self.cTrav = 0
            self.appTrav = 0
            self.dgTrav = DataGraphTraverser()
            self.win = None
            self.winList = []
            self.mainWinMinimized = 0
            self.pipe = None
            self.pipeList = []
            self.mak = None
            self.cam = None
            self.camList = []
            self.camNode = None
            self.camLens = None
            self.camera = None
            self.cameraList = []
            self.camera2d = self.render2d.attachNewNode('camera2d')
            self.oldexitfunc = getattr(sys, 'exitfunc', None)
            sys.exitfunc = self.exitfunc
            if self.config.GetBool('open-default-window', 1):
                self.openMainWindow()
                self.graphicsEngine.renderFrame()
                self.graphicsEngine.renderFrame()
                if self.win.isClosed():
                    self.notify.info('Window did not open, removing.')
                    self.closeWindow(self.win)
                if self.win == None:
                    self.makeAllPipes()
                    while self.win == None and len(self.pipeList) > 1:
                        self.pipeList.remove(self.pipe)
                        self.pipe = self.pipeList[0]
                        self.openMainWindow()
                        self.graphicsEngine.renderFrame()
                        self.graphicsEngine.renderFrame()
                        if self.win.isClosed():
                            self.notify.info('Window did not open, removing.')
                            self.closeWindow(self.win)

        self.loader = Loader.Loader(self)
        self.eventMgr = eventMgr
        self.messenger = messenger
        self.taskMgr = taskMgr
        self.particleMgr = particleMgr
        self.particleMgr.setFrameStepping(1)
        self.particleMgrEnabled = 0
        self.physicsMgr = physicsMgr
        integrator = LinearEulerIntegrator()
        self.physicsMgr.attachLinearIntegrator(integrator)
        self.physicsMgrEnabled = 0
        self.physicsMgrAngular = 0
        self.createBaseAudioManagers()
        self.createStats()
        self.AppHasAudioFocus = 1
        __builtins__['base'] = self
        __builtins__['render2d'] = self.render2d
        __builtins__['aspect2d'] = self.aspect2d
        __builtins__['render'] = self.render
        __builtins__['hidden'] = self.hidden
        __builtins__['camera'] = self.camera
        __builtins__['loader'] = self.loader
        __builtins__['taskMgr'] = self.taskMgr
        __builtins__['eventMgr'] = self.eventMgr
        __builtins__['messenger'] = self.messenger
        __builtins__['config'] = self.config
        __builtins__['run'] = self.run
        __builtins__['ostream'] = Notify.out()
        __builtins__['directNotify'] = directNotify
        __builtins__['globalClock'] = ClockObject.getGlobalClock()
        __builtins__['vfs'] = vfs
        self.accept('window-event', self.__windowEvent)
        import Transitions
        self.transitions = Transitions.Transitions(self.loader)
        self.startTk(self.config.GetBool('want-tk', 0))
        self.startDirect(self.config.GetBool('want-directtools', 0))
        self.restart()
        return
Ejemplo n.º 8
0
    print(episodes)

    exit(0)

    height = 4  # square gridworld
    width = 4

    import Grid

    grid = Grid.GridWorld(height, width)
    grid.print_grid()

    actions = ["up", "down", "right", "left"]

    import Transitions
    x = Transitions.Transitions_Probs(grid, actions)
    x.create_common_transition(
        "Deterministic")  # ("Bernoulli",0.7)) # "Deterministic"

    import Rewards
    sparse_reward = Rewards.Reward(grid, actions)
    sparse_reward.common_reward("sparse")

    discount = 0.2
    policy = np.ones((len(grid.states), len(actions))) * 0.25  # uniform policy

    state_values = iterative_bellman_equation(
        grid, actions, policy,
        discount=discount)  # approximate the true state values

    from Agent import Agent as agent
Ejemplo n.º 9
0
        """
        knownstates = set(self.keys())
        for possiblestates in self.values():
            for i in possiblestates:
                knownstates.add(i)
        return list(knownstates)



if __name__ == '__main__':
    import Transitions
    a = Transitions.Transitions()
    print "Available states", a.states()

    try:
        Transitions.changeState('submitted','failed')
    except:
        pass
    Transitions.changeState('submitted','killed')
    Transitions.changeState('submitted','resubmit')
    Transitions.changeState('submitted','closed')

    try:
        Transitions.changeState('queued','queued')
    except:
        pass
    Transitions.changeState('queued','submitted')
    Transitions.changeState('queued','failed')

    try:
        Transitions.changeState('killed','submitted')