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


Python State.is_def方法代码示例

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


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

示例1: take

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import is_def [as 别名]
  def take(self, state):
    """Changes the state of the cell to taken by either player.

    Allows the caller to change the state of this cell to any state defined
    in the board.state module (except for State.EMPTY). If the specified state
    is not defined in the baord.state module, or the state is State.EMPTY,
    this will raise an exception to be hadled by the caller.

    Args:
      state: Any state defined in the board.State module.

    Raises:
      IllegalStateChangeException: Raised if the caller tries to change the
        state on a taken cell, changes the state to empty, or if the state is
        not a known state.
    """
    logging.debug('Attempting to change state from %s to %s',
                  self.state, state)
    if self.state != State.EMPTY:
      raise IllegalStateChangeException('Cannot change state of taken cell.')
    elif state == State.EMPTY:
      raise IllegalStateChangeException('Cannot take with empty state')
    elif State.is_def(state):
      self.state = state
    else:
      raise IllegalStateChangeException('State %s is undefined' % state)
开发者ID:bwreher,项目名称:tic-tac-toe,代码行数:28,代码来源:cell.py

示例2: testIsDefWithValidStates

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import is_def [as 别名]
 def testIsDefWithValidStates(self):
  self.assertTrue(State.is_def(State.TAKEN_X))
  self.assertTrue(State.is_def(State.TAKEN_O))
  self.assertFalse(State.is_def('foo_player'))
开发者ID:bwreher,项目名称:tic-tac-toe,代码行数:6,代码来源:state_test.py


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