• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python state.State类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中state.State的典型用法代码示例。如果您正苦于以下问题:Python State类的具体用法?Python State怎么用?Python State使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了State类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: tone

 def tone(self,who,val,unused=None,force=False):
     # who is 'M','A','B','C','D','TR'
     if force or val != self.preset.currentDict[who][1]:
         State.printT('TONE:\t' + str(who) +'\t' + str(val))
         trVal = 'Off'
         toneVal = '0'
         if who =='TR':
             trVal =  str(val-1) if val else 'Off'
             targ = 'M'
             toneVal = None
         elif who == 'M':
             targ = who
             trVal = None
             toneVal = str(val-1) if val else 'Off'
             self.mEval.set(1,val)
         else:
             targ = who
             trVal = '0' if val else 'Off'
             toneVal = str(val-1) if val else 'Off'
         if trVal != None:
             #self.outgoing.append("a.set('%s',State.ToneRange,State.l%s)"%(targ,trVal))
             self.set(targ,State.ToneRange,eval('State.l%s'%trVal))
         if toneVal != None:
             #self.outgoing.append("a.set('%s',State.Tone,State.l%s)"%(targ,toneVal))
             self.set(targ,State.Tone,eval('State.l%s'%toneVal))
         self.preset.currentDict[who][1] = val
         return True
     return False
开发者ID:gratefulfrog,项目名称:ArduGuitar,代码行数:28,代码来源:appT.py


示例2: test_eu_proposition_2

def test_eu_proposition_2():
    t = Transition([0], [1])
    p = PetriNet([t])
    s1 = State([0,2], p)
    prop = EUProposition(LessProposition(NumericExpression(0),
    VariableExpression(0)), TrueProposition())
    assert s1.evaluate(prop) == True
开发者ID:bivab,项目名称:pytri,代码行数:7,代码来源:test_proposition.py


示例3: test_eg_loop

def test_eg_loop():
    t = Transition([0], [0])
    p = PetriNet([t])
    s1 = State([1], p)
    prop = EGProposition(TrueProposition())
    assert s1.evaluate(prop) == True
    assert len(p._states_cache) == 1
开发者ID:bivab,项目名称:pytri,代码行数:7,代码来源:test_proposition.py


示例4: install

    def install(self, target: Target, state: State, output: Output):
        """Installs CMake.

        CMake is not easily buildable on Windows so we rely on a binary
        distribution

        Parameters
        ----------
        target: Target
            The target platform and architecture.
        state: State
            The state of the bootstrap build.
        output: Output
            The output helper.
        """
        print("")
        output.print_step_title("Installing CMake")
        if state.cmake_path == "":
            self._install(target)
            print("    CMake installed successfully")
        else:
            self.path = state.cmake_path
            print("    Using previous installation: " + self.path)
        state.set_cmake_path(self.path)
        output.next_step()
开发者ID:CodeSmithyIDE,项目名称:Bootstrap,代码行数:25,代码来源:cmake.py


示例5: test_ex_proposition

def test_ex_proposition():
    t1 = Transition([0], [1])
    t2 = Transition([1], [2])
    p = PetriNet([t1, t2])
    s1 = State([1,1,0], p)
    prop = EXProposition(EqualsProposition(VariableExpression(0), NumericExpression(0)))
    assert s1.evaluate(prop) == True
开发者ID:bivab,项目名称:pytri,代码行数:7,代码来源:test_proposition.py


示例6: setUp

 def setUp(self):
     pygame.mixer.init()
     self.player = PlayerSprite()
     self.invScreen = InventoryScreen(self.player)
     self.invScreen.lines = ['Test1', 'Test2']
     State.screens = []
     State.push_screen(self.invScreen)
开发者ID:nhandler,项目名称:cs429,代码行数:7,代码来源:test_inventoryScreen.py


示例7: loadconfig

def loadconfig():
    state = State()
    data = yaml.safe_load(file.read(file(configfile, 'r')))

    for k in data:
        try:
            for rule in data[k]['rules']:
                try:
                    source = getattr(network, rule['source'])
                    state.add_rule(source, rule['value'], k, rule['confidence'])
                except TypeError:
                    pass
        except TypeError:
            pass
        except KeyError:
            pass

        try:
            state[k].in_actions.extend(map(lambda string:getattr(actions, string), data[k]['in_actions']))
        except TypeError:
            pass

        try:
            state[k].out_actions.extend(map(lambda string:getattr(actions, string), data[k]['out_actions']))
        except TypeError:
            pass
    return state
