本文整理汇总了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()