def strDelim(self, d):
        dStr = D(d) * D(self.delititer_multiplier)
        if(dStr > 150):
            return core.strContent(self.delimiter_prepend + str(D(round(dStr, -1)).quantize(D(1))) + self.delimiter_append)

        dStr = dStr.quantize(D(1))
        return core.strContent(self.delimiter_prepend + str(dStr) + self.delimiter_append)
Example #2
0
    def generate(self):
        #line = (("0", core.strContent(0)), ("0.25", core.strContent(0.25)), ("0.5", core.strContent(0.5)), ("0.75", core.strContent(0.75)), ("1", core.strContent(1)))
        line = []
        for i in range(0, 6):
            line.append((str(i / 5.0), core.strContent(i)))

        questions = []

        i = 0
        while (i < 30):
            val = RC(self.valid)
            lead = RC(self.validLead)

            if (val < .099 and (val > .051 or val < 0.49) and lead != 0):
                continue

            #sVal = str(val)[1:]

            if (lead > 0 or RI(0, 1)):
                sVal = str(lead) + str(val)

            sVal = (lead + val) / 5.0

            questions.append(
                (str(sVal), core.strContent(self.toPercent(lead + val))))

            i += 1

        return [line, questions]
Example #3
0
 def generate(self):
     #line = (("0", core.strContent(0)), ("0.25", core.strContent(0.25)), ("0.5", core.strContent(0.5)), ("0.75", core.strContent(0.75)), ("1", core.strContent(1)))
     line = []
     for i in range(0, 6):
         line.append((str(i/5.0), core.strContent(i)))
         
     questions = []
     
     i = 0
     while(i < 30):
         val = RC(self.valid)
         lead = RC(self.validLead)
         
         if(val < .099 and (val > .051 or val < 0.49) and lead != 0):
             continue
         
         #sVal = str(val)[1:]
         
         if(lead > 0 or RI(0, 1)):
             sVal = str(lead) + str(val)
         
         sVal = (lead + val) / 5.0
         
         questions.append((str(sVal), core.strContent(self.toPercent(lead + val))))
         
         i += 1
     
     return [line, questions]
    def generate(self):
        line = (("0", core.strContent(0)), ("0.25", core.strContent(0.25)),
                ("0.5", core.strContent(0.5)), ("0.75", core.strContent(0.75)),
                ("1", core.strContent(1)))
        #line = (("0", core.strContent(0)), ("0.5", core.strContent(0.5)), ("1", core.strContent(1)))

        questions = []
        prev = (0, 0)
        val = (0, 0)

        i = 0
        while (i < 20):
            while (val[0] == prev[0] and val[1] == prev[1]):
                val = self.valid.get()

            sVal = str((val[0] * 1.0) / val[1])
            if (len(sVal) > 5):
                sVal = sVal[0:5]

            questions.append((sVal, core.frtContent(val[0], val[1])))

            i += 1
            val = prev

        return [line, questions]
    def strDelim(self, d):
        dStr = D(d) * D(self.delititer_multiplier)
        if (dStr > 150):
            return core.strContent(self.delimiter_prepend +
                                   str(D(round(dStr, -1)).quantize(D(1))) +
                                   self.delimiter_append)

        dStr = dStr.quantize(D(1))
        return core.strContent(self.delimiter_prepend + str(dStr) +
                               self.delimiter_append)
    def generate(self):
        pattern = [RC([0, 1]), RC([1, 2]), RC([0, 2])]
        gates = []
        
        #Get the selector
        selector = self.getSelector()
        
        #Establish the decimal step size
        step = 1.0 / selector[1]
        
        #Temporary equivalents
        num = selector[0]
        den = selector[1]
        
        #Handling fractions > 1
        if(num > den):
            den *= 2

        #Loop through gates
        while(len(gates) < len(pattern)):
            #Selector is smaller
            if(pattern[len(gates)] == 0):
                left  = RI(num + 1 , den)
                right = RI(left + 1, den + 1)
                
            #Selector is in between
            elif(pattern[len(gates)] == 1):
                left  = RI(0,       num - 1)
                right = RI(num + 1, den + 1)
                
            #Selector is larger
            elif(pattern[len(gates)] == 2):
                #Impossible case
                if(num == 1):
                    return None
                left  = RC(range(num / 2))
                right = RI(num / 2, num - 1)
            
            #Convert gates to strings
            left = self.format(left * step)
            right = self.format(right * step)
            
            #Append and continue
            gates.append((str(pattern[len(gates)]), core.strContent(left), core.strContent(right)))
            
        #randomize the order of the gates
        random.shuffle(gates)
        
        return (self.formatSelector(selector), gates)
    def generate(self):
        pattern = [RC([0, 1]), RC([1, 2]), RC([0, 2])]
        gates = []

        #Get the selector
        selector = self.getSelector()
        while (selector[0] == 0):
            selector = self.getSelector()

        #Establish the decimal step size
        step = 1.0 / selector[1]

        #Temporary equivalents
        num = selector[0]
        den = selector[1]

        fract = F(selector[0], selector[1])

        #Loop through gates
        while (len(gates) < len(pattern)):
            attempt = 0
            d = None
            if (self.sameD == 1):
                d = den
            #Selector is smaller
            if (pattern[len(gates)] == 0):
                left = items.FI.getLarger(fract, d)
                if (left != None):
                    right = items.FI.getLarger(F(left[0], left[1]), d)

            #Selector is in between
            elif (pattern[len(gates)] == 1):
                left = items.FI.getSmaller(fract, d)
                if (left != None):
                    right = items.FI.getLarger(fract, d)

            #Selector is larger
            elif (pattern[len(gates)] == 2):
                right = items.FI.getSmaller(fract, d)
                if (right != None):
                    left = items.FI.getSmaller(F(right[0], right[1]), d)

            if (left == None or right == None):
                return None

            #Convert gates to strings
            left = self.formatSelector(left)
            right = self.formatSelector(right)

            #Append and continue
            gates.append((str(pattern[len(gates)]), left, right))

        #randomize the order of the gates
        random.shuffle(gates)

        return (core.strContent(self.format(selector[0] * 1.0 / selector[1])),
                gates)
