def __init__(self): self.engine = simple_go.Game(19) self.master = GTP_controller(sys.stdin, sys.stdout) self.version = version.number self.name = version.name + version.message self.komi = 0.0 self.handicap = 0 self.sgf_number = 1 # total number of gtpc-logfiles for i in range(1000): log_name = "gtpc%03i.log" % i if not os.path.exists(log_name): break self.log_fp = open(log_name, "w") self.clock = time_settings.Timekeeper() # note formatting: follow newline with tab self.cmd_options = { "help": "Can also use '-h'. Displays this message.", "message=": "Message robot gives on new games\n\tQuotes required for spaces.", "node_limit=": "Positive integer\n\tSpecifies the normal depth of the search.", "manage_time": "If passed to program, uses time management.", "urgent_time=": "Positive integer\n\tIf this is how long it has per move,\n\tradically adjusts node limit.", "urgent_node=": "Positive integer\n\tWhen urgent time per move is reached, this is the number of nodes used." }
def speed(n): g = simple_go.Game(19) t0 = time.time() for i in xrange(n): b = g.current_board.copy() t1 = time.time() t_elapsed = t1-t0 print t_elapsed, n/t_elapsed
def boardsize(self, size): if size < 9 or size > 19: return "? unacceptable size\n\n" self.size = size self.engine.exec_cmd("quit") self.engine = GTP_connection(self.engine_command) result = self.engine.exec_cmd("boardsize " + str(size)) if result[0] == "?": return result self.slave.exec_cmd("boardsize " + str(size)) self.slave.exec_cmd("clear_board") self.simple_engine = simple_go.Game(size) return self.ok()
def __init__(self): self.engine = simple_go.Game(19) self.master = play_gtp.GTP_controller(sys.stdin, sys.stdout) self.version = "0.0.2" self.name = "IdiotBot: I play mostly randomly: if I'm too easy, try WeakBot50k. Its maybe 60 stones stronger. 30k humans are often 80 stones stronger. My info contains links to my source code: " self.komi = 0.0 self.handicap = 0 # total number of gtpc-logfiles for i in range(1000): log_name = "gtpc%03i.log" % i if not os.path.exists(log_name): break self.log_fp = open(log_name, "w")
def __init__(self): #if config.use_opening_library: # self.opening_tree = {} # for color in "WB": # self.opening_tree[color + "0"] = cgos_opening_tree.OpeningTree("opening%s_0.dat" % color, None) # self.opening_tree[color] = cgos_opening_tree.OpeningTree("opening%s.dat" % color, None) self.engine = simple_go.Game(9) self.master = GTP_controller(sys.stdin, sys.stdout) self.version = version.number #self.name = version.name + version.message self.name = version.name self.komi = 0.0 self.handicap = 0 self.capture_all_dead = False log_name = get_next_filename("gtpc%04i.log") self.log_fp = open(log_name, "w") self.clock = None self.move_generated = False komi = 6.5 self.engine.set_komi(komi) # note formatting: follow newline with tab self.cmd_options = { "help": "Can also use '-h'. Displays this message.", "message=": "Message robot gives on new games\n\tQuotes required for spaces.", "node_limit=": "Positive integer\n\tSpecifies the normal depth of the search for a 9x9 game.", "manage_time": "If passed to program, uses time management.", "capture_all_dead": "If passed to program, will capture all dead before passing" } self.mode = None self.randomcount = 0 print 'ready to setting ' #jobmgr, network ¼³Á¤. self.m_network = network() self.m_network.init2() self.engine.network = self.m_network self.m_jobmgr = jobmgr2(self.mode) print 'setting is done'
def load_file(name): s = open(name).read() parts = string.split(s, ";") header = parts[1] moves = parts[2:] sz = re.match(r".*SZ\[(\d+)\].*", header, re.DOTALL) if sz: g = simple_go.Game(int(sz.group(1))) else: raise ValueError, "no size tag" ha = re.match(r".*AB(.*?)P.*", header, re.DOTALL) if ha: for move in string.split(ha.group(1)[1:-1], "]["): if g.current_board.side == simple_go.WHITE: g.make_move(simple_go.PASS_MOVE) if not g.make_move(sgf2tuple(g.size, move)): raise ValueError, move for move_str in moves: m = re.match(r".*?(\w+)\[(.*?)\](.*)", move_str, re.DOTALL) if m: color = m.group(1) move = m.group(2) rest = m.group(3) if color in ("B", "W"): if (g.current_board.side == simple_go.BLACK) != (string.upper( color[0]) == "B"): g.make_move(simple_go.PASS_MOVE) if not g.make_move(sgf2tuple(g.size, move)): raise ValueError, move elif color in ("AW", "AB"): while move and color in ("AW", "AB"): if (g.current_board.side == simple_go.BLACK) != (string.upper(color[1]) == "B"): g.make_move(simple_go.PASS_MOVE) if not g.make_move(sgf2tuple(g.size, move)): raise ValueError, move m = re.match(r"\[(.*?)\](.*)", rest, re.DOTALL) if m: move = m.group(1) rest = m.group(2) else: m = re.match(r"(\w+)\[(.*?)\](.*)", rest, re.DOTALL) if m: color = m.group(1) move = m.group(2) rest = m.group(3) else: move = None return g
def __init__(self, command1, command2, name, version): self.engine_command = command1 self.engine = GTP_connection(self.engine_command) self.simple_engine = simple_go.Game(19) self.slave = GTP_connection(command2) self.master = GTP_controller(sys.stdin, sys.stdout) self.version = version self.name = name self.time_delay = False self.time = 600 # total number of gtpc-logfiles log_name = get_next_filename("gtpc%04i.log") self.log_fp = open(log_name, "w") self.size = 19
def __init__(self, command1, command2, name, version): self.engine_command = command1 self.engine = GTP_connection(self.engine_command) self.simple_engine = simple_go.Game(19) self.slave = GTP_connection(command2) self.master = GTP_controller(sys.stdin, sys.stdout) self.version = version self.name = name # total number of gtpc-logfiles for i in range(1000): log_name = "gtpc%03i.log" % i if not os.path.exists(log_name): break self.log_fp = open(log_name, "w") self.size = 19
def boardsize(self, size): if size < 5 or size > 19: return "? unacceptable size\n\n" self.size = size self.engine.exec_cmd("quit") self.estimate_engine.exec_cmd("quit") self.engine = GTP_connection(self.engine_command) self.estimate_engine = GTP_connection(self.engine_command) #self.engine.exec_cmd("set_random_seed 1") #self.estimate_engine.exec_cmd("set_random_seed 1") result = self.engine.exec_cmd("boardsize " + str(size)) if result[0] == "?": return result self.estimate_engine.exec_cmd("boardsize " + str(size)) self.engine.exec_cmd("clear_board") self.estimate_engine.exec_cmd("clear_board") self.random_engine = simple_go.Game(size)
def diagram2game(str): g = None for line in string.split(str, "\n"): line = string.strip(line) if not line: continue if line[0]=="A" and not g: g = simple_go.Game(len(line)) elif line[0] in string.digits: y, line, rest = string.split(line, "|") y = int(y) for x in range(len(line)): stone = line[x] x = x + 1 if stone in WHITE+BLACK: if g.current_board.side!=stone: g.make_move(PASS_MOVE) g.make_move((x, y)) return g
def boardsize(self, size): if size < 9 or size > 19: return "? unacceptable size\n\n" self.size = size self.engine.exec_cmd("quit") self.engine = GTP_connection(self.engine_command) result = self.engine.exec_cmd("boardsize " + str(size)) if result[0] == "?": return result result = self.engine.exec_cmd("clear_board") self.slave.exec_cmd("boardsize " + str(size)) self.slave.exec_cmd("clear_board") if len(self.simple_engine.move_history): self.save_sgf("size") self.simple_engine = simple_go.Game(size) if os.path.exists("break.flag"): sys.exit(1) return self.ok()
def boardsize(self, size): #if size > simple_go.max_size: # return self.error("Too big size") fp = open("size%03i.sgf" % self.sgf_number, "w") fp.write(str(self.engine)) fp.close() self.sgf_number = self.sgf_number + 1 self.engine = simple_go.Game(size) self.handicap = 0.0 ## if size<=9: ## #config.debug_tactics = True ## config.lambda_node_limit = 100 ## elif size<=13: ## config.lambda_node_limit = 75 ## else: ## config.lambda_node_limit = 50 log("=" * 60 + "\n") log("boardsize: %s\n" % size) if os.path.exists("break.flag"): sys.exit(1) return self.ok("")
def boardsize(self, size): if size > 9: return self.error("Too big size") #if size > simple_go.max_size: # return self.error("Too big size") # clock must be initialized before the engine # otherwise the engine will override any lambda node limit settings if config.lambda_node_limit_baseline > 0: config.lambda_node_limit = int(config.lambda_node_limit_baseline * 81.0 / (size * size)) - size + 9 if self.clock is None: self.clock = time_settings.Timekeeper() else: self.clock.set_boardsize(size) if len(self.engine.move_history): self.save_sgf("size") self.engine = simple_go.Game(size) self.engine.network = self.m_network self.set_handicap(0.0) ## if size<=9: ## #config.debug_tactics = True ## config.lambda_node_limit = 100 ## elif size<=13: ## config.lambda_node_limit = 75 ## else: ## config.lambda_node_limit = 50 log("=" * 60 + "\n") log("boardsize: %s\n" % size) if os.path.exists("break.flag"): sys.exit(1) self.move_generated = False return self.ok("")
def __init__(self): play_gtp.GTP_player.__init__(self) self.engine = simple_go.Game(19) self.version = "0.0.3" self.name = "IdiotBot: I play mostly randomly: if I'm too easy, try WeakBot50k. Its maybe 60 stones stronger. 30k humans are often 80 stones stronger. My info contains links to my source code: "
def setUp(self): self.size = 13 self.game = simple_go.Game(self.size) self.board = simple_go.Board(self.size)