示例#1
0
	def addNew(self):

		self.syncKey = True

		self.answer = maths.weightedRandomIndex([0.5, 0.5]) # 0.5 for 0 i.e wrong answer
		leftid = maths.randint(0,3)
		leftnameid = maths.randint(0,3)

		if self.answer == 0:
			rightid_pdf = popList(leftid, 0.2) + [0.4] + popList(3-leftid, 0.2) # 0.4 chance left color = right color
			rightid = leftnameid
			while rightid == leftnameid:
				rightid = maths.weightedRandomIndex(rightid_pdf)
			rightnameid = maths.randint(0,3)
		else:
			rightid = leftnameid
			rightnameid_pdf = popList(leftid, 0.2) + [0.4] + popList(3-leftid, 0.2)
			rightnameid = maths.weightedRandomIndex(rightnameid_pdf)

		self.rightBtn.label.text = self.colornames[rightnameid]
		self.rightBtn.label.color = self.colors[rightid] + [255]
		self.leftBtn.label.text = self.colornames[leftnameid]
		self.leftBtn.label.color = self.colors[leftid] + [255]

		self.syncKey = False
示例#2
0
	def addNew(self):

		self.syncKey = True

		self.answer = maths.weightedRandomIndex([0.5, 0.5])

		if self.answer == 1:
			col = self.previous
			shape = self.previous_shape
			while shape == self.previous_shape:
				shape = maths.randint(0, 3)
		else:
			col = self.previous
			while col == self.previous:
				col = maths.randint(0, 3)
			shape = maths.randint(0, 3)

		cshape = self.shapes[shape]

		self.previous = col
		self.previous_shape = shape
		self.curshape.delete()

		if cshape == 'square':
			self.curshape = draw.square(self.width//2 - 75, 300, 150, color=self.colors[col])
		elif cshape == 'hexagon':
			self.curshape = draw.hexagon(self.width//2 - 75, 300, 75, color=self.colors[col])
		elif cshape == 'triangle':
			self.curshape = draw.triangle(self.width//2 - 75, 300, 150, color=self.colors[col])
		else:
			self.curshape = draw.circle(self.width//2 - 75, 300, 75, color=self.colors[col])
		self.curshape.draw()

		self.syncKey = False
示例#3
0
    def addNew(self):

        self.syncKey = True

        self.answer = maths.weightedRandomIndex([0.5, 0.5])

        if self.answer == 1:
            col = self.previous
            shape = self.previous_shape
            while shape == self.previous_shape:
                shape = maths.randint(0, 3)
        else:
            col = self.previous
            while col == self.previous:
                col = maths.randint(0, 3)
            shape = maths.randint(0, 3)

        cshape = self.shapes[shape]

        self.previous = col
        self.previous_shape = shape
        self.curshape.delete()

        if cshape == 'square':
            self.curshape = draw.square(self.width // 2 - 75,
                                        300,
                                        150,
                                        color=self.colors[col])
        elif cshape == 'hexagon':
            self.curshape = draw.hexagon(self.width // 2 - 75,
                                         300,
                                         75,
                                         color=self.colors[col])
        elif cshape == 'triangle':
            self.curshape = draw.triangle(self.width // 2 - 75,
                                          300,
                                          150,
                                          color=self.colors[col])
        else:
            self.curshape = draw.circle(self.width // 2 - 75,
                                        300,
                                        75,
                                        color=self.colors[col])
        self.curshape.draw()

        self.syncKey = False