当前位置: 首页>>代码示例>>Python>>正文


Python state.State类代码示例

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


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


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