Exemple #1
0
def main(width=200, height=200, scale=2,
        beta=100, nondet=100,
        copy_borders=True, black=80,
        histogram=True, activity=True,
        base=7):

    beta = beta / 100.
    nondet = nondet / 100.

    w, h = width, height
    size = w, h

    if black is not None:
        config = RandomConfiguration(base, black)
    else:
        config = None

    sim_obj = SillySim(size=size, config=config, base=base, nondet=nondet, histogram=histogram, activity=activity, beta=beta, copy_borders=copy_borders)

    display = ZasimDisplay(sim_obj)
    display.set_scale(scale)

    display.control.start()

    if histogram:
        extra_hist = HistogramExtraDisplay(sim_obj, parent=display, height=200, maximum= w * h)
        extra_hist.show()
        display.window.attach_display(extra_hist)
        display.window.addDockWidget(Qt.RightDockWidgetArea, extra_hist)

    if activity:
        extra_activity = HistogramExtraDisplay(sim_obj, attribute="activity", parent=display, height=200, maximum=w*h)
        extra_activity.show()
        display.window.attach_display(extra_activity)
        display.window.addDockWidget(Qt.RightDockWidgetArea, extra_activity)

    sys.exit(app.exec_())
Exemple #2
0
    def slot_change_settings(self):
        self.rule_a = self.rule_a_edit.value()
        self.rule_b = self.rule_b_edit.value()
        self.probability = 1.0 - (self.probab_slider.value() / 1000.)

        # if we don't disconnect the signal, the old displays might be kept
        # instead of deleted by the garbage collector.
        self.displaywidget.display.image_wrapped.disconnect(self.sim_timer.stop)
        self.create_stepfunc()
        self.displaywidget.switch_simulator(self.sim)
        self.displaywidget.set_scale(2)
        self.displaywidget.display.image_wrapped.connect(self.sim_timer.stop)

        # since we have changed things, run the simulation as fast as possible.
        self.sim_timer.start(0)

    def slot_reroll_conf(self):
        self.conf = RandomConfiguration(2, 0.5, 0.5).generate(self.sim.shape)
        self.slot_change_settings()

    def stepsim(self):
        self.sim.step()

if __name__ == "__main__":
    import sys

    gadget = DualRuleGadget()
    gadget.show()

    sys.exit(app.exec_())