def initializer(self): """ Method fot host initialization """ for node in self.network.nodes(): node.memory['neighbors_data'] = {} node._polygon = [node.memory['axis']] node.gallery = ArtGallery(node.memory['axis']) PreviewControl.add_view(node.gallery, str(node.id)) # Fills node neighbors and notify each one its axis node.memory[self.neighborsKey] = \ node.compositeSensor.read()['Neighbors'] node.status = 'IDLE' self.notify(node, node.id, node.memory['axis'])
self.version += 1 if __name__ == '__main__': print "Starting..." tmp = ArtGallery.load("inputs/test_1.poly") g = ArtGallery(tmp.pop(0)) for p in tmp: g.include(p) for p in g.get_points(): if g.is_guard(p): print p, " GUARD!" else: print p print "Min_color = " + str(g._color.get_min_color()) print "color[0] = " + str(g._color.get_color_count(0)) print "color[1] = " + str(g._color.get_color_count(1)) print "color[2] = " + str(g._color.get_color_count(2)) print "color[3] = " + str(g._color.get_color_count(3)) from preview_control import PreviewControl from art_gallery_painter import ArtGalleryPainter previewer = PreviewControl(ArtGalleryPainter) previewer.show(g, "Test") print "END!"
p.y = ((p.y + 0) * 20) + 10 if (p.x > max_x): max_x = p.x if (p.y > max_y): max_y = p.y lines = PreviewDefaults.height // (max_y + 20) columns = PreviewDefaults.width // (max_x + 20) fps = 0 # Starts the graphical interface PreviewControl.start(title=label, lines=lines, columns=columns, fps_limit=fps, painter_class=ArtGalleryPainter) # Defines the network algorithm net.algorithms = ((DistributedArtGallery, {'key': 'axis'}),) i = 0 # Assign to node memory its position for node in net.nodes(): node.memory['axis'] = polygon[i] i += 1