Pythonで碁盤を表す文字列を生成

なんでこんなものを書いてるか、の説明はあとで。

# -*- coding: utf-8 -*-
import sys
import codecs
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)

class Goban(object):

    empty = 0
    black = 1
    white = 2

    def __init__(self, size):
        self.size = size
        self.data = [ [ 0 for i in range(size) ] for j in range(size) ]
    
    def render(self, output=sys.stdout):
        for i, line in enumerate(self.data):
            for j, point in enumerate(line):
                if point == self.empty:
                    output.write(self._empty_str(i, j))
                elif point == self.black:
                    output.write(u'●')
                else:
                    output.write(u'○')
            output.write('\n')
    
    def touch(self, x, y, color):
        self.data[y][x] = color

    def _empty_str(self, x, y):
        if x == 0:
            if y == 0:
                return u'┏'
            elif y == self.size - 1:
                return u'┓'
            else:
                return u'┯'
        elif x == self.size - 1:
            if y == 0:
                return u'┗'
            elif y == self.size - 1:
                return u'┛'
            else:
                return u'┷'
        else:
            if y == 0:
                return u'┠'
            elif y == self.size - 1:
                return u'┨'
            else:
                return u'┼'
        
def test():
    goban_size = 19
    goban = Goban(goban_size)
    goban.touch(4, 4, Goban.black)
    goban.touch(15, 15, Goban.white)
    goban.touch(0, 1, Goban.black)
    goban.render()

if __name__ == '__main__':
    test()