def generate(self): try: print(int(self.mapsizetext.get("1.0", END))) tree = self.parent.gc.tree if len(tree.get_children()) == 0: raise NoTreeChildrenException code = asp_map_size(int(self.mapsizetext.get("1.0", END))) for c in tree.get_children(): cdata = tree.set(c) tm = Tilemap(1,1) f = open(cdata['filepath'], 'r') tm.tilemap = json.load(f) f.close() code = code + asp_room_entry(tm, cdata['roomname'], cdata['numrooms']) f = open("asp/sample-gen.lp", "r") generator_asp = f.read() f.close() code = code + generator_asp self.write_to_txt(self.gentxt, code) self.write_to_txt(self.solvetxt, clingo_spawn(code)) except ValueError: self.log("invalid map size") except NoTreeChildrenException: self.log("no rooms to use")
from dungenasp.maputil.tilemap import Tilemap from dungenasp.asp.generator import RoomModelASP, asp_room_entry tm = Tilemap(10,10) tm.tilemap[0][2] = 1 tm.tilemap[2][4] = 1 tm.tilemap[2][5] = 1 tm.tilemap[4][6] = 1 tm.tilemap[5][6] = 1 print(asp_room_entry(tm, "qweqwe", 10)) from asp.clingo import clingo_spawn print clingo_spawn('fact.')