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


Python Bot.noise_factor方法代码示例

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


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

示例1: update_state

# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import noise_factor [as 别名]
 def update_state(state, move, outcome):
   """ Update (or create) outcome probabilities for a game state
   and move combo
   
   Arguments:
     state and move: standard notation game strings
     outcome: array of player scores [ player, bot ]
   """
   
   from bot import Bot
   game = BotMoves.find_state(state, move)
   outcome = BotMoves.outcome(outcome)
   if game:
     if game[0].count() > 1: # Dup!
       # Use the most played move
       dups = []
       for game in game[0]: dups.append(game)
       dups.sort(key=lambda g: g.played, reverse=True)
       for i in range(1,len(dups)): dups[i].delete()
       game = dups[0]
     else:
       game = game[0].one()
     game.played += 1
     if outcome == 1: game.wins += 1
     elif outcome == 0: game.draws += 1
     else: game.losses += 1
     game.winp = float(game.wins) / float(game.played);
     game.lossp = float(game.losses) / float(game.played);
     game.drawp = float(game.draws) / float(game.played);
     if game.played_in_sequence >= Bot.noise_factor():
       game.played_in_sequence = 0
     else:
       game.played_in_sequence += 1
     elixir.session.commit()
     # Add mapped flag if all valid moves have been played
     from botmovesmapped import BotMovesMapped
     if not BotMovesMapped.has(game.state):
       from state import State
       state = State(game.state)
       if not Bot.get_missing_move(state):
         BotMovesMapped(state=game.state)
         elixir.session.commit()
   else:
     # Create new record
     w = d = l = 0
     if outcome == 1: w = 1
     elif outcome == 0: d = 1
     else: l = 1
     BotMoves(state=state,
              move=move,
              wins=w,
              draws=d,
              losses=l,
              winp=float(w),
              drawp=float(d),
              lossp=float(l))
     elixir.session.commit()
开发者ID:Andarin,项目名称:qtpy,代码行数:59,代码来源:botmoves.py


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