import processes
import agents
import networks
import recruiters


class Experiment(object):
    def __init__(self, session):
        self.task = "Experiment title"
        self.session = session

    def add_sources(self):
        pass

    def step(self):
        pass


class Demo1(Experiment):
    def __init__(self, session):
        super(Demo1, self).__init__(session)
        self.task = "Transmission chain"
        self.num_agents = 10
        self.num_steps = self.num_agents - 1
        self.network = networks.Chain(self.session)
        self.process = processes.RandomWalkFromSource(self.network)
        self.recruiter = recruiters.BotoRecruiter()

        # Setup for first time experiment is accessed
        if not self.network.sources:
            source = agents.SinusoidalFunctionSource()
            self.network.add_node(source)
            print "Added initial source: " + str(source)

    def newcomer_arrival_trigger(self, newcomer):

        # Set the newcomer to invisible.
        newcomer.is_visible = False

        self.network.add_agent(newcomer)

        # If this is the first participant, link them to the source.
        if len(self.network) == 0:
            source = self.network.sources[0]
            source.connect_to(newcomer)
            self.network.db.commit()

        # Run the next step of the process.
        self.process.step()

    def transmission_reception_trigger(self, transmissions):
        # Mark transmissions as received
        for t in transmissions:
            t.mark_received()

    def information_creation_trigger(self, info):
        if self.is_experiment_over():
            # If the experiment is over, stop recruiting and export the data.
            self.recruiter.close_recruitment()
        else:
            # Otherwise recruit a new participant.
            self.recruiter.recruit_new_participants(n=1)

    def is_experiment_over(self):
        return self.network.links == self.num_agents


class Demo2(Experiment):
    def __init__(self, session):
        super(Demo2, self).__init__(session)
        self.task = "Moran process over scale free network"
        self.num_agents = 10
        self.num_steps = 20
        self.network = networks.Chain(self.session)
        self.process = processes.MoranProcess(self.network)

        # Setup for first time experiment is accessed
        if not self.network.sources:
            source = agents.RandomBinaryStringSource()
            self.network.add_node(source)
            print "Added initial source: " + str(source)

    def newcomer_arrival_trigger(self, newcomer):
        # Seed newcomer with info from source
        source = self.network.sources[0]
        source.connect_to(newcomer)
        self.network.trigger_source(source)
        newcomer.receive_all()

        # Run the process
        self.process.step()

    def is_experiment_over(self):
        return False

@@ -1,71 +1,4 @@
-import processes%0Aimport agents%0Aimport networks%0Aimport recruiters%0A%0A%0A
 clas
@@ -127,721 +127,8 @@
 on%0A%0A
-    def add_sources(self):%0A        pass%0A%0A    def step(self):%0A        pass%0A%0A%0Aclass Demo1(Experiment):%0A    def __init__(self, session):%0A        super(Demo1, self).__init__(session)%0A        self.task = %22Transmission chain%22%0A        self.num_agents = 10%0A        self.num_steps = self.num_agents - 1%0A        self.network = networks.Chain(self.session)%0A        self.process = processes.RandomWalkFromSource(self.network)%0A        self.recruiter = recruiters.BotoRecruiter()%0A%0A        # Setup for first time experiment is accessed%0A        if not self.network.sources:%0A            source = agents.SinusoidalFunctionSource()%0A            self.network.add_node(source)%0A            print %22Added initial source: %22 + str(source)%0A%0A
     
@@ -173,25 +173,24 @@
 comer):%0A
-%0A
         
 # Set th
@@ -185,1891 +185,226 @@
     
-# Set the newcomer to invisible.%0A        newcomer.is_visible = False%0A%0A        self.network.add_agent(newcomer)%0A%0A        # If this is the first participant, link them to the source.%0A        if len(self.network) == 0:%0A            source = self.network.sources%5B0%5D%0A            source.connect_to(newcomer)%0A            self.network.db.commit()%0A%0A        # Run the next step of the process.%0A        self.process.step()%0A%0A    def transmission_reception_trigger(self, transmissions):%0A        # Mark transmissions as received%0A        for t in transmissions:%0A            t.mark_received()%0A%0A    def information_creation_trigger(self, info):%0A        if self.is_experiment_over():%0A            # If the experiment is over, stop recruiting and export the data.%0A            self.recruiter.close_recruitment()%0A        else:%0A            # Otherwise recruit a new participant.%0A            self.recruiter.recruit_new_participants(n=1)%0A%0A    def is_experiment_over(self):%0A        return self.network.links == self.num_agents%0A%0A%0Aclass Demo2(Experiment):%0A    def __init__(self, session):%0A        super(Demo2, self).__init__(session)%0A        self.task = %22Moran process over scale free network%22%0A        self.num_agents = 10%0A        self.num_steps = 20%0A        self.network = networks.Chain(self.session)%0A        self.process = processes.MoranProcess(self.network)%0A%0A        # Setup for first time experiment is accessed%0A        if not self.network.sources:%0A            source = agents.RandomBinaryStringSource()%0A            self.network.add_node(source)%0A            print %22Added initial source: %22 + str(source)%0A%0A    def newcomer_arrival_trigger(self, newcomer):%0A        # Seed newcomer with info from source%0A        source = self.network.sources%5B0%5D%0A        source.connect_to(newcomer)%0A        self.network.trigger_source(source)%0A        newcomer.receive_all()%0A%0A        # Run the process%0A        self.process.step()
+pass%0A%0A    def transmission_reception_trigger(self, transmissions):%0A        pass%0A%0A    def information_creation_trigger(self, info):%0A        pass%0A%0A    def add_sources(self):%0A        pass%0A%0A    def step(self):%0A        pass
 %0A%0A  
@@ -448,16 +448,29 @@
    r
-eturn False
+aise NotImplementedError
 %0A

Remove custom experiments from experiments.py