其實這個東西有九成都是寒假的時候做的
顯示棋子和手數
再import到主程式
# 0 = normal 1 = point 2 = top 3 = bottom 4 = left 5 = right 6 = top left 7 = top right 8 = bot left 9 = top right boards = [ [6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7], # a [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # b [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # c [4, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 5], # d [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # e [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # f [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # g [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # h [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # i [4, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 5], # j [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # k [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # l [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # m [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # n [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # o [4, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 5], # p [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # q [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], # r [8, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 9] # s ] |
bc = [ ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'], ['N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N'] ] |
# draw board def draw_board(tabs): K = 40 for i in range(len(boards)): for j in range(len(boards[i])): if boards[i][j] == 0: # normal point pg.draw.line(screen, B, (K * j + K / 2 , K * i), (K * j + K / 2, K * (i +1)), 2) pg.draw.line(screen, B, (K * j, K * i + K / 2), (K * (j + 1), K * i + K / 2), 2) if boards[i][j] == 1: # star point pg.draw.line(screen, B, (K * j + K / 2 , K * i), (K * j + K / 2, K * (i +1)), 2) pg.draw.line(screen, B, (K * j, K * i + K / 2), (K * (j + 1), K * i + K / 2), 2) pg.draw.circle(screen, B, (K * j + K / 2 + 1, K * i + K / 2 + 1), 6, 0) # +1 to make slight fix if boards[i][j] == 2: # top pg.draw.line(screen, B, (K * j, K * i + K / 2), (K * (j + 1), K * i + K / 2), 2) pg.draw.line(screen, B, ((K * j + K / 2, K * i + K / 2)), ((K * j + K / 2, K * i + K)), 2) if boards[i][j] == 3: # bottom pg.draw.line(screen, B, (K * j, K * i + K / 2), (K * (j + 1), K * i + K / 2), 2) pg.draw.line(screen, B, ((K * j + K / 2, K * i + K / 2)), ((K * j + K / 2, K * i)), 2) if boards[i][j] == 4: # left pg.draw.line(screen, B, (K * j + K / 2, K * i + K / 2), (K * (j + 1), K * i + K / 2), 2) pg.draw.line(screen, B, ((K * j + K / 2, K * i)), ((K * j + K / 2, K * (i + 1))), 2) if boards[i][j] == 5: # right pg.draw.line(screen, B, (K * j + K / 2, K * i + K / 2), (K * j, K * i + K / 2), 2) pg.draw.line(screen, B, ((K * j + K / 2, K * i)), ((K * j + K / 2, K * (i + 1))), 2) if boards[i][j] == 6: # top left pg.draw.line(screen, B, (K * j + K / 2, K * i + K / 2), (K * j + K, K * i + K / 2), 2) pg.draw.line(screen, B, (K * j + K / 2, K * i + K / 2), (K * j + K / 2, K * i + K), 2) if boards[i][j] == 7: # top right pg.draw.line(screen, B, (K * j + K / 2, K * i + K / 2), (K * j, K * i + K / 2), 2) pg.draw.line(screen, B, (K * j + K / 2, K * i + K / 2), (K * j + K / 2, K * i + K), 2) if boards[i][j] == 8: # down left pg.draw.line(screen, B, (K * j + K / 2, K * i + K / 2), (K * j + K, K * i + K / 2), 2) pg.draw.line(screen, B, (K * j + K / 2, K * i + K / 2), (K * j + K / 2, K * i), 2) if boards[i][j] == 9: # down right pg.draw.line(screen, B, (K * j + K / 2, K * i + K / 2), (K * j, K * i + K / 2), 2) pg.draw.line(screen, B, (K * j + K / 2, K * i + K / 2), (K * j + K / 2, K * i), 2) for i in range(len(tabs)): for j in range(len(tabs)): if tabs[i][j] == 'B': screen.blit(b_piece, (K * j + 4 , K * i + 4)) if tabs[i][j] == 'W': screen.blit(w_piece, (K * j + 4 , K * i + 4)) |