def __init__(self, g: BoardGame): Tk.__init__(self) self._game = g for y in range(g.rows()): for x in range(g.cols()): b = Button(self, width=3, height=2, font=('', 16)) b['command'] = (lambda x=x, y=y: (self._game.play_at(x, y), self.update_buttons())) b.grid(column=x, row=y) self.resizable(0, 0) self.update_buttons()
def id_to_boardgame(ID): game_info = boardgame_info(ID) game = BoardGame(game_info) time.sleep(2) try: if 'error' in game.data(): time.sleep(5) id_to_boardgame(ID) else: return (game) except: return (None)
def test0(): print 'test 0' infile='example/game_test0.txt' myform='movelist' print 'load file : '+infile # myboard=BoardGame(infile,myform) myboard=BoardGame() myboard.load_File(myform, infile) print 'print board' print str(myboard) print 'test 0 ended'
def test7(): print 'test 7' # nmoves=20 nmoves=random.randint(0,361) print nmoves # for i in range(nmoves): # x=random.random() # print x infile='' out_graph='graph_test7' # myform='sgf' outfile='test7_outboard_random3.txt' n=19 print 'make random board : '+infile # myboard=BoardGame(infile,myform) myboard=BoardGame(n,n) myboard.make_random(nmoves) print 'print board' print str(myboard) myboard.graph(out_graph) print 'write board to file in myformat' myboard.writeGameFile(outfile) print 'test 7 ended'
def test1(): print 'test 1' infile='example/game_test01.txt' myform='movelist' outfile='test1_outboard.txt' print 'load file : '+infile # myboard=BoardGame(infile,myform) myboard=BoardGame() myboard.load_File(myform, infile) print 'print board' print str(myboard) print 'write board to file in myformat' myboard.writeGameFile(outfile) print 'test 1 ended'
def test3(): print 'test 3' infile='example/17lg1-1.sgf' myform='sgf' outfile='test3_outboard.txt' n=19 print 'load file : '+infile # myboard=BoardGame(infile,myform) myboard=BoardGame(n,n) myboard.load_File(myform, infile) print 'print board' print str(myboard) print 'write board to file in myformat' myboard.writeGameFile(outfile) print 'test 3 ended'
def test2(): print 'test 2' infile='example/game_test2.txt' myform='myf' outfile='test2_outboard.txt' n=19 print 'load file : '+infile # myboard=BoardGame(infile,myform) myboard=BoardGame(n,n) myboard.load_File(myform, infile) print 'print board' print str(myboard) print 'write board to file in myformat' myboard.writeGameFile(outfile) print 'test 2 ended'
def test6(): print 'test 6' infile='example/yamadori-kentaur.sgf' myform='sgf' outfile='test6_outboard.txt' n=19 print 'load file : '+infile # myboard=BoardGame(infile,myform) myboard=BoardGame(n,n) myboard.load_File(myform, infile) print 'print board' print str(myboard) print 'write board to file in myformat' myboard.writeGameFile(outfile) print 'test 6 ended'
def test4(): print 'test 4' infile='example/test3_outboard.txt' myform='myf' outfile='test4_outboard.txt' n=19 print 'load file : '+infile # myboard=BoardGame(infile,myform) myboard=BoardGame(n,n) myboard.load_File(myform, infile) print 'print board' print str(myboard) print 'write board to file in myformat' myboard.writeSGF(outfile) print 'test 4 ended'
def test017(): print 'test 017' # nmoves=20 # nmoves=random.randint(0,361) # print nmoves # for i in range(nmoves): # x=random.random() # print x infile='example/test7_outboard_random3.txt' out_graph='graph_test0177' # myform='sgf' outfile='test017_radial_data_t7r3.txt' n=19 print 'make random board : '+infile # myboard=BoardGame(infile,myform) myboard=BoardGame(n,n) # myboard.make_random(nmoves) myboard.load_File(myform, infile) myboard.make_radial()
def test8(): print 'test 8' # nmoves=20 nmoves=random.randint(0,361) print nmoves # for i in range(nmoves): # x=random.random() # print x vers=8 vs=str(vers) infile='' out_graph='graph_test'+vs plot_name='graph_g_distribution_30'+vs # myform='sgf' outfile='test'+vs+'_outboard_random3.txt' n=19 print 'make random board : '+infile # myboard=BoardGame(infile,myform) myboard=BoardGame(n,n) myboard.make_random(nmoves) print 'print board' print str(myboard) myboard.graph(out_graph) print 'write board to file in myformat' myboard.writeGameFile(outfile) # # # print 'calculating g(r) functions' # one general, BB, WW, BW rg=radials.make_gofr(plot_name,myboard) #radials.make_gofr(plot_name,myboard) #radials.plot(plot_name,rg) print 'test 8 ended'
def gui_play(game: BoardGame): g2d.init_canvas((game.cols() * W, game.rows() * H)) ui = BoardGameGui(game) g2d.main_loop(ui.tick)
def __init__(self, g: BoardGame): self._game = g self._downtime = 0 g2d.init_canvas((g.cols() * W, g.rows() * H)) self.update_buttons()
def gui_play(game: BoardGame): g2d.init_canvas((game.cols() * W, game.rows() * H)) ui = BoardGameGui(game) g2d.handle_events(None, ui.mousedown, ui.mouseup) g2d.main_loop()
def gui_play(game: BoardGame): g2d.init_canvas((game.cols() * W, game.rows() * H)) g2d.alert("Welcome to Hitori Game!") ui = BoardGameGui(game) g2d.main_loop(ui.tick)