Beispiel #1
0
 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)
Beispiel #3
0
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'
Beispiel #4
0
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'
Beispiel #5
0
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'
Beispiel #6
0
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'
Beispiel #7
0
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'
Beispiel #8
0
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'
Beispiel #9
0
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'
Beispiel #10
0
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()
Beispiel #11
0
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'
Beispiel #12
0
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()
Beispiel #14
0
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()
Beispiel #15
0
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)