开发者ID:berdario,项目名称:magellan,代码行数:27,代码来源:loader.py


示例8: _apply_change

    def _apply_change(self, change, remote_id):
        """Apply the change provided to the server state,
        then tell all of the remotes about it
        Params:
        change -- the Change object to apply
        remote_id -- the id number of the remote providing the change
        """
        # find the source state of the change
        source_node = self.root.find_source_of(change, remote_id)
        source_operation = Operation.from_change(change, None)

        # transform down to the tip
        new_tip_operation = source_node.transform_to_tip(source_operation, remote_id)
        new_tip_operation.apply(self.value)
        new_tip = new_tip_operation.end
        
        youngest_root = State(new_tip.pos)

        # tell the remotes about the change
        for cur_remote_id, remote in self.remotes.iteritems():
            if cur_remote_id == remote_id:
                remote.server_ack_to_client(new_tip.make_ack(cur_remote_id), new_tip.pos)
            else:
                remote.server_change_available(self.tip.make_change(cur_remote_id))
            youngest_root.age_to_include(remote.last_acked_state)

        self.tip = new_tip

        # see if I can move the root to a younger node
        while self.root.operation is not None and \
                not self.root.operation.end.pos.is_younger_than(youngest_root):
            self.root = self.root.operation.end
开发者ID:leighpauls,项目名称:opt_algos,代码行数:32,代码来源:server.py


示例9: update

    def update(self,name, att, state=State.connectionUpdateOnly):
        """ To call update(...) on name, att, state
        >>> update('A',State.Inverter,State.l2)
        To call update(...) on connections
        >>> update(('A',0),('B',1))
        this method sets up the call to doSettingMasking 
        which makes the member variable assignments
        ---
        Note that there is a procedural difference between updating
        a Vol, Tone,ToneRang, Inverter setting, and updating a connection
        setting.
        In the former case, the non-affecting attributes are maintained. 
        In the latter case, all the connection settings are reset prior to 
        updating. Examples:
        If we had  'A', Vol, l3 already, then we set 'A', Inverter, 1, then
        both the vol and inverter settings are maintained.
        But if we have some connections and we add are starting a new one then
        the previous ones are erased. However, if we have already started
        adding connections, then the previous NEW ones are maintained.
        """
        if state == State.connectionUpdateOnly:
            self.doSettingMasking(connectionsDict[(name,att)],[])
        else:
            # all states can be 'State.lOff', ie None !
            onOff = not state == State.lOff
            (setting, masking) = BitMgr.baseFunc(onOff,
                                                 name,
                                                 att,
                                                 state)
            State.printT(setting,masking)  # this is ok!
            # for a.set('A',State.Inverter,State.l0)
            # ((4, 0), (4, 3)) ((4, 240),)

            self.doSettingMasking(setting,masking)
开发者ID:gratefulfrog,项目名称:ArduGuitar,代码行数:34,代码来源:bitMgr.py


示例10: __init__

    def __init__(self, surf, prev):
        """

        :param surf:
        :param prev:
        """
        State.__init__(self, surf, prev)
开发者ID:Pafycio,项目名称:Pendomotion,代码行数:7,代码来源:menu_state.py


示例11: Game

class Game():   
    
    def __init__(self, gru_file=None):
        
        self.compiler = Compiler()
        if gru_file:
            self.stream = self.compiler.decompile(gru_file) 
        else:            
            self.stream = self.compiler.compile(None)   
        self.metadata = self.stream.metadata   
        self.flags = Flags(self.stream)
        self.wheel = Wheel(config)
        self.title = Title(config)
        self.inventory = Inventory(self.stream, self.flags, config)
        self.combiner = Combiner(self.stream, self.flags, self.inventory)
        self.page = Page(config, self.flags, self.combiner, self.inventory)
        self.state = State(self.stream, self.flags, self.inventory, self.wheel, self.combiner, self.title, self.page)               
        if self.metadata.has_key("start"):
            start = self.metadata["start"]
            self.state.update(start)
        else:
            self.state.update("start")

    def draw(self, tick):
        self.inventory.draw()
        self.wheel.draw()
        self.title.draw()
        self.page.draw(tick)

    
        
        
        
开发者ID:Teognis,项目名称:GruEngine,代码行数:28,代码来源:game.py


示例12: StateTests

