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


Python State.board方法代码示例

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


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

示例1: test_bot

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import board [as 别名]
    def test_bot():
        import gomill

        logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',
                            level=logging.DEBUG)

        DCL_PATH = '/home/jm/prj/DeepCL/'
        deepcl_io = bot_deepcl.DeepCL_IO(os.path.join(DCL_PATH, 'build/predict'), options={
            'weightsfile': os.path.join(DCL_PATH, "build/weights.dat"),
            'outputformat': 'binary',
                })

        player = DistWrappingMaxPlayer(DeepCLDistBot(deepcl_io))

        class State:
            pass
        s = State()

        b = gomill.boards.Board(19)
        s.board = b
        s.ko_point = None
        logging.debug("bot: %s"% repr(player.genmove(s, 'w').move))
开发者ID:jmoudrik,项目名称:deep-go-wrap,代码行数:24,代码来源:bot_deepcl.py

示例2: MainWindow

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import board [as 别名]
class MainWindow(object):

    __metaclass__ = MetaSignals
    signals = ["keypress", "quit"]

    _palette = [
        ('divider', 'black', 'light gray'),
        ('text', 'white', 'default'),

        ('number', 'dark green', 'default'),
        ('time', 'dark gray', 'default'),
        ('quote', 'light green', 'default'),

        ('highlight', 'yellow', 'default'),
        ('underline', 'yellow', 'default', 'underline'),
        ('bold', 'yellow', 'default', 'bold'),
        ('body', 'text'),
        ('footer', 'text'),
        ('header', 'text'),
    ]

    def __init__(self, sender="1234567890"):
        self.mark_quit = False
        self.sender = sender

        self.state = State()

    def main(self):
        """Entry point."""
        self.ui = urwid.raw_display.Screen()
        self.ui.register_palette(self._palette)
        self.build_ui()
        self.ui.run_wrapper(self.run)

    def build_ui(self):
        """Build the urwid UI."""
        self.header = urwid.Text("Chancli")
        self.content = urwid.SimpleListWalker([])
        self.content.append(self.state.splash())
        self.body = urwid.ListBox(self.content)
        self.divider = urwid.Text("Type help for instructions, exit to quit.")
        self.footer = urwid.Edit("> ")

        self.header = urwid.AttrWrap(self.header, "divider")
        self.body = urwid.AttrWrap(self.body, "body")
        self.divider = urwid.AttrWrap(self.divider, "divider")
        self.footer = urwid.AttrWrap(self.footer, "footer")

        self.footer.set_wrap_mode("space")

        main_frame = urwid.Frame(self.body, header=self.header, footer=self.divider)
        
        self.context = urwid.Frame(main_frame, footer=self.footer)
        self.context.set_focus("footer") # Focus on the user input first

    def run(self):
        """Setup and start mainloop."""

        def input_handler(key):
            if self.mark_quit:
                raise urwid.ExitMainLoop
            self.keypress(self.size, key)

        self.size = self.ui.get_cols_rows()

        self.main_loop = urwid.MainLoop(
                self.context,
                screen=self.ui,
                handle_mouse=False,
                unhandled_input=input_handler
        )

        # Disable bold on bright fonts
        self.main_loop.screen.set_terminal_properties(bright_is_bold=False)

        try:
            self.main_loop.run()
        except KeyboardInterrupt:
            self.quit()

    def print_content(self, text):
        """Print given text as content."""
        # Accept strings, convert them to urwid.Text instances
        if not isinstance(text, (urwid.Text, urwid.Pile)):
            text = urwid.Text(text)

        self.content.append(text)

    def parse_input(self):
        """Parse input data."""
        text = self.footer.get_edit_text()

        # Remove input after submitting
        self.footer.set_edit_text("")

        # input: description
        # -------------------------------------------------------------
        # exit, quit, q: exit the application
        # help: show help page
        # license: show license page
#.........这里部分代码省略.........
开发者ID:gimu,项目名称:chancli,代码行数:103,代码来源:chancli.py


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