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


Python State.transition方法代码示例

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


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

示例1: extract_inequality

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import transition [as 别名]
def extract_inequality(prev, next, input):
  state = State(prev)
  currents = list(reversed(map(lambda i: input[i], state.unstables())))

  if next == state.transition(State.left).state:
    return ( (-1, currents[0]), (1, currents[1]), (1, prev) )
  elif next == state.transition(State.right).state:
    return ( (1, currents[0]), (-1, currents[1]), (-1, prev) )
开发者ID:derfred,项目名称:cyclotron,代码行数:10,代码来源:inequality_decider.py

示例2: __init__

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import transition [as 别名]
class Theta:
  def __init__(self, state):
    self.state = State(state)
    self.left  = []
    self.right = []

  def add(self, to, input):
    currents = map(lambda i: input[i], self.state.unstables())
    currents.reverse()

    if to == self.state.transition(State.left).state:
      if currents not in self.left:
        self.left.append(currents)
    elif to == self.state.transition(State.right).state:
      if currents not in self.right:
        self.right.append(currents)
    else:
      raise "hell"

  def add_constraints_to(self, program):
    for left in self.left:
      program.add_constraint( program[left[0]]-program[left[1]]+1 <= program["T"+self.state.state] )

    for right in self.right:
      program.add_constraint( program[right[0]]-program[right[1]]-1 >= program["T"+self.state.state] )

  def switch(self, input, params):
    currents = map(lambda i: params[input[i]], self.state.unstables())
    delta    = currents[1] - currents[0]
    boundary = params.get("T"+self.state.state, 0)

    if delta < boundary:
      return [self.state.transition(State.left)]
    elif delta > boundary:
      return [self.state.transition(State.right)]
    else:
      return [self.state.transition(State.left), self.state.transition(State.right)]
开发者ID:derfred,项目名称:cyclotron,代码行数:39,代码来源:solution.py

示例3: transition

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import transition [as 别名]
 def transition(self):
     TimerEvents().stop(self.eventid)
     State.transition(self)
开发者ID:CodeSkool,项目名称:SimpleGUI2Pygame,代码行数:5,代码来源:React.py

示例4: fromText

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import transition [as 别名]
            ops = fromText(operation)
        except KeyError:
            ops = None
        if ops:
            tup = s.toTuple()
            count[tup] = count.get(tup, 0) + 1
            
            ac = actionCount.get(tup, {})
            ac[ops] = ac.get(ops,0) + 1
            actionCount[tup] = ac

            if tup not in action:
                action[tup] = [(ops, duration)]
            else:
                action[tup].append((ops, duration))
            s.transition(ops)
    s.init()
    prev_time = 0

print s.range()

toBeSort = []
toBeSort2 = []
for k in count:
    toBeSort.append((count[k], k))
    toBeSort2.append((len(actionCount[k]), k))
toBeSort.sort(reverse = True)
toBeSort2.sort(reverse = True)

for i in range(len(toBeSort)):
    print toBeSort[i][0], toBeSort2[i][0]
开发者ID:rivercheng,项目名称:Random-Trace,代码行数:33,代码来源:test.py


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