class StateTests(unittest.TestCase):
    def setUp(self):
        self.state = State('S', ['VP', 'NP'], 0, 0, 0)

    def test_is_complete(self):
        self.assertFalse(self.state.is_complete())

        self.state.dot = 1
        self.assertFalse(self.state.is_complete())

        self.state.dot = 2
        self.assertTrue(self.state.is_complete())

        self.state.dot = 3
        self.assertFalse(self.state.is_complete())

    def test_next_cat(self):
        self.assertEqual(self.state.next_cat(), 'VP')

        self.state.dot = 1
        self.assertEqual(self.state.next_cat(), 'NP')

        self.state.dot = 2
        self.assertEqual(self.state.next_cat(), None)

    def test_after_dot(self):
        self.assertEqual(self.state.after_dot(), 'VP')

        self.state.dot = 1
        self.assertEqual(self.state.after_dot(), 'NP')

        self.state.dot = 2
        self.assertEqual(self.state.after_dot(), None)
开发者ID:justindomingue,项目名称:nlp,代码行数:33,代码来源:test_state.py


示例13: __init__

class Game:
	def __init__(self, host, port):
		self.gameId = 0
		self.state = None
		self.host = host
		self.port = port

	def init(self, nickname, level):
        response = self.get_post_request(self.host, self.port, '/init/' + str(level), {'nickname': nickname, 'scaffold': 'python'})
		json_root = json.loads(response)
		self.gameId = json_root['gameId']
		self.update_board(json_root['board'])
	
	def move(self, col):
		response = self.get_post_request(self.host, self.port, '/game/move/' + str(self.gameId), {'move': col})
		json_root = json.loads(response)
		self.update_board(json_root['board'])

	def update_board(self, board):
		cols = len(board)
		rows = len(board[0])
		self.state = State(rows, cols)
		for col_i, col in enumerate(board):
			for row_i, slot in enumerate(col):
				self.state.setSlot(row_i, col_i, slot)

	def get_post_request(self, host, port, url, params):
		params = urllib.urlencode(params)
		headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
		conn = httplib.HTTPConnection(host, port)
		conn.request('POST', url, params, headers)
		return conn.getresponse().read()
开发者ID:markdrago,项目名称:four-in-a-row,代码行数:32,代码来源:game.py


示例14: pb0Func

 def pb0Func(self):
     if self.sequencing:
         State.printT('pb0Func:\tstepping the sequence...')
         #State.debug and input('Press Return:')
         return self.doNextSeq()
     else:
         return false
开发者ID:gratefulfrog,项目名称:ArduGuitar,代码行数:7,代码来源:appT.py


示例15: _update

 def _update(self):
     State._update(self)
     
     if(not self.fight_ended and (self.character.isDead() or self.dragon.isDead()) ):
         self.fight_ended = True
         self.enterResolutionMode()
         if(not self.character.isDead()):
             self.character.level += 1
             Consts.MONEY += 150
     
     #buttons
     if(self.is_in_resolution):
         self.continue_button._update()
     else:
         self.attack_button._update()
         self.defense_button._update()
         self.spell_button._update()
         self.charge_button._update()
     
     self.run_button._update()
     #characters
     self.character.update()
     self.dragon.update()
     
     return self.next_state
开发者ID:alfonsoaranzazu,项目名称:StepFight,代码行数:25,代码来源:stateFight.py


示例16: loadConf

 def loadConf(self, conf):
     try:
         #res = self.doParse(conf[self.conf.vocab.configKeys[7]])
         self.doParse(conf[self.conf.vocab.configKeys[7]])
         """
         for e in res:
             #print(e)
             self.outgoing.append(e)
         """
         for key in self.preset.currentDict.keys():
             self.preset.currentDict[key] = conf[key]
     except Exception as e:
         print (e)
         self.doParse(self.conf.presetConf.defaultConfDict[self.conf.vocab.configKeys[7]])
         for key in self.conf.presetConf.defaultConfDict.keys():
             self.preset.currentDict[key] = self.conf.presetConf.defaultConfDict[key]
         self.preset.currentDict[self.conf.vocab.configKeys[0]] = 'DEFAULT PRESET'
     
     self.tone('TR',self.preset.currentDict['TR'][1],force=True)
     for c in ['A','B','C','D','M']:
         self.vol(c,self.preset.currentDict[c][0],force=True)
         self.tone(c,self.preset.currentDict[c][1],force=True)
     self.lcdMgr.loadConf()
     self.trem(self.preset.currentDict[self.conf.vocab.configKeys[8]])
     self.vib(self.preset.currentDict[self.conf.vocab.configKeys[9]])
     self.tracking(self.preset.currentDict[self.conf.vocab.configKeys[10]])
     State.printT(self.outgoing)
