+def dominosa_format(s):
+ ret = Holder()
+ ret.s = ""
+ params, seed = string.split(s, ":")
+ n = string.atoi(params)
+ w = n+2
+ h = n+1
+ grid = []
+ while len(seed) > 0:
+ if seed[0] == '[': # XXX
+ d, seed = string.split(seed[1:], "]")
+ grid.append(string.atoi(d))
+ else:
+ assert seed[0] in string.digits
+ grid.append(string.atoi(seed[0:1]))
+ seed = seed[1:]
+ assert w*h == len(grid)
+ # I'm going to arbitrarily choose to use 9pt text for the
+ # numbers, and a 16pt grid pitch.
+ textht = 9
+ gridpitch = 16
+ pw = gridpitch * w
+ ph = gridpitch * h
+ psprint(ret, "/Helvetica findfont %g scalefont setfont" % textht)
+ ret.coords = (pw/2, pw/2, ph/2, ph/2)
+ psprint(ret, "%g %g translate" % (-ret.coords[0], -ret.coords[2]))
+ for y in xrange(h):
+ for x in xrange(w):
+ psprint(ret, "%g %g (%d) ctshow" % \
+ ((x+0.5)*gridpitch, (h-y-0.5)*gridpitch, grid[y*w+x]))
+ return ret.coords, ret.s
+