Example #8
0
 def generate(self):
     subset = []
     
     player = self.validPlayer.get()
     while(player[0] == self.prev[0] and player[1] == self.prev[1]):
         player = self.validPlayer.get()
 
     fCompare = player[0] * 1.0 / player[1]
 
     i = 0
     while(i < 4):
         f = RI(0, 1)
         f1 = 0
         f2 = len(self.valid[f]) - 1
         while(f1 == 0 and f2 == len(self.valid[f]) - 1):
             f1 = RI(0, len(self.valid[f]) - 2)
             f2 = RI(f1 + 1, len(self.valid[f]) - 1)
             
         f1 = self.valid[f][f1]
         f2 = self.valid[f][f2]
         
         if(f1 == fCompare or f2 == fCompare):
             continue
         
         ans = 'u'
         if(fCompare < f1):
             ans = '0'
         elif(fCompare < f2):
             ans = '1'
         else:
             ans = '2'
             
         if(self.prevA == ans and RI(0, 8) > 2):
             continue
             
         subset.append((ans, core.strContent(str(f1)), core.strContent(str(f2))))
         self.prev = player
         self.prevA = ans
     
         i += 1
 
     return (core.frtContent(player[0], player[1]), subset)
Example #9
0
    def generate(self):
        subset = []

        player = RC(self.player)
        while (player == self.prev):
            player = RC(self.player)

        i = 0
        while (i < 4):
            f = RI(0, 1)
            f1 = 0
            f2 = len(self.valid[f]) - 1
            while (f1 == 0 and f2 == len(self.valid[f]) - 1):
                f1 = RI(0, len(self.valid[f]) - 2)
                f2 = RI(f1 + 1, len(self.valid[f]) - 1)

            f1 = self.valid[f][f1]
            f2 = self.valid[f][f2]

            if (f1 == player or f2 == player):
                continue

            ans = 'u'
            if (player < f1):
                ans = '0'
            elif (player < f2):
                ans = '1'
            else:
                ans = '2'

            if (self.prevA == ans and RI(0, 8) > 2):
                continue

            subset.append(
                (ans, core.strContent(str(f1)), core.strContent(str(f2))))
            self.prev = player
            self.prevA = ans

            i += 1

        return (core.strContent(str(player)), subset)
Example #10
0
 def generate(self):
     subset = []
     
     player = RC(self.player)
     while(player == self.prev):
         player = RC(self.player)
 
     i = 0
     while(i < 4):
         f = RI(0, 1)
         f1 = 0
         f2 = len(self.valid[f]) - 1
         while(f1 == 0 and f2 == len(self.valid[f]) - 1):
             f1 = RI(0, len(self.valid[f]) - 2)
             f2 = RI(f1 + 1, len(self.valid[f]) - 1)
             
         f1 = self.valid[f][f1]
         f2 = self.valid[f][f2]
         
         if(f1 == player or f2 == player):
             continue
         
         ans = 'u'
         if(player < f1):
             ans = '0'
         elif(player < f2):
             ans = '1'
         else:
             ans = '2'
             
         if(self.prevA == ans and RI(0, 8) > 2):
             continue
             
         subset.append((ans, core.strContent(str(f1)), core.strContent(str(f2))))
         self.prev = player
         self.prevA = ans
     
         i += 1
 
     return (core.strContent(str(player)), subset)
Example #11
0
 def generate(self):
     line = (("0", core.strContent(0)), ("0.25", core.strContent(0.25)), ("0.5", core.strContent(0.5)), ("0.75", core.strContent(0.75)), ("1", core.strContent(1)))
     #line = (("0", core.strContent(0)), ("0.5", core.strContent(0.5)), ("1", core.strContent(1)))
         
     questions = []
     prev = (0, 0)
     val = (0, 0)
     
     i = 0
     while(i < 20):
         while(val[0] == prev[0] and val[1] == prev[1]):
             val = self.valid.get();
         
         sVal = str((val[0] * 1.0) / val[1])
         if(len(sVal) > 5):
             sVal = sVal[0:5]
         
         questions.append((sVal, core.frtContent(val[0], val[1])))
         
         i += 1
         val = prev
     
     return [line, questions]
 def strSelector(self, s):
     return core.strContent(self.selector_prepend + str(s * self.selector_multiplier) + self.selector_append)
 def strSelector(self, s):
     return core.strContent(self.selector_prepend +
                            str(s * self.selector_multiplier) +
                            self.selector_append)