# Author: <NAME>
# Date: 12-13-16
# Description: This is a program to help me learn L-Systems
# It should generate strings based on the rules applied.


class system:
    axiom = "A"
    sentence = axiom
    rules  = []

    rules.append({
        "A":"A",
        "B":"AB"
        })

    rules.append({
        "A": "B",
        "B": "A"
    })

    def generate(self):
        nextSentence = ""
        for i in range(0,len(self.sentence)):
            current = self.sentence[i]
            found = False
            for j in range(0, len(self.rules)):
                if(current == self.rules[j].get("A")):
                    found = True
                    nextSentence += self.rules[j].get("B")
                    break
                if found == False:
                    nextSentence += current
        self.sentence = nextSentence
        print self.sentence


    def main(self):
        print "Press enter to generate.\nType exit to exit."
        print self.axiom
        while True:
            state = raw_input()
            if(state == "exit"):
                break
            self.generate()

a = system()
a.main()

# Author: <NAME>
# Date: 12-13-16
# Description: This is a program to help me learn L-Systems
# It should generate strings based on the rules applied.


class system:
    axiom = "A"
    sentence = axiom
    rules  = []

    rules.append({
        "A":"A",
        "B":"AB"
        })

    rules.append({
        "A": "B",
        "B": "A"
    })

    def generate(self):
        nextSentence = ""
        for i in range(0,len(self.sentence)):
            current = self.sentence[i]
            found = False
            for j in range(0, len(self.rules)):
                if(current == self.rules[j].get("A")):
                    found = True
                    nextSentence += self.rules[j].get("B")
                    break
                if found == False:
                    nextSentence += current
        self.sentence = nextSentence
        print self.sentence


    def main(self):
        print "Press enter to generate.\nType exit to exit."
        print self.axiom
        while True:
            state = raw_input()
            if(state == "exit"):
                break
            self.generate()

a = system()
a.main()

# Author: <NAME> # Date: 12-13-16 # Description: This is a program to help me learn L-Systems # It should generate strings based on the rules applied.