开发者ID:gratefulfrog,项目名称:ArduGuitar,代码行数:27,代码来源:appTest.py


示例17: extend_state

    def extend_state(self, state):
        if len(state) == self.d:
            if state.calc_info() >= self.j:
                self.T.append(state)
            return

        Q = []
        g_i = state.most_recent_gene()

        for g_k in self.graph.neighbors_iter(g_i):
            if g_k < g_i: continue
            if g_k in state: continue

            for e in self.C:
                new_state = State(state.genes + [g_k], state.expr_ptn + [e], self.expression)
                redundant = False

                for g_j in state.iter_gene():
                    if new_state.calc_info_omit(g_j) >= new_state.calc_info():
                        redundant = True
                        break

                if not redundant and new_state.calc_info_bound() >= self.j:
                    Q.append(new_state)

        if not Q:
            if state.calc_info() >= self.j:
                self.T.append(state)
            return

        Q_b = sorted(Q, key=lambda s: - s.calc_info())[:self.b]

        for new_state in Q_b:
            self.extend_state(new_state)
开发者ID:mrorii,项目名称:crane,代码行数:34,代码来源:core.py


示例18: sa_search

    def sa_search(graph, budget, timer):
        # Might be able to simplify this.
        cycle = list(range(0, len(graph.nodelist)))
        #random.shuffle(cycle)
        state = State(graph, cycle, [])
        best = state.get_cpy()

        while timer.get_secs() < budget:
            temp = Search.schedule(timer.get_secs(), budget)

            if temp <= 0:
                break

            #nextop = random.choice(oplist)
            nextstate = state.get_cpy()
            nextstate.swap_nodes()
            deltae =  state.cost - nextstate.cost

            if deltae > 0:
                state = nextstate
            else:
                if math.exp(float(deltae)/float(temp)) > random.uniform(0,1):
                    state = nextstate

            if state.cost < best.cost:
                best = state.get_cpy()

        return best
开发者ID:pcm2718,项目名称:psychic-longbow,代码行数:28,代码来源:search.py


示例19: __init__

 def __init__(self, current=0):
     State.__init__(self)
     self.ui = UI(self, Jules_UIContext)
     self.nextState = GameStart
     logo_duration = 20 * 1000
     scores_duration = 5 * 1000
     self.displays = [(logo_duration, self.draw_logo),
                     (scores_duration, self.draw_high_scores)]
     self.eventid = TimerEvents.SplashScreen
     self.current = current
     self.draw = self.displays[self.current][1]
     self.instructions = ['Can you think fast and react faster?',
                          'This game will test both.',
                          'Your job is to destroy the bonus blocks.',
                          'Sounds easy, right?... Wrong!',
                          'There are several problems.',
                          'If you destroy a penalty block you lose 200 pts.',
                          'If you get 3 penalties, you lose a life.',
                          'If you lose 3 lives, the game is over.',
                          'The bonus and penalty blocks',
                          'change colors every 5 seconds.',
                          'And on top of that, if you do not destroy a',
                          'random non-bonus, non-penalty block every',
                          'couple of seconds, that will give you a',
                          'penalty too. Think you got all that?']
开发者ID:CodeSkool,项目名称:SimpleGUI2Pygame,代码行数:25,代码来源:React.py


示例20: Manuscript

class Manuscript(object):

    def __init__ (self, num, acc_date = date.today()):
        self.number = num
        self.state = State(acc_date)
        self.eng_rev = False

    def new_state(self, state, date = date.today()):
        '''Indicates that the manuscript reached a new state in the
        publication process'''
        self.state.set_state(state, date)

    def is_revised(self):
        '''Returns true if the manuscript was submitted to language revision'''
        return self.eng_rev

    def set_revised(self):
        '''Informs that a manuscript has been submitted to language revision'''
        self.eng_rev = True

    def __str__(self):
        if self.is_revised():
            eng_status = 'Abstract revised'
        else:
            eng_status = 'Abstract NOT revised'

        return ('\n%s:\n\n%s%s\n' % (self.number, self.state, eng_status))
开发者ID:holypriest,项目名称:editsys,代码行数:27,代码来源:manuscript.py



注:本文中的state.State类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python statemachine.StateMachine类代码示例发布时间:2022-05-27
下一篇:
Python state.load函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap