from tkinter import * root = Tk() # variable teban = IntVar() teban.set(1) # def start(): canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k

Size: px
Start display at page:

Download "from tkinter import * root = Tk() # variable teban = IntVar() teban.set(1) # def start(): canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k"

Transcription

1 Zen Deep Zen Go from tkinter import * root = Tk() canvas = Canvas(root, width = 360, height=360) canvas.pack() root.mainloop() 1

2 from tkinter import * root = Tk() # variable teban = IntVar() teban.set(1) # def start(): canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k in range(80,520,40): canvas.create_line(60,k,480,k) for k in range(80,520,40): canvas.create_line(k,80,k,500) canvas.create_oval(120-3, 200-3, 120+3, 200+3, fill= blue ) canvas.create_oval(360-3, 200-3, 360+3, 200+3, fill= blue ) canvas.create_oval(360-3, 440-3, 360+3, 440+3, fill= blue ) canvas.create_oval(360-20, , , , fill= black ) canvas.create_oval(400-20, , , , fill= white ) canvas.create_oval(360-20, , , , fill= black ) canvas.create_oval(360-20, , , , fill= white ) 2

3 canvas.create_oval(320-20, , , , fill= black ) canvas.create_oval(400-20, , , , fill= white ) canvas.create_oval(400-20, , , , fill= black ) canvas.create_oval(400-20, , , , fill= white ) canvas.create_oval(280-20, , , , fill= black ) def start2(): canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k in range(80,520,40): canvas.create_line(60,k,480,k) for k in range(80,520,40): canvas.create_line(k,80,k,500) canvas.create_oval(120-3, 200-3, 120+3, 200+3, fill= blue ) canvas.create_oval(360-3, 200-3, 360+3, 200+3, fill= blue ) canvas.create_oval(360-3, 440-3, 360+3, 440+3, fill= blue ) if teban.get() == 1: canvas.create_oval(360-20, , , , fill= black ) canvas.create_oval(400-20, , , , fill= white ) canvas.create_oval(360-20, , , , fill= black ) canvas.create_oval(360-20, , , , fill= white ) canvas.create_oval(400-20, , , , fill= black ) canvas.create_oval(320-20, , , , fill= white ) canvas.create_oval(360-20, , , , fill= black ) canvas.create_oval(400-20, , , , fill= white ) canvas.create_oval(280-20, , , , fill= black ) else: canvas.create_oval(360-20, , , , fill= black ) canvas.create_oval(400-20, , , , fill= white ) canvas.create_oval(360-20, , , , fill= black ) canvas.create_oval(360-20, , , , fill= white ) canvas.create_oval(400-20, , , , fill= black ) canvas.create_oval(320-20, , , , fill= white ) canvas.create_oval(360-20, , , , fill= black ) canvas.create_oval(320-20, , , , fill= white ) canvas.create_oval(400-20, , , , fill= black ) canvas.create_oval(400-20, , , , fill= white ) canvas.create_oval(440-20, , , , fill= black ) canvas.create_oval(440-20, , , , fill= white ) 3

4 canvas.create_oval(280-20, , , , fill= black ) # menubar = Menu(root) root.configure(menu = menubar) # tebans = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=tebans) hosi = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=hosi) kakari = Menu(hosi, tearoff = False) hosi.add_cascade(label=" ", underline = 0, menu=kakari) kakari.add_command(label = " ", under = 0, command = start) kakari.add_command(label = " ", under = 0, command = start2) # Labels tebans.add_radiobutton(label =, variable = teban, value = 1) tebans.add_radiobutton(label =, variable = teban, value = 2) canvas = Canvas(root, width = 560, height=560) canvas.pack() root.mainloop() 4

5 teban=1 teban=2 5

6 def get_pos(x, y): px = 80+40*int((x-60)/40) py = 80+40*int((y-60)/40) return px, py def on_pressed(event): sx, sy = get_pos(event.x, event.y) if teban.get() == 1: canvas.create_oval(sx-20, sy-20, sx+20, sy+20, fill= black ) else: canvas.create_oval(sx-20, sy-20, sx+20, sy+20, fill= white ) canvas.bind("<buttonpress-1>", on_pressed) 6

7 [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,8, w ),(14,4, b )] from tkinter import * root = Tk() # variable teban = IntVar() teban.set(1) joseki = [] num = 0 # def start(): global joseki, num canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k in range(80,520,40): canvas.create_line(60,k,480,k) 7

8 for k in range(80,520,40): canvas.create_line(k,80,k,500) canvas.create_oval(120-3, 200-3, 120+3, 200+3, fill= blue ) canvas.create_oval(360-3, 200-3, 360+3, 200+3, fill= blue ) canvas.create_oval(360-3, 440-3, 360+3, 440+3, fill= blue ) joseki = hosi1 num = 0 if teban.get() == 2: tx, ty, cl = joseki[num] px = 40*(tx-9)+80 py = 40*(ty-1)+80 canvas.create_oval(px-20, py-20, px+20, py+20, fill= black ) num += 1 def start2(): pass # menubar = Menu(root) root.configure(menu = menubar) # tebans = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=tebans) hosi = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=hosi) kakari = Menu(hosi, tearoff = False) hosi.add_cascade(label=" ", underline = 0, menu=kakari) kakari.add_command(label = " ", under = 0, command = start) kakari.add_command(label = " ", under = 0, command = start2) # Labels tebans.add_radiobutton(label =, variable = teban, value = 1) tebans.add_radiobutton(label =, variable = teban, value = 2) canvas = Canvas(root, width = 560, height=560) canvas.pack() def get_pos(x, y): 8

9 px = 80+40*int((x-60)/40) py = 80+40*int((y-60)/40) return px, py def on_pressed(event): global num sx, sy = get_pos(event.x, event.y) tx, ty, cl = joseki[num] px = 40*(tx-9)+80 py = 40*(ty-1)+80 print( sx=,sx, sy=,sy, px=,px, py=,py) if sx!= px or sy!= py: return if teban.get() == 1 and cl == b : canvas.create_oval(sx-20, sy-20, sx+20, sy+20, fill= black ) elif teban.get() == 2 and cl == w : canvas.create_oval(sx-20, sy-20, sx+20, sy+20, fill= white ) else: return num += 1 if num >= len(joseki): canvas.create_text(10, 10, text = OK, font = ( FixedSys, 14)) return tx, ty, cl = joseki[num] px = 40*(tx-9)+80 py = 40*(ty-1)+80 if teban.get() == 1: canvas.create_oval(px-20, py-20, px+20, py+20, fill= white ) elif teban.get() == 2: canvas.create_oval(px-20, py-20, px+20, py+20, fill= black ) num += 1 if num >= len(joseki): canvas.create_text(10, 10, text = OK, font = ( FixedSys, 14)) canvas.bind("<buttonpress-1>", on_pressed) # hosi1 = [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,8, w ),(14,4, b )] root.mainloop() 9

10 from tkinter import * root = Tk() # variable teban = IntVar() teban.set(1) joseki = [] num = 0 basic_board = [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 10

11 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3] board = [] B_SIZE = 19 WIDTH = 21 dir4 = [1, WIDTH, -1, -WIDTH] def get_z(x, y): return y * WIDTH + x def flip_color(col): return 3 - col def count_liberty_sub(tz, color, p_liberty, p_stone, check_board): check_board[tz] = 1 p_stone += 1 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if check_board[z]: continue if board[z] == 0: check_board[z] = 1 p_liberty += 1 if board[z] == color: p_liberty, p_stone = count_liberty_sub(z, color,p_liberty, p_stone, check_board) return p_liberty, p_stone def count_liberty(tz, p_liberty, p_stone): p_liberty = 0 p_stone = 0 check_board = [0] * 21 * 21 p_liberty, p_stone = count_liberty_sub(tz, board[tz], p_liberty, 11

12 p_stone, check_board) return p_liberty, p_stone def take_stone(tz, color): global board board[tz] = 0 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == color: take_stone(z, color) def put_stone(tz, color): global board board[tz] = color un_col = flip_color(color) for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == 0 or board[z] == 3 or board[z] == color: continue liberty = 0 stone = 0 liberty, stone = count_liberty(z, liberty, stone) if liberty == 0: take_stone(z, un_col) def display_board(): canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k in range(80,520,40): canvas.create_line(60,k,480,k) for k in range(80,520,40): canvas.create_line(k,80,k,500) canvas.create_oval(120-3, 200-3, 120+3, 200+3, fill= blue ) canvas.create_oval(360-3, 200-3, 360+3, 200+3, fill= blue ) canvas.create_oval(360-3, 440-3, 360+3, 440+3, fill= blue ) for i in range(9, 20, 1): for k in range(1, 12, 1): if board[get_z(i,k)] == 1: px = 40*(i-9)+80 py = 40*(k-1)+80 canvas.create_oval(px-20, py-20, px+20, py+20, fill= black ) elif board[get_z(i,k)] == 2: px = 40*(i-9)+80 py = 40*(k-1)+80 12

13 canvas.create_oval(px-20, py-20, px+20, py+20, fill= white ) # def start(): global joseki, num, board joseki = hosi1 num = 0 board = basic_board.copy() if teban.get() == 2: tx, ty, cl = joseki[num] put_stone(get_z(tx, ty), get_col(cl)) num += 1 display_board() def start2(): pass # menubar = Menu(root) root.configure(menu = menubar) # tebans = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=tebans) hosi = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=hosi) kakari = Menu(hosi, tearoff = False) hosi.add_cascade(label=" ", underline = 0, menu=kakari) kakari.add_command(label = " ", under = 0, command = start) kakari.add_command(label = " ", under = 0, command = start2) # Labels tebans.add_radiobutton(label =, variable = teban, value = 1) tebans.add_radiobutton(label =, variable = teban, value = 2) ### ##Label(root, text = "***** Menu Test *****").pack() canvas = Canvas(root, width = 560, height=560) canvas.pack() 13

14 def get_col(cl): return 1 if cl == b else 2 def get_pos(x, y): px = 80+40*int((x-60)/40) py = 80+40*int((y-60)/40) return px, py def on_pressed(event): global num, board sx, sy = get_pos(event.x, event.y) tx, ty, cl = joseki[num] px = 40*(tx-9)+80 py = 40*(ty-1)+80 print( sx=,sx, sy=,sy, px=,px, py=,py) if sx!= px or sy!= py: canvas.create_text(200, 10, text = Failure!, font = ( FixedSys, 20)) return if teban.get() == 1 and cl == b : put_stone(get_z(tx, ty), get_col(cl)) elif teban.get() == 2 and cl == w : put_stone(get_z(tx, ty), get_col(cl)) else: return num += 1 if num >= len(joseki): display_board() canvas.create_text(200, 10, text = Congratulations!, font = ( FixedSys, 20)) return tx, ty, cl = joseki[num] if teban.get() == 1: put_stone(get_z(tx, ty), get_col(cl)) elif teban.get() == 2: put_stone(get_z(tx, ty), get_col(cl)) display_board() num += 1 if num >= len(joseki): canvas.create_text(200, 10, text = Congratulations!, 14

15 font = ( FixedSys, 20)) canvas.bind("<buttonpress-1>", on_pressed) # hosi1 = [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,8, w ),(14,4, b )] root.mainloop() def put_stone(tz, color): [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,10, w ),(10,4, b )] [[(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,8, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,10, w ),(10,3, b )]] 15

16 history get_candidate() from tkinter import * import random root = Tk() # variable teban = IntVar() teban.set(1) joseki = [] num = 0 history = [] basic_board = [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3] 16

17 board = [] B_SIZE = 19 WIDTH = 21 dir4 = [1, WIDTH, -1, -WIDTH] def get_z(x, y): return y * WIDTH + x def flip_color(col): return 3 - col def count_liberty_sub(tz, color, p_liberty, p_stone, check_board): check_board[tz] = 1 p_stone += 1 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if check_board[z]: continue if board[z] == 0: check_board[z] = 1 p_liberty += 1 if board[z] == color: p_liberty, p_stone = count_liberty_sub(z, color,p_liberty, p_stone, check_board) return p_liberty, p_stone def count_liberty(tz, p_liberty, p_stone): p_liberty = 0 p_stone = 0 check_board = [0] * 21 * 21 p_liberty, p_stone = count_liberty_sub(tz, board[tz], p_liberty, p_stone, check_board) return p_liberty, p_stone def take_stone(tz, color): global board board[tz] = 0 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == color: take_stone(z, color) def put_stone(tz, color): global board board[tz] = color 17

18 un_col = flip_color(color) for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == 0 or board[z] == 3 or board[z] == color: continue liberty = 0 stone = 0 liberty, stone = count_liberty(z, liberty, stone) if liberty == 0: take_stone(z, un_col) def display_board(): canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k in range(80,520,40): canvas.create_line(60,k,480,k) for k in range(80,520,40): canvas.create_line(k,80,k,500) canvas.create_oval(120-3, 200-3, 120+3, 200+3, fill= blue ) canvas.create_oval(360-3, 200-3, 360+3, 200+3, fill= blue ) canvas.create_oval(360-3, 440-3, 360+3, 440+3, fill= blue ) for i in range(9, 20, 1): for k in range(1, 12, 1): if board[get_z(i,k)] == 1: px = 40*(i-9)+80 py = 40*(k-1)+80 canvas.create_oval(px-20, py-20, px+20, py+20, fill= black ) elif board[get_z(i,k)] == 2: px = 40*(i-9)+80 py = 40*(k-1)+80 canvas.create_oval(px-20, py-20, px+20, py+20, fill= white ) def get_candidate(num): candidate = [] for j_list in joseki: flag = True if num < len(j_list): for i in range(num): if j_list[i]!= history[i]: flag = False break if flag: if j_list[num] not in candidate: 18

19 candidate.append(j_list[num]) return candidate def start(): global joseki, num, board, history random.seed() joseki = hosi1 num = 0 board = basic_board.copy() history = [] if teban.get() == 2: candidate = get_candidate(num) n = random.randint(0, len(candidate)-1) tx, ty, cl = candidate[n] put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 display_board() def start2(): pass # menubar = Menu(root) root.configure(menu = menubar) # tebans = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=tebans) hosi = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=hosi) kakari = Menu(hosi, tearoff = False) hosi.add_cascade(label=" ", underline = 0, menu=kakari) kakari.add_command(label = " ", under = 0, command = start) kakari.add_command(label = " ", under = 0, command = start2) # Labels tebans.add_radiobutton(label =, variable = teban, value = 1) tebans.add_radiobutton(label =, variable = teban, value = 2) canvas = Canvas(root, width = 560, height=560) canvas.pack() 19

20 def get_col(cl): return 1 if cl == b else 2 def get_pos(x, y): px = 80+40*int((x-60)/40) py = 80+40*int((y-60)/40) return px, py def is_candidate(tx, ty, cl, candidate): for j in candidate: if j == (tx, ty, cl): return True return False def on_pressed(event): global num, board, history sx, sy = get_pos(event.x, event.y) candidate = get_candidate(num) tx = (sx - 80) // ty = (sy - 80) // cl = b if teban.get() == 1 else w print( tx=,tx, ty=,ty, cl=,cl) print( candidate=, candidate) if is_candidate(tx, ty, cl,candidate) == False: canvas.create_text(200, 10, text = Failure!, font = ( FixedSys, 20)) return put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 print( num=,num) candidate = get_candidate(num) if candidate == []: display_board() canvas.create_text(200, 10, text = Congratulations!, font = ( FixedSys, 20)) return n = random.randint(0, len(candidate)-1) tx, ty, cl = candidate[n] put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) display_board() 20

21 num += 1 candidate = get_candidate(num) if candidate == []: canvas.create_text(200, 10, text = Congratulations!, font = ( FixedSys, 20)) canvas.bind("<buttonpress-1>", on_pressed) # hosi1 = [[(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,8, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,10, w ),(10,3, b )]] root.mainloop() from tkinter import * import random root = Tk() ##root.option_add("*font", ("FixedSys", 10)) # variable teban = IntVar() teban.set(1) joseki = [] num = 0 history = [] basic_board = [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 21

22 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3] board = [] B_SIZE = 19 WIDTH = 21 dir4 = [1, WIDTH, -1, -WIDTH] def get_z(x, y): return y * WIDTH + x def flip_color(col): return 3 - col def count_liberty_sub(tz, color, p_liberty, p_stone, check_board): check_board[tz] = 1 p_stone += 1 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if check_board[z]: continue if board[z] == 0: check_board[z] = 1 p_liberty += 1 if board[z] == color: p_liberty, p_stone = count_liberty_sub(z, color,p_liberty, p_stone, check_board) return p_liberty, p_stone def count_liberty(tz, p_liberty, p_stone): p_liberty = 0 p_stone = 0 22

23 check_board = [0] * 21 * 21 p_liberty, p_stone = count_liberty_sub(tz, board[tz], p_liberty, p_stone, check_board) return p_liberty, p_stone def take_stone(tz, color): global board board[tz] = 0 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == color: take_stone(z, color) def put_stone(tz, color): global board board[tz] = color un_col = flip_color(color) for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == 0 or board[z] == 3 or board[z] == color: continue liberty = 0 stone = 0 liberty, stone = count_liberty(z, liberty, stone) if liberty == 0: take_stone(z, un_col) def display_board(): canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k in range(80,520,40): canvas.create_line(60,k,480,k) for k in range(80,520,40): canvas.create_line(k,80,k,500) canvas.create_oval(120-3, 200-3, 120+3, 200+3, fill= blue ) canvas.create_oval(360-3, 200-3, 360+3, 200+3, fill= blue ) canvas.create_oval(360-3, 440-3, 360+3, 440+3, fill= blue ) for i in range(9, 20, 1): for k in range(1, 12, 1): if board[get_z(i,k)] == 1: px = 40*(i-9)+80 py = 40*(k-1)+80 23

24 canvas.create_oval(px-20, py-20, px+20, py+20, fill= black ) elif board[get_z(i,k)] == 2: px = 40*(i-9)+80 py = 40*(k-1)+80 canvas.create_oval(px-20, py-20, px+20, py+20, fill= white ) def get_candidate(num): candidate = [] for j_list in joseki: flag = True if num < len(j_list): for i in range(num): if j_list[i]!= history[i]: flag = False break if flag: if j_list[num] not in candidate: candidate.append(j_list[num]) return candidate def basic_start(): global joseki, num, board, history num = 0 board = basic_board.copy() history = [] if teban.get() == 2: candidate = get_candidate(num) n = random.randint(0, len(candidate)-1) tx, ty, cl = candidate[n] put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 display_board() def start(): global joseki random.seed() if teban.get() == 1: joseki = hosi1b else: joseki = hosi1w 24

25 basic_start() def start2(): global joseki random.seed() if teban.get() == 1: joseki = hosi2b else: joseki = hosi2b basic_start() # menubar = Menu(root) root.configure(menu = menubar) # tebans = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=tebans) hosi = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=hosi) kakari = Menu(hosi, tearoff = False) hosi.add_cascade(label=" ", underline = 0, menu=kakari) kakari.add_command(label = " ", under = 0, command = start) kakari.add_command(label = " ", under = 0, command = start2) # Labels tebans.add_radiobutton(label =, variable = teban, value = 1) tebans.add_radiobutton(label =, variable = teban, value = 2) canvas = Canvas(root, width = 560, height=560) canvas.pack() def get_col(cl): return 1 if cl == b else 2 def get_pos(x, y): px = 80+40*int((x-60)/40) py = 80+40*int((y-60)/40) return px, py def is_candidate(tx, ty, cl, candidate): for j in candidate: if j == (tx, ty, cl): 25

26 return True return False def on_pressed(event): global num, board, history sx, sy = get_pos(event.x, event.y) candidate = get_candidate(num) tx = (sx - 80) // ty = (sy - 80) // cl = b if teban.get() == 1 else w if is_candidate(tx, ty, cl,candidate) == False: canvas.create_text(200, 10, text = Failure!, font = ( FixedSys, 20)) return put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 candidate = get_candidate(num) if candidate == []: display_board() canvas.create_text(200, 10, text = Congratulations!, font = ( FixedSys, 20)) return n = random.randint(0, len(candidate)-1) tx, ty, cl = candidate[n] put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) display_board() num += 1 candidate = get_candidate(num) if candidate == []: canvas.create_text(200, 10, text = Congratulations!, font = ( FixedSys, 20)) canvas.bind("<buttonpress-1>", on_pressed) # ##hosi1 = [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), ##(17,4, b ),(17,8, w ),(14,4, b )] 26

27 hosi1b = [ [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,8, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,10, w ),(10,3, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(17,7, w ), (14,4, b ),(15,3, w ),(14,3, b ),(16,2, w ),(14,2, b ),(18,2, w ), (17,2, b ),(17,1, w ),(15,2, b ),(16,3, w ),(17,3, b ),(16,1, w ), (18,1, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(17,7, w ), (14,4, b ),(15,3, w ),(14,3, b ),(16,2, w ),(14,2, b ),(17,2, w ), (18,2, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(18,5, w ), (14,4, b ),(15,3, w ),(14,3, b ),(16,2, w ),(17,7, b ),(18,7, w ), (17,8, b ),(18,8, w ),(14,2, b ),(18,2, w ),(17,2, b ),(17,3, w ), (16,3, b ),(15,2, w ),(18,3, b ),(17,1, w ),(15,1, b ),(17,3, w ), (19,5, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(18,5, w ), (14,4, b ),(15,3, w ),(14,3, b ),(15,2, w ),(14,2, b ),(17,2, w ), (17,7, b ),(18,7, w ),(17,8, b ),(18,8, w ),(18,2, b ),(18,1, w ), (19,5, b ),(18,6, w ),(17,3, b ),(16,2, w ),(19,2, b )], ] hosi1w = [ [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,8, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,10, w ),(10,3, b )] ] hosi2b = [ [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(17,7, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(15,7, w ),(17,7, b ),(17,8, w ),(18,6, b ),(18,7, w ), (14,4, b )], 27

28 [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(15,7, w ),(17,7, b ),(17,8, w ),(18,6, b ),(14,4, w ), (18,8, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(18,6, w ),(15,7, b ),(16,8, w ),(14,6, b ),(15,8, w ), (15,5, b ),(18,5, w ),(17,3, b )] ] root.mainloop() 28

29 29

30 30

31 from tkinter import * import tkinter.filedialog import sys, os.path root = Tk() ##root.option_add("*font", ("FixedSys", 10)) # variable teban = IntVar() teban.set(1) joseki = [] num = 0 history = [] capture = [] 31

32 path_name = "" file_name = "" basic_board = [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3] board = [] B_SIZE = 19 WIDTH = 21 dir4 = [1, WIDTH, -1, -WIDTH] def get_z(x, y): return y * WIDTH + x def flip_color(col): return 3 - col def count_liberty_sub(tz, color, p_liberty, p_stone, check_board): check_board[tz] = 1 p_stone += 1 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d 32

33 if check_board[z]: continue if board[z] == 0: check_board[z] = 1 p_liberty += 1 if board[z] == color: p_liberty, p_stone = count_liberty_sub(z, color,p_liberty, p_stone, check_board) return p_liberty, p_stone def count_liberty(tz, p_liberty, p_stone): p_liberty = 0 p_stone = 0 check_board = [0] * 21 * 21 p_liberty, p_stone = count_liberty_sub(tz, board[tz], p_liberty, p_stone, check_board) return p_liberty, p_stone def take_stone(tz, color): global board board[tz] = 0 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == color: take_stone(z, color) def put_stone(tz, color): global board, capture board[tz] = color un_col = flip_color(color) cap = 0 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == 0 or board[z] == 3 or board[z] == color: continue liberty = 0 stone = 0 liberty, stone = count_liberty(z, liberty, stone) if liberty == 0: take_stone(z, un_col) if d == 1: cap = cap 1 elif d == WIDTH: cap = cap 2 elif d == -1: cap = cap 4 else: cap = cap 8 33

34 capture.append(cap) def display_board(): canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k in range(80,520,40): canvas.create_line(60,k,480,k) for k in range(80,520,40): canvas.create_line(k,80,k,500) canvas.create_oval(120-3, 200-3, 120+3, 200+3, fill= blue ) canvas.create_oval(360-3, 200-3, 360+3, 200+3, fill= blue ) canvas.create_oval(360-3, 440-3, 360+3, 440+3, fill= blue ) for i in range(9, 20, 1): for k in range(1, 12, 1): if board[get_z(i,k)] == 1: px = 40*(i-9)+80 py = 40*(k-1)+80 canvas.create_oval(px-20, py-20, px+20, py+20, fill= black ) elif board[get_z(i,k)] == 2: px = 40*(i-9)+80 py = 40*(k-1)+80 canvas.create_oval(px-20, py-20, px+20, py+20, fill= white ) def set_ban(): global num, board, history, capture new_jyoseki = [] num = 0 board = basic_board.copy() history = [] capture = [] display_board() def set_joseki(): global num, history, joseki FLAG = True for j_list in joseki: if len(history) == len(j_list): flag = True for i in range(len(history)): 34

35 if history[i]!= j_list[i]: flag = False if flag == True: FLAG = False break if FLAG == True: joseki.append(history) print( joseki=, joseki) def cover_stone(tz, color): global board board[tz] = color for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == 0: take_stone(z, color) def matta(): global num, history, board, capture cap = capture[-1] capture = capture[:-1] te = history[-1] x, y, cl = te history = history[:-1] if cap & 8: cover_stone(get_z(x,y)-width, 1 if cl== b else 2) elif cap & 4: cover_stone(get_z(x,y)-1, 1 if cl== b else 2) elif cap & 2: cover_stone(get_z(x,y)+width, 1 if cl== b else 2) elif cap & 1: cover_stone(get_z(x,y)+1, 1 if cl== b else 2) board[get_z(x,y)] = 0 num -= 1 display_board() M_STOP_FLAG = False def joseki2file(): global M_STOP_FLAG M_STOP_FLAG = True global path_name, joseki filename = tkinter.filedialog.asksaveasfilename(initialdir=path_name) if filename: 35

36 path_name = os.path.dirname(filename) f = open(filename, "w") ss = "[\n" f.write(ss) for k in range(len(joseki)): j_list = joseki[k] ss = "[" for i in range(len(j_list)): x, y, c = j_list[i] ss += "(" + str(x)+"," + str(y)+","+c+")" if i < len(j_list)-1: ss += "," ss += "]" if k < len(joseki)-1: ss += "," ss += "\n" f.write(ss) ss = "]\n" f.write(ss) f.close() M_STOP_FLAG = False def file2joseki(): global M_STOP_FLAG M_STOP_FLAG = True global path_name, joseki filename = tkinter.filedialog.askopenfilename(initialdir=path_name) if filename: path_name = os.path.dirname(filename) f = open(filename, "r") joseki = [] for line in f: line = line[:-1] if line == [ or line == ] : continue j_item = [] j_list = line.split(",") for k in range(len(j_list)//3): sx = j_list[3*k] sy = j_list[3*k+1] 36

37 sc = j_list[3*k+2] if k == 0: x = int(sx[2:]) else: x = int(sx[1:]) y = int(sy) c = sc[0] j_item.append((x,y,c)) joseki.append(j_item) f.close() M_STOP_FLAG = False print( joseki=, joseki) # menubar = Menu(root) root.configure(menu = menubar) # tebans = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=tebans) menufile = Menu(menubar, tearoff = False) menubar.add_cascade(label="file", underline = 0, menu=menufile) menuout = Menu(menufile, tearoff = False) ##menufile.add_cascade(label=" ", underline = 0, menu=menuout) menufile.add_command(label = " ", under = 0, command = joseki2file) menufile.add_separator menufile.add_command(label = " ", under = 0, command = file2joseki) # Labels tebans.add_radiobutton(label =, variable = teban, value = 1) tebans.add_radiobutton(label =, variable = teban, value = 2) canvas = Canvas(root, width = 560, height=560) canvas.pack() button1 = Button(root, text =, command = set_ban) button1.pack(side=left) button2 = Button(root, text =, command = set_joseki) button2.pack(side=left) button3 = Button(root, text =, command = matta) button3.pack(side=right) 37

38 def get_col(cl): return 1 if cl == b else 2 def get_pos(x, y): px = 80+40*int((x-60)/40) py = 80+40*int((y-60)/40) return px, py def is_candidate(tx, ty, cl, candidate): for j in candidate: if j == (tx, ty, cl): return True return False def on_pressed(event): global num, board, history, M_STOP_FLAG if M_STOP_FLAG == True: return sx, sy = get_pos(event.x, event.y) tx = (sx - 80) // ty = (sy - 80) // cl = b if num % 2 == 0 else w put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 display_board() canvas.bind("<buttonpress-1>", on_pressed) root.mainloop() 38

39 joseki append joseki= [[(17, 4, b ), (15, 3, w ), (13, 3, b ), (15, 5, w ), (16, 6, b ), (12, 4, w ), (16, 3, b ), (15, 2, w ), (15, 6, b ), (12, 3, w ), (17, 10, b )]] 39

40 joseki append File joseki [ [(16,4,b),(17,6,w),(16,6,b),(16,7,w),(15,6,b),(17,5,w),(17,4,b),(17,8,w),(14,4,b)], [(16,4,b),(17,6,w),(16,6,b),(16,7,w),(15,6,b),(17,5,w),(17,4,b),(17,10,w),(10,3,b)] ] [ ] File joseki joseki append File 40

41 M_STOP_FLAG = False def file2joseki(): global M_STOP_FLAG M_STOP_FLAG = True global path_name, joseki filename = tkinter.filedialog.askopenfilename(initialdir=path_name) if filename: path_name = os.path.dirname(filename) f = open(filename, "r") joseki = [] for line in f: line = line[:-1] if line == [ or line == ] : continue j_item = [] j_list = line.split(",") for k in range(len(j_list)//3): sx = j_list[3*k] sy = j_list[3*k+1] sc = j_list[3*k+2] if k == 0: x = int(sx[2:]) else: 41

42 x = int(sx[1:]) y = int(sy) c = sc[0] j_item.append((x,y,c)) joseki.append(j_item) f.close() M_STOP_FLAG = False print( joseki=, joseki) def on_pressed(event): global num, board, history, M_STOP_FLAG if M_STOP_FLAG == True: return sx, sy = get_pos(event.x, event.y) tx = (sx - 80) // ty = (sy - 80) // cl = b if num % 2 == 0 else w put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 display_board() M_STOP_FLAG on_pressed(event) from tkinter import * import random import tkinter.filedialog import sys, os.path root = Tk() # variable teban = IntVar() teban.set(1) 42

43 joseki = [] num = 0 history = [] path_name = "" file_name = "" basic_board = [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3] board = [] B_SIZE = 19 WIDTH = 21 dir4 = [1, WIDTH, -1, -WIDTH] def get_z(x, y): return y * WIDTH + x def flip_color(col): return 3 - col def count_liberty_sub(tz, color, p_liberty, p_stone, check_board): check_board[tz] = 1 43

44 p_stone += 1 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if check_board[z]: continue if board[z] == 0: check_board[z] = 1 p_liberty += 1 if board[z] == color: p_liberty, p_stone = count_liberty_sub(z, color,p_liberty, p_stone, check_board) return p_liberty, p_stone def count_liberty(tz, p_liberty, p_stone): p_liberty = 0 p_stone = 0 check_board = [0] * 21 * 21 p_liberty, p_stone = count_liberty_sub(tz, board[tz], p_liberty, p_stone, check_board) return p_liberty, p_stone def take_stone(tz, color): global board board[tz] = 0 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == color: take_stone(z, color) def put_stone(tz, color): global board board[tz] = color un_col = flip_color(color) for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == 0 or board[z] == 3 or board[z] == color: continue liberty = 0 stone = 0 liberty, stone = count_liberty(z, liberty, stone) if liberty == 0: take_stone(z, un_col) def display_board(): 44

45 canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k in range(80,520,40): canvas.create_line(60,k,480,k) for k in range(80,520,40): canvas.create_line(k,80,k,500) canvas.create_oval(120-3, 200-3, 120+3, 200+3, fill= blue ) canvas.create_oval(360-3, 200-3, 360+3, 200+3, fill= blue ) canvas.create_oval(360-3, 440-3, 360+3, 440+3, fill= blue ) for i in range(9, 20, 1): for k in range(1, 12, 1): if board[get_z(i,k)] == 1: px = 40*(i-9)+80 py = 40*(k-1)+80 canvas.create_oval(px-20, py-20, px+20, py+20, fill= black ) elif board[get_z(i,k)] == 2: px = 40*(i-9)+80 py = 40*(k-1)+80 canvas.create_oval(px-20, py-20, px+20, py+20, fill= white ) def get_candidate(num): candidate = [] for j_list in joseki: flag = True if num < len(j_list): for i in range(num): if j_list[i]!= history[i]: flag = False break if flag: if j_list[num] not in candidate: candidate.append(j_list[num]) return candidate def basic_start(): global joseki, num, board, history num = 0 board = basic_board.copy() history = [] if teban.get() == 2: candidate = get_candidate(num) n = random.randint(0, len(candidate)-1) 45

46 tx, ty, cl = candidate[n] put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 display_board() def start(): global joseki random.seed() if teban.get() == 1: joseki = hosi1b else: joseki = hosi1w basic_start() def start2(): global joseki random.seed() if teban.get() == 1: joseki = hosi2b else: joseki = hosi2b basic_start() M_STOP_FLAG = False def file2joseki(): global M_STOP_FLAG M_STOP_FLAG = True global path_name, joseki filename = tkinter.filedialog.askopenfilename(initialdir=path_name) if filename: path_name = os.path.dirname(filename) f = open(filename, "r") joseki = [] for line in f: line = line[:-1] if line == [ or line == ] : continue j_item = [] 46

47 j_list = line.split(",") for k in range(len(j_list)//3): sx = j_list[3*k] sy = j_list[3*k+1] sc = j_list[3*k+2] if k == 0: x = int(sx[2:]) else: x = int(sx[1:]) y = int(sy) c = sc[0] j_item.append((x,y,c)) joseki.append(j_item) f.close() M_STOP_FLAG = False print( joseki=, joseki) basic_start() def restart(): basic_start() # menubar = Menu(root) root.configure(menu = menubar) # tebans = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=tebans) hosi = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=hosi) kakari = Menu(hosi, tearoff = False) hosi.add_cascade(label=" ", underline = 0, menu=kakari) kakari.add_command(label = " ", under = 0, command = start) kakari.add_command(label = " ", under = 0, command = start2) # Labels tebans.add_radiobutton(label =, variable = teban, value = 1) tebans.add_radiobutton(label =, variable = teban, value = 2) josekiopen = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=josekiopen) josekiopen.add_command(label = " ", under = 0, command = file2joseki) 47

48 josekiopen.add_command(label = " ", under = 0, command = restart) canvas = Canvas(root, width = 560, height=560) canvas.pack() def get_col(cl): return 1 if cl == b else 2 def get_pos(x, y): px = 80+40*int((x-60)/40) py = 80+40*int((y-60)/40) return px, py def is_candidate(tx, ty, cl, candidate): for j in candidate: if j == (tx, ty, cl): return True return False def on_pressed(event): global num, board, history if M_STOP_FLAG == True: return sx, sy = get_pos(event.x, event.y) candidate = get_candidate(num) tx = (sx - 80) // ty = (sy - 80) // cl = b if teban.get() == 1 else w if is_candidate(tx, ty, cl,candidate) == False: canvas.create_text(200, 10, text = Failure!, font = ( FixedSys, 20)) return put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 candidate = get_candidate(num) if candidate == []: display_board() canvas.create_text(200, 10, text = Congratulations!, font = ( FixedSys, 20)) return n = random.randint(0, len(candidate)-1) tx, ty, cl = candidate[n] 48

49 put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) display_board() num += 1 candidate = get_candidate(num) if candidate == []: canvas.create_text(200, 10, text = Congratulations!, font = ( FixedSys, 20)) canvas.bind("<buttonpress-1>", on_pressed) # ##hosi1 = [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), ##(17,4, b ),(17,8, w ),(14,4, b )] hosi1b = [ [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,8, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,10, w ),(10,3, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(17,7, w ), (14,4, b ),(15,3, w ),(14,3, b ),(16,2, w ),(14,2, b ),(18,2, w ), (17,2, b ),(17,1, w ),(15,2, b ),(16,3, w ),(17,3, b ),(16,1, w ), (18,1, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(17,7, w ), (14,4, b ),(15,3, w ),(14,3, b ),(16,2, w ),(14,2, b ),(17,2, w ), (18,2, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(18,5, w ), (14,4, b ),(15,3, w ),(14,3, b ),(16,2, w ),(17,7, b ),(18,7, w ), (17,8, b ),(18,8, w ),(14,2, b ),(18,2, w ),(17,2, b ),(17,3, w ), (16,3, b ),(15,2, w ),(18,3, b ),(17,1, w ),(15,1, b ),(17,3, w ), (19,5, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(18,5, w ), (14,4, b ),(15,3, w ),(14,3, b ),(15,2, w ),(14,2, b ),(17,2, w ), (17,7, b ),(18,7, w ),(17,8, b ),(18,8, w ),(18,2, b ),(18,1, w ), 49

50 (19,5, b ),(18,6, w ),(17,3, b ),(16,2, w ),(19,2, b )], ] hosi1w = [ [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,8, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,10, w ),(10,3, b )] ] hosi2b = [ [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(17,7, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(15,7, w ),(17,7, b ),(17,8, w ),(18,6, b ),(18,7, w ), (14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(15,7, w ),(17,7, b ),(17,8, w ),(18,6, b ),(14,4, w ), (18,8, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(18,6, w ),(15,7, b ),(16,8, w ),(14,6, b ),(15,8, w ), (15,5, b ),(18,5, w ),(17,3, b )] ] root.mainloop() 50

51 51

52 52

53 53

54 Failure! 54

55 komoku1b = [ [(17,4, b ),(15,3, w ),(16,5, b ),(14,4, b ),(13,3, w )], [(17,4, b ),(15,3, w ),(16,5, b ),(12,3, b ),(14,4, w ),(16,3, b )], [(17,4, b ),(15,3, w ),(16,5, b ),(12,3, b ),(17,2, w ),(14,4, b ), (14,3, w ),(13,4, b ),(18,3, w )] ] from tkinter import * import tkinter.filedialog import sys, os.path root = Tk() # variable teban = IntVar() teban.set(1) joseki = [] num = 0 history = [] 55

56 capture = [] path_name = "" file_name = "" basic_board = [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3] board = [] B_SIZE = 19 WIDTH = 21 dir4 = [1, WIDTH, -1, -WIDTH] def get_z(x, y): return y * WIDTH + x def flip_color(col): return 3 - col def count_liberty_sub(tz, color, p_liberty, p_stone, check_board): check_board[tz] = 1 p_stone += 1 for d in [1, WIDTH, -1, -WIDTH]: 56

57 z = tz + d if check_board[z]: continue if board[z] == 0: check_board[z] = 1 p_liberty += 1 if board[z] == color: p_liberty, p_stone = count_liberty_sub(z, color,p_liberty, p_stone, check_board) return p_liberty, p_stone def count_liberty(tz, p_liberty, p_stone): p_liberty = 0 p_stone = 0 check_board = [0] * 21 * 21 p_liberty, p_stone = count_liberty_sub(tz, board[tz], p_liberty, p_stone, check_board) return p_liberty, p_stone def take_stone(tz, color): global board board[tz] = 0 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == color: take_stone(z, color) def put_stone(tz, color): global board, capture board[tz] = color un_col = flip_color(color) cap = 0 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == 0 or board[z] == 3 or board[z] == color: continue liberty = 0 stone = 0 liberty, stone = count_liberty(z, liberty, stone) if liberty == 0: take_stone(z, un_col) if d == 1: cap = cap 1 elif d == WIDTH: cap = cap 2 elif d == -1: cap = cap 4 57

58 else: cap = cap 8 capture.append(cap) def display_board(): canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k in range(80,520,40): canvas.create_line(60,k,480,k) for k in range(80,520,40): canvas.create_line(k,80,k,500) canvas.create_oval(120-3, 200-3, 120+3, 200+3, fill= blue ) canvas.create_oval(360-3, 200-3, 360+3, 200+3, fill= blue ) canvas.create_oval(360-3, 440-3, 360+3, 440+3, fill= blue ) for i in range(9, 20, 1): for k in range(1, 12, 1): if board[get_z(i,k)] == 1: px = 40*(i-9)+80 py = 40*(k-1)+80 canvas.create_oval(px-20, py-20, px+20, py+20, fill= black ) elif board[get_z(i,k)] == 2: px = 40*(i-9)+80 py = 40*(k-1)+80 canvas.create_oval(px-20, py-20, px+20, py+20, fill= white ) def set_ban(): global num, board, history, capture new_jyoseki = [] num = 0 board = basic_board.copy() history = [] capture = [] display_board() def set_joseki(): global num, history, joseki FLAG = True for j_list in joseki: if len(history) == len(j_list): flag = True 58

59 for i in range(len(history)): if history[i]!= j_list[i]: flag = False if flag == True: FLAG = False break if FLAG == True: joseki.append(history) print( joseki=, joseki) def cover_stone(tz, color): global board board[tz] = color for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == 0: take_stone(z, color) def matta(): global num, history, board, capture cap = capture[-1] capture = capture[:-1] te = history[-1] x, y, cl = te history = history[:-1] if cap & 8: cover_stone(get_z(x,y)-width, 1 if cl== b else 2) elif cap & 4: cover_stone(get_z(x,y)-1, 1 if cl== b else 2) elif cap & 2: cover_stone(get_z(x,y)+width, 1 if cl== b else 2) elif cap & 1: cover_stone(get_z(x,y)+1, 1 if cl== b else 2) board[get_z(x,y)] = 0 num -= 1 display_board() def tenuki(): global num num += 1 M_STOP_FLAG = False def joseki2file(): global M_STOP_FLAG 59

60 M_STOP_FLAG = True global path_name, joseki filename = tkinter.filedialog.asksaveasfilename(initialdir=path_name) if filename: path_name = os.path.dirname(filename) f = open(filename, "w") ss = "[\n" f.write(ss) for k in range(len(joseki)): j_list = joseki[k] ss = "[" for i in range(len(j_list)): x, y, c = j_list[i] ss += "(" + str(x)+"," + str(y)+","+c+")" if i < len(j_list)-1: ss += "," ss += "]" if k < len(joseki)-1: ss += "," ss += "\n" f.write(ss) ss = "]\n" f.write(ss) f.close() M_STOP_FLAG = False def file2joseki(): global M_STOP_FLAG M_STOP_FLAG = True global path_name, joseki filename = tkinter.filedialog.askopenfilename(initialdir=path_name) if filename: path_name = os.path.dirname(filename) f = open(filename, "r") joseki = [] for line in f: line = line[:-1] if line == [ or line == ] : continue j_item = [] 60

61 j_list = line.split(",") for k in range(len(j_list)//3): sx = j_list[3*k] sy = j_list[3*k+1] sc = j_list[3*k+2] if k == 0: x = int(sx[2:]) else: x = int(sx[1:]) y = int(sy) c = sc[0] j_item.append((x,y,c)) joseki.append(j_item) f.close() M_STOP_FLAG = False print( joseki=, joseki) # menubar = Menu(root) root.configure(menu = menubar) # tebans = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=tebans) menufile = Menu(menubar, tearoff = False) menubar.add_cascade(label="file", underline = 0, menu=menufile) menuout = Menu(menufile, tearoff = False) ##menufile.add_cascade(label=" ", underline = 0, menu=menuout) menufile.add_command(label = " ", under = 0, command = joseki2file) menufile.add_separator menufile.add_command(label = " ", under = 0, command = file2joseki) # Labels tebans.add_radiobutton(label =, variable = teban, value = 1) tebans.add_radiobutton(label =, variable = teban, value = 2) canvas = Canvas(root, width = 560, height=560) canvas.pack() button1 = Button(root, text =, command = set_ban) button1.pack(side=left) button2 = Button(root, text =, command = set_joseki) 61

62 button2.pack(side=left) button3 = Button(root, text =, command = matta) button3.pack(side=right) button4 = Button(root, text =, command = tenuki) button4.pack(side=right) def get_col(cl): return 1 if cl == b else 2 def get_pos(x, y): px = 80+40*int((x-60)/40) py = 80+40*int((y-60)/40) return px, py def is_candidate(tx, ty, cl, candidate): for j in candidate: if j == (tx, ty, cl): return True return False def on_pressed(event): global num, board, history, M_STOP_FLAG if M_STOP_FLAG == True: return sx, sy = get_pos(event.x, event.y) tx = (sx - 80) // ty = (sy - 80) // cl = b if num % 2 == 0 else w put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 display_board() canvas.bind("<buttonpress-1>", on_pressed) root.mainloop() from tkinter import * import random import tkinter.filedialog 62

63 import sys, os.path root = Tk() # variable teban = IntVar() teban.set(1) joseki = [] num = 0 history = [] path_name = "" file_name = "" basic_board = [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3] board = [] B_SIZE = 19 WIDTH = 21 dir4 = [1, WIDTH, -1, -WIDTH] 63

64 def get_z(x, y): return y * WIDTH + x def flip_color(col): return 3 - col def count_liberty_sub(tz, color, p_liberty, p_stone, check_board): check_board[tz] = 1 p_stone += 1 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if check_board[z]: continue if board[z] == 0: check_board[z] = 1 p_liberty += 1 if board[z] == color: p_liberty, p_stone = count_liberty_sub(z, color,p_liberty, p_stone, check_board) return p_liberty, p_stone def count_liberty(tz, p_liberty, p_stone): p_liberty = 0 p_stone = 0 check_board = [0] * 21 * 21 p_liberty, p_stone = count_liberty_sub(tz, board[tz], p_liberty, p_stone, check_board) return p_liberty, p_stone def take_stone(tz, color): global board board[tz] = 0 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == color: take_stone(z, color) def put_stone(tz, color): global board board[tz] = color un_col = flip_color(color) for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == 0 or board[z] == 3 or board[z] == color: continue 64

65 liberty = 0 stone = 0 liberty, stone = count_liberty(z, liberty, stone) if liberty == 0: take_stone(z, un_col) def display_board(): canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k in range(80,520,40): canvas.create_line(60,k,480,k) for k in range(80,520,40): canvas.create_line(k,80,k,500) canvas.create_oval(120-3, 200-3, 120+3, 200+3, fill= blue ) canvas.create_oval(360-3, 200-3, 360+3, 200+3, fill= blue ) canvas.create_oval(360-3, 440-3, 360+3, 440+3, fill= blue ) canvas.create_oval(120-3, 440-3, 120+3, 440+3, fill= blue ) for i in range(9, 20, 1): for k in range(1, 12, 1): if board[get_z(i,k)] == 1: px = 40*(i-9)+80 py = 40*(k-1)+80 canvas.create_oval(px-20, py-20, px+20, py+20, fill= black ) elif board[get_z(i,k)] == 2: px = 40*(i-9)+80 py = 40*(k-1)+80 canvas.create_oval(px-20, py-20, px+20, py+20, fill= white ) def get_candidate(num): candidate = [] for j_list in joseki: flag = True if num < len(j_list): for i in range(num): if j_list[i]!= history[i]: flag = False break if flag: if j_list[num] not in candidate: candidate.append(j_list[num]) 65

66 return candidate def basic_start(): global joseki, num, board, history num = 0 board = basic_board.copy() history = [] if teban.get() == 2: candidate = get_candidate(num) n = random.randint(0, len(candidate)-1) tx, ty, cl = candidate[n] put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 display_board() def start(): global joseki random.seed() if teban.get() == 1: joseki = hosi1b else: joseki = hosi1w basic_start() def start2(): global joseki random.seed() if teban.get() == 1: joseki = hosi2b else: joseki = hosi2b basic_start() def start3(): global joseki random.seed() if teban.get() == 1: joseki = komoku1b else: joseki = komoku1b 66

67 basic_start() M_STOP_FLAG = False def file2joseki(): global M_STOP_FLAG M_STOP_FLAG = True global path_name, joseki filename = tkinter.filedialog.askopenfilename(initialdir=path_name) if filename: path_name = os.path.dirname(filename) f = open(filename, "r") joseki = [] for line in f: line = line[:-1] if line == [ or line == ] : continue j_item = [] j_list = line.split(",") for k in range(len(j_list)//3): sx = j_list[3*k] sy = j_list[3*k+1] sc = j_list[3*k+2] if k == 0: x = int(sx[2:]) else: x = int(sx[1:]) y = int(sy) c = sc[0] j_item.append((x,y,c)) joseki.append(j_item) f.close() M_STOP_FLAG = False print( joseki=, joseki) basic_start() def restart(): basic_start() # 67

68 menubar = Menu(root) root.configure(menu = menubar) # tebans = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=tebans) hosi = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=hosi) kakari = Menu(hosi, tearoff = False) hosi.add_cascade(label=" ", underline = 0, menu=kakari) kakari.add_command(label = " ", under = 0, command = start) kakari.add_command(label = " ", under = 0, command = start2) komoku = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=komoku) ##komoku.add_cascade(label=" ", underline = 0, menu=kakari) komoku.add_command(label = " ", under = 0, command = start3) # Labels tebans.add_radiobutton(label =, variable = teban, value = 1) tebans.add_radiobutton(label =, variable = teban, value = 2) josekiopen = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=josekiopen) josekiopen.add_command(label = " ", under = 0, command = file2joseki) josekiopen.add_command(label = " ", under = 0, command = restart) canvas = Canvas(root, width = 560, height=560) canvas.pack() def get_col(cl): return 1 if cl == b else 2 def get_pos(x, y): px = 80+40*int((x-60)/40) py = 80+40*int((y-60)/40) return px, py def is_candidate(tx, ty, cl, candidate): for j in candidate: if j == (tx, ty, cl): return True return False def on_pressed(event): global num, board, history if M_STOP_FLAG == True: return 68

69 canvas.create_text(200, 10, text =, font = ( FixedSys, 20)) sx, sy = get_pos(event.x, event.y) candidate = get_candidate(num) print( candidate=, candidate) tx = (sx - 80) // ty = (sy - 80) // cl = b if teban.get() == 1 else w if is_candidate(tx, ty, cl, candidate) == False: display_board() canvas.create_text(200, 10, text = Failure!, font = ( FixedSys, 20)) return put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 display_board() candidate = get_candidate(num) if candidate == []: display_board() canvas.create_text(200, 10, text = Congratulations!, font = ( FixedSys, 20)) return n = random.randint(0, len(candidate)-1) tx, ty, cl = candidate[n] # if (teban.get()==1 and cl== w ) or (teban.get()==2 and cl== b ): put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) display_board() num += 1 while True: candidate = get_candidate(num) if candidate == []: canvas.create_text(200, 10, text = Congratulations!, font = ( FixedSys, 20)) return else: # 69

70 n = random.randint(0, len(candidate)-1) tx, ty, cl = candidate[n] if (teban.get()==1 and cl== w ) or (teban.get()==2 and cl== b ): put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) display_board() num += 1 else: break else: # canvas.create_text(200, 10, text =, font = ( FixedSys, 20)) canvas.bind("<buttonpress-1>", on_pressed) # hosi1b = [ [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,8, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,10, w ),(10,3, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(17,7, w ), (14,4, b ),(15,3, w ),(14,3, b ),(16,2, w ),(14,2, b ),(18,2, w ), (17,2, b ),(17,1, w ),(15,2, b ),(16,3, w ),(17,3, b ),(16,1, w ), (18,1, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(17,7, w ), (14,4, b ),(15,3, w ),(14,3, b ),(16,2, w ),(14,2, b ),(17,2, w ), (18,2, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(18,5, w ), (14,4, b ),(15,3, w ),(14,3, b ),(16,2, w ),(17,7, b ),(18,7, w ), (17,8, b ),(18,8, w ),(14,2, b ),(18,2, w ),(17,2, b ),(17,3, w ), (16,3, b ),(15,2, w ),(18,3, b ),(17,1, w ),(15,1, b ),(17,3, w ), (19,5, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(18,5, w ), (14,4, b ),(15,3, w ),(14,3, b ),(15,2, w ),(14,2, b ),(17,2, w ), (17,7, b ),(18,7, w ),(17,8, b ),(18,8, w ),(18,2, b ),(18,1, w ), (19,5, b ),(18,6, w ),(17,3, b ),(16,2, w ),(19,2, b )], 70

71 ] hosi1w = [ [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,8, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,10, w ),(10,3, b )] ] hosi2b = [ [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(17,7, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(15,7, w ),(17,7, b ),(17,8, w ),(18,6, b ),(18,7, w ), (14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(15,7, w ),(17,7, b ),(17,8, w ),(18,6, b ),(14,4, w ), (18,8, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(18,6, w ),(15,7, b ),(16,8, w ),(14,6, b ),(15,8, w ), (15,5, b ),(18,5, w ),(17,3, b )] ] komoku1b = [ [(17,4, b ),(15,3, w ),(16,5, b ),(14,4, b ),(13,3, w )], [(17,4, b ),(15,3, w ),(16,5, b ),(12,3, b ),(14,4, w ),(16,3, b )], [(17,4, b ),(15,3, w ),(16,5, b ),(12,3, b ),(17,2, w ),(14,4, b ), (14,3, w ),(13,4, b ),(18,3, w )] ] root.mainloop() 71

72 72

73 [ [(-6,-16,b),(17,4,b),(15,3,w),(13,3,b),(13,4,w),(12,4,b),(14,4,w),(11,3,b),(16,6,w) ] from tkinter import * import tkinter.filedialog import sys, os.path root = Tk() # variable teban = IntVar() teban.set(1) joseki = [] num = 0 history = [] capture = [] 73

74 path_name = "" file_name = "" basic_board = [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3] board = [] B_SIZE = 19 WIDTH = 21 dir4 = [1, WIDTH, -1, -WIDTH] def get_z(x, y): return y * WIDTH + x def flip_color(col): return 3 - col def count_liberty_sub(tz, color, p_liberty, p_stone, check_board): check_board[tz] = 1 p_stone += 1 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if check_board[z]: continue 74

75 if board[z] == 0: check_board[z] = 1 p_liberty += 1 if board[z] == color: p_liberty, p_stone = count_liberty_sub(z, color,p_liberty, p_stone, check_board) return p_liberty, p_stone def count_liberty(tz, p_liberty, p_stone): p_liberty = 0 p_stone = 0 check_board = [0] * 21 * 21 p_liberty, p_stone = count_liberty_sub(tz, board[tz], p_liberty, p_stone, check_board) return p_liberty, p_stone def take_stone(tz, color): global board board[tz] = 0 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == color: take_stone(z, color) def put_stone(tz, color): global board, capture board[tz] = color un_col = flip_color(color) cap = 0 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == 0 or board[z] == 3 or board[z] == color: continue liberty = 0 stone = 0 liberty, stone = count_liberty(z, liberty, stone) if liberty == 0: take_stone(z, un_col) if d == 1: cap = cap 1 elif d == WIDTH: cap = cap 2 elif d == -1: cap = cap 4 else: cap = cap 8 capture.append(cap) 75

76 def display_board(): canvas.create_rectangle(0, 0, 600, 600, fill= white ) for k in range(80,560,30): canvas.create_line(65,k,530,k) for k in range(80,540,30): canvas.create_line(k,80,k,545) canvas.create_oval( 80-3, 170-3, 80+3, 170+3, fill= blue ) canvas.create_oval(260-3, 170-3, 260+3, 170+3, fill= blue ) canvas.create_oval(440-3, 170-3, 440+3, 170+3, fill= blue ) canvas.create_oval( 80-3, 350-3, 80+3, 350+3, fill= blue ) canvas.create_oval(260-3, 350-3, 260+3, 350+3, fill= blue ) canvas.create_oval(440-3, 350-3, 440+3, 350+3, fill= blue ) canvas.create_oval( 80-3, 530-3, 80+3, 530+3, fill= blue ) canvas.create_oval(260-3, 530-3, 260+3, 530+3, fill= blue ) canvas.create_oval(440-3, 530-3, 440+3, 530+3, fill= blue ) for i in range(4, 20, 1): for k in range(1, 17, 1): if board[get_z(i,k)] == 1: px = 30*(i-4)+80 py = 30*(k-1)+80 canvas.create_oval(px-15, py-15, px+15, py+15, fill= black ) elif board[get_z(i,k)] == 2: px = 30*(i-4)+80 py = 30*(k-1)+80 canvas.create_oval(px-15, py-15, px+15, py+15, fill= white ) def set_ban(): global num, board, history, capture new_jyoseki = [] num = 0 board = basic_board.copy() history = [] capture = [] display_board() def set_joseki(): global num, history, joseki 76

77 FLAG = True for j_list in joseki: if len(history) == len(j_list): flag = True for i in range(len(history)): if history[i]!= j_list[i]: flag = False if flag == True: FLAG = False break if FLAG == True: joseki.append(history) print( joseki=, joseki) def cover_stone(tz, color): global board board[tz] = color for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == 0: take_stone(z, color) def matta(): global num, history, board, capture cap = capture[-1] capture = capture[:-1] te = history[-1] x, y, cl = te history = history[:-1] if cap & 8: cover_stone(get_z(x,y)-width, 1 if cl== b else 2) elif cap & 4: cover_stone(get_z(x,y)-1, 1 if cl== b else 2) elif cap & 2: cover_stone(get_z(x,y)+width, 1 if cl== b else 2) elif cap & 1: cover_stone(get_z(x,y)+1, 1 if cl== b else 2) board[get_z(x,y)] = 0 num -= 1 display_board() def tenuki(): global num num += 1 def white_okiisi(): 77

78 global num, history, board, capture x, y, cl = history[-1] board[get_z(x,y)] = get_col( w ) history[-1] =(-x, -y, w ) num = 0 display_board() def black_okiisi(): global num, history, board, capture x, y, cl = history[-1] board[get_z(x,y)] = get_col( b ) history[-1] =(-x, -y, b ) num = 0 display_board() M_STOP_FLAG = False def joseki2file(): global M_STOP_FLAG M_STOP_FLAG = True global path_name, joseki filename = tkinter.filedialog.asksaveasfilename(initialdir=path_name) if filename: path_name = os.path.dirname(filename) f = open(filename, "w") ss = "[\n" f.write(ss) for k in range(len(joseki)): j_list = joseki[k] ss = "[" for i in range(len(j_list)): x, y, c = j_list[i] ss += "(" + str(x)+"," + str(y)+","+c+")" if i < len(j_list)-1: ss += "," ss += "]" if k < len(joseki)-1: ss += "," ss += "\n" f.write(ss) 78

79 ss = "]\n" f.write(ss) f.close() M_STOP_FLAG = False def file2joseki(): global M_STOP_FLAG M_STOP_FLAG = True global path_name, joseki filename = tkinter.filedialog.askopenfilename(initialdir=path_name) if filename: path_name = os.path.dirname(filename) f = open(filename, "r") joseki = [] for line in f: line = line[:-1] if line == [ or line == ] : continue j_item = [] j_list = line.split(",") for k in range(len(j_list)//3): sx = j_list[3*k] sy = j_list[3*k+1] sc = j_list[3*k+2] if k == 0: x = int(sx[2:]) else: x = int(sx[1:]) y = int(sy) c = sc[0] j_item.append((x,y,c)) joseki.append(j_item) f.close() M_STOP_FLAG = False print( joseki=, joseki) # menubar = Menu(root) root.configure(menu = menubar) # 79

80 tebans = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=tebans) menufile = Menu(menubar, tearoff = False) menubar.add_cascade(label="file", underline = 0, menu=menufile) menuout = Menu(menufile, tearoff = False) ##menufile.add_cascade(label=" ", underline = 0, menu=menuout) menufile.add_command(label = " ", under = 0, command = joseki2file) menufile.add_separator menufile.add_command(label = " ", under = 0, command = file2joseki) # Labels tebans.add_radiobutton(label =, variable = teban, value = 1) tebans.add_radiobutton(label =, variable = teban, value = 2) canvas = Canvas(root, width = 600, height=600) canvas.pack() button1 = Button(root, text =, command = set_ban) button1.pack(side=left) button2 = Button(root, text =, command = set_joseki) button2.pack(side=left) button3 = Button(root, text =, command = matta) button3.pack(side=right) button4 = Button(root, text =, command = tenuki) button4.pack(side=right) button5 = Button(root, text =, command = white_okiisi) button5.pack(side=right) button6 = Button(root, text =, command = black_okiisi) button6.pack(side=right) def get_col(cl): return 1 if cl == b else 2 def get_pos(x, y): px = 80+30*int((x-65)/30) py = 80+30*int((y-65)/30) return px, py def is_candidate(tx, ty, cl, candidate): for j in candidate: if j == (tx, ty, cl): return True return False 80

81 def on_pressed(event): global num, board, history, M_STOP_FLAG if M_STOP_FLAG == True: return sx, sy = get_pos(event.x, event.y) tx = (sx - 80) // ty = (sy - 80) // cl = b if num % 2 == 0 else w put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 display_board() canvas.bind("<buttonpress-1>", on_pressed) root.mainloop() File 81

82 M_STOP_FLAG = False def file2joseki(): global M_STOP_FLAG M_STOP_FLAG = True global path_name, joseki filename = tkinter.filedialog.askopenfilename(initialdir=path_name) if filename: path_name = os.path.dirname(filename) f = open(filename, "r") joseki = [] for line in f: line = line[:-1] if line == [ or line == ] : continue j_item = [] j_list = line.split(",") for k in range(len(j_list)//3): sx = j_list[3*k] sy = j_list[3*k+1] sc = j_list[3*k+2] if k == 0: x = int(sx[2:]) else: 82

83 x = int(sx[1:]) y = int(sy) c = sc[0] j_item.append((x,y,c)) joseki.append(j_item) f.close() M_STOP_FLAG = False print( joseki=, joseki) def on_pressed(event): global num, board, history, M_STOP_FLAG if M_STOP_FLAG == True: return sx, sy = get_pos(event.x, event.y) tx = (sx - 80) // ty = (sy - 80) // cl = b if num % 2 == 0 else w put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 display_board() M_STOP_FLAG on_pressed(event) from tkinter import * import random import tkinter.filedialog import sys, os.path root = Tk() ##root.option_add("*font", ("FixedSys", 10)) # variable teban = IntVar() teban.set(1) 83

84 joseki = [] num = 0 history = [] path_name = "" file_name = "" basic_board = [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3] board = [] B_SIZE = 19 WIDTH = 21 dir4 = [1, WIDTH, -1, -WIDTH] def get_z(x, y): return y * WIDTH + x def flip_color(col): return 3 - col def count_liberty_sub(tz, color, p_liberty, p_stone, check_board): check_board[tz] = 1 p_stone += 1 84

85 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if check_board[z]: continue if board[z] == 0: check_board[z] = 1 p_liberty += 1 if board[z] == color: p_liberty, p_stone = count_liberty_sub(z, color,p_liberty, p_stone, check_board) return p_liberty, p_stone def count_liberty(tz, p_liberty, p_stone): p_liberty = 0 p_stone = 0 check_board = [0] * 21 * 21 p_liberty, p_stone = count_liberty_sub(tz, board[tz], p_liberty, p_stone, check_board) return p_liberty, p_stone def take_stone(tz, color): global board board[tz] = 0 for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == color: take_stone(z, color) def put_stone(tz, color): global board board[tz] = color un_col = flip_color(color) for d in [1, WIDTH, -1, -WIDTH]: z = tz + d if board[z] == 0 or board[z] == 3 or board[z] == color: continue liberty = 0 stone = 0 liberty, stone = count_liberty(z, liberty, stone) if liberty == 0: take_stone(z, un_col) def display_board(): canvas.create_rectangle(0, 0, 600, 600, fill= white ) 85

86 for k in range(80,560,30): canvas.create_line(65,k,530,k) for k in range(80,540,30): canvas.create_line(k,80,k,545) canvas.create_oval( 80-3, 170-3, 80+3, 170+3, fill= blue ) canvas.create_oval(260-3, 170-3, 260+3, 170+3, fill= blue ) canvas.create_oval(440-3, 170-3, 440+3, 170+3, fill= blue ) canvas.create_oval( 80-3, 350-3, 80+3, 350+3, fill= blue ) canvas.create_oval(260-3, 350-3, 260+3, 350+3, fill= blue ) canvas.create_oval(440-3, 350-3, 440+3, 350+3, fill= blue ) canvas.create_oval( 80-3, 530-3, 80+3, 530+3, fill= blue ) canvas.create_oval(260-3, 530-3, 260+3, 530+3, fill= blue ) canvas.create_oval(440-3, 530-3, 440+3, 530+3, fill= blue ) for i in range(4, 20, 1): for k in range(1, 17, 1): if board[get_z(i,k)] == 1: px = 30*(i-4)+80 py = 30*(k-1)+80 canvas.create_oval(px-15, py-15, px+15, py+15, fill= black ) elif board[get_z(i,k)] == 2: px = 30*(i-4)+80 py = 30*(k-1)+80 canvas.create_oval(px-15, py-15, px+15, py+15, fill= white ) canvas.create_text(200, 10, text =, font = ( FixedSys, 20)) n_okiishi = 0 def get_candidate(num): candidate = [] for j_list in joseki: flag = True if num < len(j_list): for i in range(num): if j_list[i]!= history[i]: flag = False break if flag: if j_list[num] not in candidate: candidate.append(j_list[num]) 86

87 return candidate def basic_start(): global joseki, num, board, history, n_okiishi num = 0 n_okiishi = 0 board = basic_board.copy() history = [] # n = random.randint(0, len(joseki)-1) j_hist = joseki[n] i = 0 while True: x,y,cl = j_hist[i] if x < 0: put_stone(get_z(-x, -y), get_col(cl)) history.append((x, y, cl)) i += 1 n_okiishi += 1 else: break if teban.get() == 2: candidate = get_candidate(num+n_okiishi) n = random.randint(0, len(candidate)-1) tx, ty, cl = candidate[n] put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 display_board() def start(): global joseki random.seed() if teban.get() == 1: joseki = hosi1b else: joseki = hosi1w basic_start() 87

88 def start2(): global joseki random.seed() if teban.get() == 1: joseki = hosi2b else: joseki = hosi2b basic_start() def start3(): global joseki random.seed() if teban.get() == 1: joseki = komoku1b else: joseki = komoku1b basic_start() M_STOP_FLAG = False def file2joseki(): global M_STOP_FLAG M_STOP_FLAG = True global path_name, joseki filename = tkinter.filedialog.askopenfilename(initialdir=path_name) if filename: path_name = os.path.dirname(filename) f = open(filename, "r") joseki = [] for line in f: line = line[:-1] if line == [ or line == ] : continue j_item = [] j_list = line.split(",") for k in range(len(j_list)//3): sx = j_list[3*k] sy = j_list[3*k+1] sc = j_list[3*k+2] if k == 0: x = int(sx[2:]) 88

89 else: x = int(sx[1:]) y = int(sy) c = sc[0] j_item.append((x,y,c)) joseki.append(j_item) f.close() print( joseki=, joseki) basic_start() M_STOP_FLAG = False def restart(): basic_start() # menubar = Menu(root) root.configure(menu = menubar) # tebans = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=tebans) hosi = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=hosi) kakari = Menu(hosi, tearoff = False) hosi.add_cascade(label=" ", underline = 0, menu=kakari) kakari.add_command(label = " ", under = 0, command = start) kakari.add_command(label = " ", under = 0, command = start2) komoku = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=komoku) kogeimakakari = Menu(hosi, tearoff = False) komoku.add_cascade(label=" ", underline = 0, menu=kogeimakakari) kogeimakakari.add_command(label = " ", under = 0, command = start3) # Labels tebans.add_radiobutton(label =, variable = teban, value = 1) tebans.add_radiobutton(label =, variable = teban, value = 2) josekiopen = Menu(menubar, tearoff = False) menubar.add_cascade(label=" ", underline = 0, menu=josekiopen) josekiopen.add_command(label = " ", under = 0, command = file2joseki) josekiopen.add_command(label = " ", under = 0, command = restart) 89

90 canvas = Canvas(root, width = 600, height=600) canvas.pack() def get_col(cl): return 1 if cl == b else 2 def get_pos(x, y): px = 80+30*int((x-65)/30) py = 80+30*int((y-65)/30) return px, py def is_candidate(tx, ty, cl, candidate): for j in candidate: if j == (tx, ty, cl): return True return False def on_pressed(event): global num, board, history, n_okiishi if M_STOP_FLAG == True: sx, sy = get_pos(event.x, event.y) return canvas.create_text(200, 10, text =, font = ( FixedSys, 20)) sx, sy = get_pos(event.x, event.y) candidate = get_candidate(num+n_okiishi) print( candidate=, candidate) tx = (sx - 80) // ty = (sy - 80) // cl = b if teban.get() == 1 else w if is_candidate(tx, ty, cl, candidate) == False: display_board() canvas.create_text(200, 10, text = Failure!, font = ( FixedSys, 20)) return put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) num += 1 display_board() candidate = get_candidate(num+n_okiishi) if candidate == []: display_board() 90

91 canvas.create_text(200, 10, text = Congratulations!, font = ( FixedSys, 20)) return n = random.randint(0, len(candidate)-1) tx, ty, cl = candidate[n] # if (teban.get()==1 and cl== w ) or (teban.get()==2 and cl== b ): put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) display_board() num += 1 while True: candidate = get_candidate(num+n_okiishi) if candidate == []: canvas.create_text(200, 10, text = Congratulations!, font = ( FixedSys, 20)) return else: # n = random.randint(0, len(candidate)-1) tx, ty, cl = candidate[n] if (teban.get()==1 and cl== w ) or (teban.get()==2 and cl== b ): put_stone(get_z(tx, ty), get_col(cl)) history.append((tx, ty, cl)) display_board() num += 1 else: break else: # canvas.create_text(200, 10, text =, font = ( FixedSys, 20)) canvas.bind("<buttonpress-1>", on_pressed) # ##hosi1 = [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), ##(17,4, b ),(17,8, w ),(14,4, b )] hosi1b = [ 91

92 [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,8, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,10, w ),(10,3, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(17,7, w ), (14,4, b ),(15,3, w ),(14,3, b ),(16,2, w ),(14,2, b ),(18,2, w ), (17,2, b ),(17,1, w ),(15,2, b ),(16,3, w ),(17,3, b ),(16,1, w ), (18,1, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(17,7, w ), (14,4, b ),(15,3, w ),(14,3, b ),(16,2, w ),(14,2, b ),(17,2, w ), (18,2, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(18,5, w ), (14,4, b ),(15,3, w ),(14,3, b ),(16,2, w ),(17,7, b ),(18,7, w ), (17,8, b ),(18,8, w ),(14,2, b ),(18,2, w ),(17,2, b ),(17,3, w ), (16,3, b ),(15,2, w ),(18,3, b ),(17,1, w ),(15,1, b ),(17,3, w ), (19,5, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(16,5, w ),(15,5, b ),(15,4, w ),(18,4, b ),(18,5, w ), (14,4, b ),(15,3, w ),(14,3, b ),(15,2, w ),(14,2, b ),(17,2, w ), (17,7, b ),(18,7, w ),(17,8, b ),(18,8, w ),(18,2, b ),(18,1, w ), (19,5, b ),(18,6, w ),(17,3, b ),(16,2, w ),(19,2, b )], ] hosi1w = [ [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,8, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(15,6, b ),(17,5, w ), (17,4, b ),(17,10, w ),(10,3, b )] ] hosi2b = [ [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(17,7, w ),(14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(15,7, w ),(17,7, b ),(17,8, w ),(18,6, b ),(18,7, w ), (14,4, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), 92

93 (16,5, b ),(15,7, w ),(17,7, b ),(17,8, w ),(18,6, b ),(14,4, w ), (18,8, b )], [(16,4, b ),(17,6, w ),(16,6, b ),(16,7, w ),(17,5, b ),(15,6, w ), (16,5, b ),(18,6, w ),(15,7, b ),(16,8, w ),(14,6, b ),(15,8, w ), (15,5, b ),(18,5, w ),(17,3, b )] ] komoku1b = [ [(17,4, b ),(15,3, w ),(16,5, b ),(11,3, w ),(17,9, b )], [(17,4, b ),(15,3, w ),(16,5, b ),(12,3, w ),(16,3, b ),(15,4, w ), (16,7, b )], [(17,4, b ),(15,3, w ),(16,5, b ),(11,3, w ),(13,3, b ),(15,5, w ), (15,6, b ),(14,5, w ),(16,7, b ),(12,4, w ),(16,3, b ),(15,2, w )], [(17,4, b ),(15,3, w ),(16,5, b ),(11,3, w ),(13,3, b ),(13,2, w ), (17,10, b ),(13,4, w )], [(17,4, b ),(15,3, w ),(16,5, b ),(11,3, w ),(13,3, b ),(13,2, w ), (12,2, b ),(12,3, w ),(14,2, b ),(13,4, w ),(14,3, b ),(14,4, w ), (15,4, b ),(15,2, w ),(13,1, b ),(15,5, w ),(16,4, b ),(15,1, w ), (14,1, b ),(11,2, w ),(16,3, b ),(15,6, w )], [(17,4, b ),(15,3, w ),(16,5, b ),(13,4, w ),(11,3, b ),(17,2, w ), (17,9, b )], [(17,4, b ),(15,3, w ),(16,5, b ),(14,4, b ),(13,3, w )], [(17,4, b ),(15,3, w ),(16,5, b ),(14,4, b ),(13,3, w ),(16,3, b )], [(17,4, b ),(15,3, w ),(16,5, b ),(14,4, b ),(13,3, w ),(11,3, b )], [(17,4, b ),(15,3, w ),(16,5, b ),(14,4, b ),(13,3, w ),(12,4, b )], [(17,4, b ),(15,3, w ),(16,5, b ),(12,3, b ),(17,2, w ),(14,4, b ), (14,3, w ),(13,4, b ),(18,3, w )], [(17,4, b ),(15,3, w ),(16,5, b ),(11,3, b ),(13,3, w ),(16,3, b ), (13,5, w )], [(17,4, b ),(15,3, w ),(16,5, b ),(11,3, b ),(17,2, w ),(14,4, b ), (14,3, w ),(13,4, b ),(12,2, w ),(11,2, b ),(12,3, w ),(12,4, b ), (18,3, w ),(10,5, b )], [(17,4, b ),(15,3, w ),(16,6, b ),(11,3, w )], [(17,4, b ),(15,3, w ),(16,6, b ),(17,3, w ),(18,3, b ),(16,4, w ), (17,5, b ),(17,2, w )], [(17,4, b ),(15,3, w ),(17,7, b ),(16,6, w ),(17,6, b ),(17,3, w ), (18,3, b ),(16,4, w ),(17,5, b ),(17,2, w )] ] root.mainloop() 93

94 Failure! 94

Python2 Python3 Python 2.7 Python 3.6 Python2 Python3 Python 2.7 Python3.6 Python Python Anaconda Python Anaconda Python

Python2 Python3 Python 2.7 Python 3.6 Python2 Python3 Python 2.7 Python3.6 Python Python Anaconda Python Anaconda Python (Python ) C++ Python Python 1 Python2 Python3 Python 2.7 Python 3.6 Python2 Python3 Python 2.7 Python3.6 Python Python Anaconda Python Anaconda Python https://www.continuum.io/downloads 2 Python 3.6 version

More information

from Tkinter import * root = Tk() c0 = Canvas(root, width = 400, height = 300) c0.pack() image_data = PhotoImage(file = c1.gif ) c0.create_image(200,

from Tkinter import * root = Tk() c0 = Canvas(root, width = 400, height = 300) c0.pack() image_data = PhotoImage(file = c1.gif ) c0.create_image(200, (Python ) Python Python 2 1. 2 2. 52 3. A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2 4. 13 5. 6. 7. 8. 9. 13 10. 11. 12. Python.gif 1 from Tkinter import * root = Tk() c0 = Canvas(root, width = 400, height =

More information

cards.gif from Tkinter import * root = Tk() c0 = Canvas(root, width = 400, height = 300) c0.pack() image_data = PhotoImage(file = c1.gif ) c0.create_i

cards.gif from Tkinter import * root = Tk() c0 = Canvas(root, width = 400, height = 300) c0.pack() image_data = PhotoImage(file = c1.gif ) c0.create_i (Python ) Python Python 2 1. 2 2. 52 3. A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2 4. 13 5. 6. 7. 8. 9. 13 10. 11. 12. Python http://www.jftz.com/cards/ 1 cards.gif from Tkinter import * root = Tk() c0 = Canvas(root,

More information

Python3 Next 2

Python3 Next 2 Python Python Tkinter Tkinter Python Python Anaconda Python Anaconda Python https://www.continuum.io/downloads Python 3.6 version Python2 Python3 Python 2.7 Python 3.6 Python2 1 Python3 Next 2 I Agree

More information

(Java/FX ) Java CD Java version Java VC++ Python Ruby Java Java Eclipse Java Java 3 Java for Everyone 2 10 Java Midi Java JavaFX Shape Canvas C

(Java/FX ) Java CD Java version Java VC++ Python Ruby Java Java Eclipse Java Java 3 Java for Everyone 2 10 Java Midi Java JavaFX Shape Canvas C (Java/FX ) Java CD Java version 10.0.1 Java VC++ Python Ruby Java Java Eclipse Java Java 3 Java for Everyone 2 10 Java Midi Java JavaFX Shape Canvas Canvas Eclipse Eclipse M... 1 javafx e(fx)clipse 3.0.0

More information

Python Speed Learning

Python   Speed Learning Python Speed Learning 1 / 76 Python 2 1 $ python 1 >>> 1 + 2 2 3 2 / 76 print : 1 print : ( ) 3 / 76 print : 1 print 1 2 print hello 3 print 1+2 4 print 7/3 5 print abs(-5*4) 4 / 76 print : 1 print 1 2

More information

listings-ext

listings-ext (6) Python (2) ( ) ohsaki@kwansei.ac.jp 5 Python (2) 1 5.1 (statement)........................... 1 5.2 (scope)......................... 11 5.3 (subroutine).................... 14 5 Python (2) Python 5.1

More information

1 6/13 2 6/20 3 6/27 4 7/4 5 7/11 6 7/18 N 7 7/25 Warshall-Floyd, Bellman-Ford, Dijkstra TSP DP, 8/1 2 / 36

1 6/13 2 6/20 3 6/27 4 7/4 5 7/11 6 7/18 N 7 7/25 Warshall-Floyd, Bellman-Ford, Dijkstra TSP DP, 8/1 2 / 36 3 2016 6 27 1 / 36 1 6/13 2 6/20 3 6/27 4 7/4 5 7/11 6 7/18 N 7 7/25 Warshall-Floyd, Bellman-Ford, Dijkstra TSP DP, 8/1 2 / 36 1 2 3 3 / 36 4 / 36 os.urandom(n) n >>> import os >>> r = os.urandom(4) #

More information

r3.dvi

r3.dvi 00 3 2000.6.10 0 Java ( 7 1 7 1 GSSM 1? 1 1.1 4 4a 4b / / 0 255 HTML X 0 255 16 (0,32,255 #0020FF Java xclock -bg #0020FF xclock ^C (Control C xclock 4c 1 import java.applet.applet; import java.awt.*;

More information

Python @HACHINONE 10 1 V Python 2014 2 : L[i] # -*- coding: utf-8 -*- def search(l, e): """L をリスト e をオブジェクトとする L に e が含まれていれば True そうでなければ False を返す """ for i in range(len(l)): if L[i] == e: return True

More information

(pack ) Toplevel

(pack ) Toplevel 1 1 2 2 3 (pack ) 6 3.1................................... 6 3.2 1............................ 8 3.3 Toplevel........................................ 9 3.4............................... 10 3.5 Toplevel..................................

More information

r4.dvi

r4.dvi 00 4 2000.6.24 0 GUI GUI GUI GUI 1 1.1 3 2 1 import java.applet.applet; import java.awt.*; public class r3ex2 extends Applet { Figure[] figs = new Figure[]{ new Circle(Color.blue, 100.0, 100.0, 30.0, 1.1,

More information

Python Speed Learning

Python   Speed Learning Python Speed Learning 1 / 89 1 2 3 4 (import) 5 6 7 (for) (if) 8 9 10 ( ) 11 12 for 13 2 / 89 Contents 1 2 3 4 (import) 5 6 7 (for) (if) 8 9 10 ( ) 11 12 for 13 3 / 89 (def) (for) (if) etc. 1 4 / 89 Jupyter

More information

1 VisBAR edu H 2 O.....

1 VisBAR edu H 2 O..... VisBAR edu v1.03 ( ) 25 4 22 1 VisBAR edu 1 1.1....................................................... 1 1.2.................................................. 2 2 3 2.1 H 2 O.........................................

More information

(37564) Python@HACHINONE Simple 3 1 VPython 2014 2 VPython 22017 91 Python 3.5 2 x x ans01 ans**3x ans**3x ans +1 3 # -*- coding: utf-8 -*- # 完全立方に対する立方根を求める x = int(raw_input(' 整数を入力してください :')) ans =

More information

PYTHON 資料 電脳梁山泊烏賊塾 PYTHON 入門 ゲームプログラミング スプライトの衝突判定 スプライトの衝突判定 スプライトの衝突判定の例として インベーダーゲームのコードを 下記に示す PYTHON3 #coding: utf-8 import pygame from pygame.lo

PYTHON 資料 電脳梁山泊烏賊塾 PYTHON 入門 ゲームプログラミング スプライトの衝突判定 スプライトの衝突判定 スプライトの衝突判定の例として インベーダーゲームのコードを 下記に示す PYTHON3 #coding: utf-8 import pygame from pygame.lo PYTHON 入門 ゲームプログラミング スプライトの衝突判定 スプライトの衝突判定 スプライトの衝突判定の例として インベーダーゲームのコードを 下記に示す #coding: utf-8 import pygame from pygame.locals import * import os import sys SCR_RECT = Rect(0, 0, 640, 480) def main():

More information

インターネットマガジン1999年7月号―INTERNET magazine No.54

インターネットマガジン1999年7月号―INTERNET magazine No.54 A MagnaviIp9907Htmltips +CD-ROM 3 3 A N S W E R HTML TIPS&TRICKS A N S W E R function Init() { block.style.setexpression("left",

More information

離散数理工学 第 2回 数え上げの基礎:漸化式の立て方

離散数理工学 第 2回  数え上げの基礎:漸化式の立て方 2 okamotoy@uec.ac.jp 2015 10 20 2015 10 18 15:29 ( ) (2) 2015 10 20 1 / 45 ( ) 1 (10/6) ( ) (10/13) 2 (10/20) 3 ( ) (10/27) (11/3) 4 ( ) (11/10) 5 (11/17) 6 (11/24) 7 (12/1) 8 (12/8) ( ) (2) 2015 10 20

More information

GIMP

GIMP (JavaScript ) Javascript 1. 2 2. 3. A, K, Q, J, 10, 9, 8, 7, 4. 5. 6. 7. J Q K A 8. 9. 6 10. 11. 12. 13. A- K- Q- J- 10-9 8 7 JavaScript.png 1 GIMP 200 300 2 var ctx; function init()

More information

listings-ext

listings-ext (10) (2) ( ) ohsaki@kwansei.ac.jp 8 (2) 1 8.1.............................. 1 8.2 mobility.fixed.......................... 2 8.3 mobility.randomwalk...................... 7 8.4 mobility.randomwaypoint...................

More information

19 ステップで 2 大人気スクリプト言語を学ぶ GUI のあるアプリを作る STEP11 から STEP12 までまとめ 1.Python での GUI アプリ作成 Python は標準ではグラフィックスの機能を持ちませんが ライブラリを使うことで GUI のアプリを作成することができる そこで

19 ステップで 2 大人気スクリプト言語を学ぶ GUI のあるアプリを作る STEP11 から STEP12 までまとめ 1.Python での GUI アプリ作成 Python は標準ではグラフィックスの機能を持ちませんが ライブラリを使うことで GUI のアプリを作成することができる そこで 19 ステップで 2 大人気スクリプト言語を学ぶ GUI のあるアプリを作る STEP11 から STEP12 までまとめ 1.Python での GUI アプリ作成 Python は標準ではグラフィックスの機能を持ちませんが ライブラリを使うことで GUI のアプリを作成することができる そこで Kivy というソフトウェアを使う Kivy は Python のパッケージ管理システム pip を使ってインターネット上のファイルサーバからインストールが可能である

More information

syspro-0405.ppt

syspro-0405.ppt 3 4, 5 1 UNIX csh 2.1 bash X Window 2 grep l POSIX * more POSIX 3 UNIX. 4 first.sh #!bin/sh #first.sh #This file looks through all the files in the current #directory for the string yamada, and then prints

More information

8 if switch for while do while 2

8 if switch for while do while 2 (Basic Theory of Information Processing) ( ) if for while break continue 1 8 if switch for while do while 2 8.1 if (p.52) 8.1.1 if 1 if ( ) 2; 3 1 true 2 3 false 2 3 3 8.1.2 if-else (p.54) if ( ) 1; else

More information

Ruby 50 Ruby UTF print, \n [Ruby-1] print("hello, Ruby.\n") [Ruby-2] Hello, Ruby. [Ruby-3] print("hello, \"Ruby\".\n") 2 [Ruby-4] seisuu = 10 pr

Ruby 50 Ruby UTF print, \n [Ruby-1] print(hello, Ruby.\n) [Ruby-2] Hello, Ruby. [Ruby-3] print(hello, \Ruby\.\n) 2 [Ruby-4] seisuu = 10 pr Ruby 50 Ruby UTF-8 1 1 print, \n [Ruby-1] print("hello, Ruby.\n") [Ruby-2] Hello, Ruby. [Ruby-3] print("hello, \"Ruby\".\n") 2 [Ruby-4] seisuu = 10 print(seisuu, "\n") jissuu = 3.141592 print(jissuu, "\n")

More information

離散数理工学 第 2回 数え上げの基礎:漸化式の立て方

離散数理工学 第 2回  数え上げの基礎:漸化式の立て方 2 okamotoy@uec.ac.jp 2014 10 21 2014 10 29 10:48 ( ) (2) 2014 10 21 1 / 44 ( ) 1 (10/7) ( ) (10/14) 2 (10/21) 3 ( ) (10/28) 4 ( ) (11/4) 5 (11/11) 6 (11/18) 7 (11/25) ( ) (2) 2014 10 21 2 / 44 ( ) 8 (12/2)

More information

BASICとVisual Basic

BASICとVisual Basic Visual Basic BASIC Visual Basic BASICBeginner's All purpose Symbolic Instruction Code Visual Basic Windows BASIC BASIC Visual Basic Visual Basic End Sub .Visual Basic Visual Basic VB 1-1.Visual Basic

More information

課題

課題 float[] xball; float[] yball; int numberofballs = (a) ; int radius=10; size(400,400); xball = (b) (c) [numberofballs]; yball = (d) (e) [numberofballs]; xball[i] = random(radius,width-radius); yball[i]

More information

: Shift-Return evaluate 2.3 Sage? Shift-Return abs 2 abs? 2: abs 3: fac

: Shift-Return evaluate 2.3 Sage? Shift-Return abs 2 abs? 2: abs 3: fac Bulletin of JSSAC(2012) Vol. 18, No. 2, pp. 161-171 : Sage 1 Sage Mathematica Sage (William Stein) 2005 2 2006 2 UCSD Sage Days 1 Sage 1.0 4.7.2 1) Sage Maxima, R 2 Sage Firefox Internet Explorer Sage

More information

Windows (L): D:\jyugyou\ D:\jyugyou\ D:\jyugyou\ (N): en2 OK 2

Windows (L): D:\jyugyou\ D:\jyugyou\ D:\jyugyou\ (N): en2 OK 2 Windows C++ Microsoft Visual Studio 2010 C++ Microsoft C++ Microsoft Visual Studio 2010 Microsoft Visual Studio 2010 C++ C C++ Microsoft Visual Studio 2010 Professional Professional 1 Professional Professional

More information

JavaScript の使い方

JavaScript の使い方 JavaScript Release10.5 JavaScript NXJ JavaScript JavaScript JavaScript 2 JavaScript JavaScript JavaScript NXJ JavaScript 1: JavaScript 2: JavaScript 3: JavaScript 4: 1 1: JavaScript JavaScript NXJ Static

More information

K227 Java 2

K227 Java 2 1 K227 Java 2 3 4 5 6 Java 7 class Sample1 { public static void main (String args[]) { System.out.println( Java! ); } } 8 > javac Sample1.java 9 10 > java Sample1 Java 11 12 13 http://java.sun.com/j2se/1.5.0/ja/download.html

More information

Taro13-第6章(まとめ).PDF

Taro13-第6章(まとめ).PDF % % % % % % % % 31 NO 1 52,422 10,431 19.9 10,431 19.9 1,380 2.6 1,039 2.0 33,859 64.6 5,713 10.9 2 8,292 1,591 19.2 1,591 19.2 1,827 22.0 1,782 21.5 1,431 17.3 1,661 20.0 3 1,948 1,541 79.1 1,541 79.1

More information

( ) ( ) lex LL(1) LL(1)

( ) ( ) lex LL(1) LL(1) () () lex LL(1) LL(1) http://www.cs.info.mie-u.ac.jp/~toshi/lectures/compiler/ 29 5 14 1 1 () / (front end) (back end) (phase) (pass) 1 2 1 () () var left, right; fun int main() { left = 0; right = 10;

More information

課題

課題 int[] scores; PFont font; int[] scores = { (a) ; PFont font; size(300,400); scores = (a); scores[0] = 10000; scores[1] = 9000; scores[2] = 5000; scores[3] = 1000; scores[4] = 30; font = loadfont("serif-48.vlw");

More information

version 1.0 November 2010 PyRAF Y. Nakajima Computer and Data Management Division Subaru Telescope NAOJ

version 1.0 November 2010 PyRAF Y. Nakajima Computer and Data Management Division Subaru Telescope NAOJ version 1.0 November 2010 PyRAF Y. Nakajima Computer and Data Management Division Subaru Telescope NAOJ Chapter 1 PyRAF 1.1 PyRAF PyRAF IRAF Python STScI 1998 (1) IRAF-CL (2) CL-? (3) IRAF Python wrapper

More information

GIMP

GIMP (JavaScript ) Javascript 2 1. 2 2. 52 3. A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2 4. 13 5. 6. 7. 8. 9. 13 10. 11. 12. JavaScript.png 1 GIMP 200 300 2 var ctx; function init() { var

More information

取扱説明書 [F-01D]

取扱説明書 [F-01D] F-01D 12.7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 a b 18 c d e 19 a b c d e f a b j k l g h i f m n o p a b c d e f g h i j k l m n o p a t y b X 20 a b a b a b c a b c 21 a b a b c a b c a b 22 23

More information

An Introduction to OSL

An Introduction to OSL .... An Introduction to OSL TeamGPS 2009 3 CSA (TeamGPS) An Introduction to OSL 2009 3 CSA 1 / 45 ..1..2..3..4.... : (TeamGPS) An Introduction to OSL 2009 3 CSA 2 / 45 Disclaimer: OSL Bonanza Crafty (pruning/cut,

More information

r08.dvi

r08.dvi 19 8 ( ) 019.4.0 1 1.1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( ) 1 next 1 prev 1 head cur tail head cur prev

More information

たのしいプログラミング Pythonではじめよう!

たのしいプログラミング Pythonではじめよう! Title of English-language original: Python for Kids A Playful Introduction to Programming ISBN 978-1-59327-407-8, published by No Starch Press, Inc. Copyright 2013 by Jason R. Briggs. Japanese-language

More information

コンピュータ概論

コンピュータ概論 4.1 For Check Point 1. For 2. 4.1.1 For (For) For = To Step (Next) 4.1.1 Next 4.1.1 4.1.2 1 i 10 For Next Cells(i,1) Cells(1, 1) Cells(2, 1) Cells(10, 1) 4.1.2 50 1. 2 1 10 3. 0 360 10 sin() 4.1.2 For

More information

ch31.dvi

ch31.dvi 1 1 1.1 1.1.1 ( ) ( 1.1 ): [ ] [ ] CPU[ + ] [ ] CPU( ) ( 1 2 1 1.1: ( 1.1 ): ( ) [ ] ( )[ ] + ( ) (+ ) ( ) ( ) 1.1. 3 1.2: ( ) ( ) ( 1.2) 4 1 1.3: 120m/ (432km/h) 0.5 2m/ 1 ( 1 ) ( ) ( ) ( 1.3) 1.1. 5

More information

2015 I ( TA)

2015 I ( TA) 2015 I ( TA) Schrödinger PDE Python u(t, x) x t 2 u(x, t) = k u(t, x) t x2 k k = i h 2m Schrödinger h m 1 ψ(x, t) i h ( 1 ψ(x, t) = i h ) 2 ψ(x, t) t 2m x Cauchy x : x Fourier x x Fourier 2 u(x, t) = k

More information

ohp08.dvi

ohp08.dvi 19 8 ( ) 2019.4.20 1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: 2 (2) NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( 2) 3 (3) head cur tail head cur prev data

More information

コメント プログラム中には コメントを加える事ができます 処理の際には無視されるので 注釈や覚え書きとして利 できます print("hello Sapporo!") # Hello Sapporo! と 表 する # コメントは無視される 字列 字列とは 単語や 章のような 字の連なったものです

コメント プログラム中には コメントを加える事ができます 処理の際には無視されるので 注釈や覚え書きとして利 できます print(hello Sapporo!) # Hello Sapporo! と 表 する # コメントは無視される 字列 字列とは 単語や 章のような 字の連なったものです CHaser のための Python 基礎編 これは U-16 札幌プロコン事前講習会に向けて メンター向けに Python の基礎を すドキュメントです 意するもの 基本編 PC Windows パソコンで CHaser を動かすまで で 意した USB メモリ Python プログラムの実 法は 主に 2 通りあります 対話型シェルによる実 対話型シェルとは その名の通り 対話をしているように

More information

RL_tutorial

RL_tutorial )! " = $ % & ' "(& &*+ = ' " + %' "(- + %. ' "(. + γ γ=0! " = $ " γ=0.9! " = $ " + 0.9$ " + 0.81$ "+, + ! " #, % #! " #, % # + (( + #,- +. max 2 3! " #,-, % 4! " #, % # ) α ! " #, % ' ( )(#, %)!

More information

r07.dvi

r07.dvi 19 7 ( ) 2019.4.20 1 1.1 (data structure ( (dynamic data structure 1 malloc C free C (garbage collection GC C GC(conservative GC 2 1.2 data next p 3 5 7 9 p 3 5 7 9 p 3 5 7 9 1 1: (single linked list 1

More information

210-0004 TEL 200-3298,3300 FAX 222-1442 14 ( ) 14 ( ) 7 ( ) 16 ( ) 16 ( ) 23 ( ) (%) 1 ( ) 1 ( ) 2 ( ) 7 ( ) 7 ( ) 22 ( ) 8 ( ) 22 ( ) 30 ( ) or 31( )

210-0004 TEL 200-3298,3300 FAX 222-1442 14 ( ) 14 ( ) 7 ( ) 16 ( ) 16 ( ) 23 ( ) (%) 1 ( ) 1 ( ) 2 ( ) 7 ( ) 7 ( ) 22 ( ) 8 ( ) 22 ( ) 30 ( ) or 31( ) 210-0004 TEL 200-3298,3300 FAX 222-1442 10:00 14:00 210-0004 TEL 200-3298,3300 FAX 222-1442 14 ( ) 14 ( ) 7 ( ) 16 ( ) 16 ( ) 23 ( ) (%) 1 ( ) 1 ( ) 2 ( ) 7 ( ) 7 ( ) 22 ( ) 8 ( ) 22 ( ) 30 ( ) or 31(

More information

ohp07.dvi

ohp07.dvi 19 7 ( ) 2019.4.20 1 (data structure) ( ) (dynamic data structure) 1 malloc C free 1 (static data structure) 2 (2) C (garbage collection GC) C GC(conservative GC) 2 2 conservative GC 3 data next p 3 5

More information

tuat1.dvi

tuat1.dvi ( 1 ) http://ist.ksc.kwansei.ac.jp/ tutimura/ 2012 6 23 ( 1 ) 1 / 58 C ( 1 ) 2 / 58 2008 9 2002 2005 T E X ptetex3, ptexlive pt E X UTF-8 xdvi-jp 3 ( 1 ) 3 / 58 ( 1 ) 4 / 58 C,... ( 1 ) 5 / 58 6/23( )

More information

< F2D A839382CC906A2E6A7464>

< F2D A839382CC906A2E6A7464> ビュホンの針 1. はじめに [Java アプレット ] [Java アプリケーション ] ビュホン ( Buffon 1707-1788) は 針を投げて円周率 πを求めることを考えました 平面上に 幅 2aの間隔で 平行線を無数に引いておきます この平面上に長さ2bの針を落とすと この針が平行線と交わる確立 pは p=(2b) (aπ) 1 となります ただし b

More information

B Simon (Trump ) SimonU.pas SimonP.dpr Name FormSimon Caption Position podesktopcenter uses Windows, Messages, SysUtils,

B Simon (Trump ) SimonU.pas SimonP.dpr Name FormSimon Caption Position podesktopcenter uses Windows, Messages, SysUtils, B 132 20 1 1 20.1 20.1.1 1 52 10 1 2 3... 7 8 8 8 20.1.2 1 5 6 7 3 20.1.3 1 3 8 20.1.4 13 20.1.5 4 1 (solitaire) B 133 20.2 20.2.1 Simon (Trump ) SimonU.pas SimonP.dpr 20.2.2 Name FormSimon Caption Position

More information

JavaScript演習

JavaScript演習 JavaScript 演習 2 1 本日の内容 prompt 関数 演習 1 演習 2 document.getelementbyid 関数 演習 3 イベント処理 基本的なフォーム テキストボックスの入力値の取得 演習 4 IE における JavaScript のデバッグ方法 1. ツール インターネットオプションメニューを実行 2. 詳細設定タブの スクリプトエラーごとに通知を表示する をチェック

More information

橡ボーダーライン.PDF

橡ボーダーライン.PDF 1 ( ) ( ) 2 3 4 ( ) 5 6 7 8 9 10 11 12 13 14 ( ) 15 16 17 18 19 20 ( ) 21 22 23 24 ( ) 25 26 27 28 29 30 ( ) 31 To be or not to be 32 33 34 35 36 37 38 ( ) 39 40 41 42 43 44 45 46 47 48 ( ) 49 50 51 52

More information

Object MenuComponent MenuBar MenuItem Menu CheckboxMenuItem

Object MenuComponent MenuBar MenuItem Menu CheckboxMenuItem Java Object MenuComponent MenuBar MenuItem Menu CheckboxMenuItem 2 MenuComponent MenuComponent setfont() void setfont(font f) MenuBar MenuBar MenuBar() MenuBar add() Menu add(menu m) Menu Menu Menu String

More information

piyo0704b.rtfd

piyo0704b.rtfd ウィンドウ内に収まらなくなると 右および下に スクロールバーが現われます 51 Text 部品と Scrollbar 1 Text 部品と Scrollbar とを組み合わせて利用すると便利です root = Tk(); root.title("text with: Scrollbar") root.config(width=150, height=80) frame = Frame(root) frame.pack(fill=both,

More information

Taro-twokansu3.jtd

Taro-twokansu3.jtd //------------------------------------------------ // // 2 次関数のグラフの広がり // y=ax^2 のグラフ // Ver3 // Copyright(C) K.Niwa 2014.08.09 // //------------------------------------------------ NO.33 エミュレータ画面例 [ アプリの概要

More information

橡Taro9-生徒の活動.PDF

橡Taro9-生徒の活動.PDF 3 1 4 1 20 30 2 2 3-1- 1 2-2- -3- 18 1200 1 4-4- -5- 15 5 25 5-6- 1 4 2 1 10 20 2 3-7- 1 2 3 150 431 338-8- 2 3 100 4 5 6 7 1-9- 1291-10 - -11 - 10 1 35 2 3 1866 68 4 1871 1873 5 6-12 - 1 2 3 4 1 4-13

More information

19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics;

19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics; 19 3!!...... (+) (>) (++) (+=) for while 3.1!! 3.1.1 50 20 20 5 (20, 20) 3.1.1 (1)(Blocks1.java) public class Blocks1 extends JApplet { public void paint(graphics g){ 5 g.drawrect( 20, 20, 50, 20); g.drawrect(

More information

() / (front end) (back end) (phase) (pass) 1 2

() / (front end) (back end) (phase) (pass) 1 2 1 () () lex http://www.cs.info.mie-u.ac.jp/~toshi/lectures/compiler/ 2018 4 1 () / (front end) (back end) (phase) (pass) 1 2 () () var left, right; fun int main() { left = 0; right = 10; return ((left

More information

PowerPoint Presentation

PowerPoint Presentation 知能システム論 1 (3) 2009.4.21 情報システム学研究科情報メディアシステム学専攻知能システム学講座末廣尚士 - 講義資料の HP http://www.taka.is.uec.ac.jp/ から右のメニューの class をクリック または http://www.taka.is.uec.ac.jp/class200 9/class2009.html を直接入力 2. Python 入門

More information

課題

課題 float xball;// 円の中心の X 座標 float yball; // 円の中心の Y 座標 float rball; // 円の半径 color cball; // 円の色 // 円を移動させる void updateball(){ yball -= 1; if(yball+rball< 0){ yball = height+rball; // 円を描く void drawball(){

More information

スライド 1

スライド 1 1 1. 2 2. 3 isplever 4 5 6 7 8 9 VHDL 10 VHDL 4 Decode cnt = "1010" High Low DOUT CLK 25MHz 50MHz clk_inst Cnt[3:0] RST 2 4 1010 11 library ieee; library xp; use xp.components.all; use ieee.std_logic_1164.all;

More information

Safari AppletViewer Web HTML Netscape Web Web 15-1 Applet Web Applet init Web paint Web start Web HTML stop destroy update init Web paint start Web up

Safari AppletViewer Web HTML Netscape Web Web 15-1 Applet Web Applet init Web paint Web start Web HTML stop destroy update init Web paint start Web up Safari AppletViewer Web HTML Netscape Web Web 15-1 Applet Web Applet init Web paint Web start Web HTML stop destroy update init Web paint start Web update Event Driven paint Signature Overwriting Overriding

More information

Java学習教材

Java学習教材 Java 2016/4/17 Java 1 Java1 : 280 : (2010/1/29) ISBN-10: 4798120987 ISBN-13: 978-4798120980 2010/1/29 1 Java 1 Java Java Java class FirstExample { public static void main(string[] args) { System.out.println("

More information

デュアルウェア講習会課題 5 会津大学講習会 簡単な IoT を作成 2018 The University of Aizu

デュアルウェア講習会課題 5 会津大学講習会 簡単な IoT を作成 2018 The University of Aizu 会津大学講習会 簡単な IoT を作成 2018 The University of Aizu 目次 1 課題... 1 1.1 課題説明... 1 課題 5-1... 1 課題 5-2... 1 2 Google API... 2 2.1 Gmail API とは... 2 2.2 Gmail API 設定... 2 Google アカウント作成... 2 Google Developers Console

More information

New version (2.15.1) of Specview is now available Dismiss Windows Specview.bat set spv= Specview set jhome= JAVA (C:\Program Files\Java\jre<version>\

New version (2.15.1) of Specview is now available Dismiss Windows Specview.bat set spv= Specview set jhome= JAVA (C:\Program Files\Java\jre<version>\ Specview VO 2012 2012/3/26 Specview Specview STSCI(Space Telescope SCience Institute) VO Specview Web page http://www.stsci.edu/resources/software hardware/specview http://specview.stsci.edu/javahelp/main.html

More information

Agenda Motivation How it works Performance Limitation Conclusion

Agenda Motivation How it works Performance Limitation Conclusion py2llvm: Python to LLVM translator Syoyo Fujita Agenda Motivation How it works Performance Limitation Conclusion Agenda Motivation How it works Performance Limitation Conclusion py2llvm Python LLVM Python,

More information

JavaScript 1.! DOM Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2

JavaScript 1.! DOM Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2 JavaScript (2) 1 JavaScript 1.! 1. 2. 3. DOM 4. 2. 3. Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2 (1) var a; a = 8; a = 3 + 4; a = 8 3; a = 8 * 2; a = 8 / 2; a = 8 % 3; 1 a++; ++a; (++

More information

1.1. jquery 1 jquery jcanvas javascript jquery JavaScript jquery $() JavaScript JavaScript jquery Googlr Chrome Eddge(Enternet Explorer) Web Web jquer

1.1. jquery 1 jquery jcanvas javascript jquery JavaScript jquery $() JavaScript JavaScript jquery Googlr Chrome Eddge(Enternet Explorer) Web Web jquer 1 1.1. jquery 1 jquery jcanvas javascript jquery JavaScript jquery $() JavaScript JavaScript jquery Googlr Chrome Eddge(Enternet Explorer) Web Web jquery jcanvas jquery jcanvas 1.2. jcanvas HTML5 Canvas

More information

Emacs Ruby..

Emacs Ruby.. command line editor 27014533 2018 3 1 5 1.1................................... 5 1.2................................... 5 2 6 2.1 Emacs...................................... 6 2.2 Ruby.......................................

More information

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I  Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~alse I Exercise on Programming I http://bit.ly/oitprog1 13 of 14 ( RD S ) I 13 of 14 1 / 39 https://bit.ly/oitprog1 ( RD S ) I 13 of 14 2 / 39 game.rb ( RD S ) I 13 of 14 3 / 39 game.rb 12 ( ) 1 require "io/console"

More information

2 PostScript PostScript (token) 437 == 437 == PostScript PostScript 437 == PostScript (operator) 437 == == ==

2 PostScript PostScript (token) 437 == 437 == PostScript PostScript 437 == PostScript (operator) 437 == == == PostScript version 1.03 2003 1 24 Copyright c 2000 2003 Daikoku Manabu 1 PostScript 1.1 PostScript PostScript PostScript (page description language) PostScript Adobe Systems Incorporated PostScript PostScript

More information

Boo Boo 2 Boo 2.NET Framework SDK 2 Subversion 2 2 Java 4 NAnt 5 Boo 5 5 Boo if 11 for 11 range 12 break continue 13 pass

Boo Boo 2 Boo 2.NET Framework SDK 2 Subversion 2 2 Java 4 NAnt 5 Boo 5 5 Boo if 11 for 11 range 12 break continue 13 pass Boo Boo 2 Boo 2.NET Framework SDK 2 Subversion 2 2 Java 4 NAnt 5 Boo 5 5 Boo 6 6 7 9 10 11 if 11 for 11 range 12 break continue 13 pass 13 13 14 15 15 23 23 24 24 24 25 import 26 27-1- Boo Boo Python CLI.NET

More information

Java演習(9) -- クラスとメソッド --

Java演習(9)   -- クラスとメソッド -- Java (9) Java (9) Java (9) 3 (x, y) x 1 30 10 (0, 50) 1 2 10 10 (width - 10, 80) -2 3 50 10 (width / 2, 110) 2 width 3 (RectMove4-1.java) import javax.swing.japplet; import javax.swing.timer; import java.awt.graphics;

More information

Java演習(4) -- 変数と型 --

Java演習(4)   -- 変数と型 -- 50 20 20 5 (20, 20) O 50 100 150 200 250 300 350 x (reserved 50 100 y 50 20 20 5 (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics; (reserved public class Blocks1 extends

More information

Q&A集

Q&A集 MapViewer & ver.2 EWEB-3C-N055 PreSerV for Web MapViewer & i 1... 1 1.1... 1 1.2... 2 1.3... 3 1.4... 4 1.5... 5 1.6... 6 1.7... 7 1.8... 8 1.9... 9 1.10...11 1.11...12 1.12...13 1.13...14 1.14...15 1.15...16

More information

~/WWW-local/compIID (WWW IID ) $ mkdir WWW-local $ cd WWW-local $ mkdir compiid 3. Emacs index.html n (a) $ cd ~/WWW/compIID

~/WWW-local/compIID (WWW IID ) $ mkdir WWW-local $ cd WWW-local $ mkdir compiid 3. Emacs index.html n (a) $ cd ~/WWW/compIID 10 10 10.1 1. 2. 3. HTML(HyperText Markup Language) Web [ ][ ] HTML Web HTML HTML Web HTML ~b08a001/www/ ( ) ~b08a001/www-local/ ( ) html ( ) 10.2 WWW WWW-local b08a001 ~b08a001/www/ ~b08a001/www-local/

More information

Quick Sort 計算機アルゴリズム特論 :2017 年度 只木進一

Quick Sort 計算機アルゴリズム特論 :2017 年度 只木進一 Quick Sort 計算機アルゴリズム特論 :2017 年度 只木進一 2 基本的考え方 リスト ( あるいは配列 )SS の中の ある要素 xx(pivot) を選択 xx より小さい要素からなる部分リスト SS 1 xx より大きい要素からなる部分リスト SS 2 xx は SS 1 または SS 2 に含まれる 長さが 1 になるまで繰り返す pivot xx の選び方として 中央の要素を選択すると効率が良い

More information

1-4 int a; std::cin >> a; std::cout << "a = " << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >>

1-4 int a; std::cin >> a; std::cout << a =  << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >> 1 C++ 1.1 C C++ C++ C C C++ 1.1.1 C printf() scanf() C++ C hello world printf() 1-1 #include printf( "hello world\n" ); C++ 1-2 std::cout

More information

or a 3-1a (0 b ) : max: a b a > b result a result b ( ) result Python : def max(a, b): if a > b: result = a else: result = b ret

or a 3-1a (0 b ) : max: a b a > b result a result b ( ) result Python : def max(a, b): if a > b: result = a else: result = b ret 4 2018.10.18 or 1 1.1 3-1a 3-1a (0 b ) : max: a b a > b result a result b result Python : def max(a, b): if a > b: result = a result = b return(result) : max2: a b result a b > result result b result 1

More information

( )$("canvas").drawarc({strokestyle:"red", x:100, y:100, radius:20, start:0, end:360); drawline(x1:, y1:,... xn:, yn:) drawline n 2 n 3 x1: y1: xn: yn

( )$(canvas).drawarc({strokestyle:red, x:100, y:100, radius:20, start:0, end:360); drawline(x1:, y1:,... xn:, yn:) drawline n 2 n 3 x1: y1: xn: yn 0.1. jquaery jcanvas jquery John Resig OSS JavaScript Web JavaScript jquery jquery 1 0.2. jcanvas jcanvas 0.3. jcanvas HTML5 Canvas Canvas jcanvas jcanvas jquery Canvas API jcanvas Grouping Layer jcanvas

More information

1

1 1 2 3 4 5 0% 20% 40% 60% 80% 100% 6 7 8 0% 20% 40% 60% 80% 100% 9 0% 20% 40% 60% 80% 100% 10 100% 90% 80% 70% 60% 50% 40% 30% 20% 10% 0% 2529 (n=17) 3034 35 (n=21) (n=17) 2529 (n=19) 3034 35 (n=34) (n=64)

More information

lifedesign_contest_No3

lifedesign_contest_No3 1 3 5 Apple Developer Program 5 AWS 8 Raspberry Pi 14 18 19 { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "sns:createplatformendpoint" ], "Resource": [ ] ] #

More information

piyo0704a.rtfd

piyo0704a.rtfd す ここで中核となるのは 組み込み関数 eval および compile です 1 コードを実行するだけなら Python/Jython で記述したコードを実行するためのツール作りに着手します >>> compile("3+4", "(*.*", "eval" >>> eval(compile("3+4",

More information

Specview Specview Specview STSCI(Space Telescope SCience Institute) VO Specview Web page htt

Specview Specview Specview STSCI(Space Telescope SCience Institute) VO Specview Web page   htt Specview Specview Specview STSCI(Space Telescope SCience Institute) VO Specview Web page http://www.stsci.edu/resources/software_hardware/specview http://specview.stsci.edu/javahelp/main.html Specview

More information