本文整理汇总了Python中brain.Brain.parse_line方法的典型用法代码示例。如果您正苦于以下问题:Python Brain.parse_line方法的具体用法?Python Brain.parse_line怎么用?Python Brain.parse_line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类brain.Brain
的用法示例。
在下文中一共展示了Brain.parse_line方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IOPokerBot
# 需要导入模块: from brain import Brain [as 别名]
# 或者: from brain.Brain import parse_line [as 别名]
class IOPokerBot(object):
"""Generic Poker Bot, can read & write lines.
Subclasses should mix-in parser & action delegates
"""
def __init__(self, io_input, io_output, log_output):
self.io_input = io_input
self.action_out = io_output
self.log_out = log_output
self.brain = Brain(self)
def run(self):
""" Main run loop """
while not self.io_input.closed:
try:
rawline = self.io_input.readline()
if len(rawline) == 0:
break
line = rawline.strip()
self.brain.parse_line(line)
except EOFError:
return
def say(self, line):
"""Writes a line where the game controller can see it"""
self.write_line(line, self.action_out)
self.log("SAID :: {l}".format(l=line))
def log(self, line):
"""Writes a line somewhere we can log it"""
self.write_line(line, self.log)
def write_line(self, line, dest):
if line and dest:
dest.write(line)
dest.write('\n')
dest.flush()