예제 #1
0
def randtopo(num, low, high):
    hashlist = []
    topolist = []
    arealist = []
    i = 0
    while i < num:
        size = random.choice(range(low, high + 1))
        area = size * size
        sel = [size, size, size, size]
        g.new('')
        randfill(sel, (1 + random.randrange(area)) * int(100 / area))
        if g.empty():
            continue
        h = g.hash(g.getrect())
        if h in hashlist:
            continue
        else:
            hashlist.append(h)
            pbox = g.getrect()
            actarea = pbox[2] * pbox[3]
            clist = g.getcells(g.getrect())
            g.store(clist, dir + 'topo_area%i_hash%i' % (actarea, h))

            clist.insert(0, pbox[2])  #prepare for tiling
            clist.insert(1, pbox[3])
            topolist.append(clist)
            arealist.append(actarea)
            i = i + 1
            continue
            return [topolist, hashlist, arealist]
예제 #2
0
      cursorX += chars.find(data[i + 1]) + 4
      i += 1
    elif data[i] == 'z':
      cursorX = 0
      cursorY += 5
    else:
      col = chars.find(data[i])
      if col & 1 != 0: cellList += [cursorX, cursorY]
      if col & 2 != 0: cellList += [cursorX, cursorY + 1]
      if col & 4 != 0: cellList += [cursorX, cursorY + 2]
      if col & 8 != 0: cellList += [cursorX, cursorY + 3]
      if col & 16 != 0: cellList += [cursorX, cursorY + 4]
      cursorX += 1
    i += 1
  return cellList

filename = golly.opendialog('Choose an apgsearch log file')
dirname = golly.opendialog('Choose a folder for the output', 'dir')
with open(filename) as f:
  line = f.readline()
  while line:
    if not line.isspace() and line[0] != '@':
      code = line.split()[0]
      try:
        cellList = readApg(code)
      except Exception, args:
        golly.warn(args[0])
      else:
        golly.store(cellList, dirname + code + '.rle')
    line = f.readline()
예제 #3
0
def writetolibrary(patname, pat, ticks):
    g.store(pat, libpath + patname + ".rle")
    if ticks > 0:
        f = open(libpath + patname + ".rle", 'a')
        f.write("maxticks = " + str(ticks))
        f.close()
예제 #4
0
    if g.empty():
        continue

    pbox = g.getrect()
    h = adj_hash(pbox)

    # h=g.hash(g.getrect())
    if h in hashlist:
        continue
    else:
        hashlist.append(h)
        pbox = g.getrect()
        actarea = pbox[2] * pbox[3]
        clist = g.getcells(g.getrect())
        g.store(clist, dir + 'topo_area%i_hash%s' % (actarea, h))

        clist.insert(0, pbox[2])  #prepare for tiling
        clist.insert(1, pbox[3])
        topolist.append(clist)
        i = i + 1
        continue
    event = g.getevent()
    if event.startswith("key"):
        evt, ch, mods = event.split()
        if ch == "q":
            out = 1
            break
        if ch == "n":
            next = 1
            break
예제 #5
0
   def save(self, fn, desc = None):
      """\
Save the pattern to file 'fn' in RLE format.
An optional description 'desc' may be given."""
      golly.store(self, fn, desc)
예제 #6
0
   def save(self, fn, desc = None):
       """\
 Save the pattern to file 'fn' in RLE format.
 An optional description 'desc' may be given."""
       golly.store(self, fn, desc)