Exemplo n.º 1
0
 def __init__(self):
     shape1, shape2 = sg.sample_shape(2)
     objs1 = tg.Select(shape=shape1, when='now')
     objs2 = tg.Select(shape=shape2, when=sg.random_when())
     self._operator = tg.Switch(tg.Exist(objs1),
                                tg.Go(objs1),
                                tg.Go(objs2),
                                both_options_avail=False)
Exemplo n.º 2
0
 def __init__(self):
     color1, color2 = sg.sample_color(2)
     objs1 = tg.Select(color=color1, when='now')
     objs2 = tg.Select(color=color2, when=sg.random_when())
     self._operator = tg.Switch(tg.Exist(objs1),
                                tg.Go(objs1),
                                tg.Go(objs2),
                                both_options_avail=False)
Exemplo n.º 3
0
    def __init__(self):
        attr1, attr2 = sg.sample_colorshape(2)
        when2 = sg.random_when()

        objs1 = tg.Select(color=attr1[0], shape=attr1[1], when='now')
        objs2 = tg.Select(color=attr2[0], shape=attr2[1], when=when2)
        self._operator = tg.Switch(tg.Exist(objs1),
                                   tg.Go(objs1),
                                   tg.Go(objs2),
                                   both_options_avail=False)
Exemplo n.º 4
0
    def __init__(self):
        attr1, attr2, attr3 = sg.sample_colorshape(3)

        objs1 = tg.Select(color=attr1[0], shape=attr1[1], when='now')
        objs2 = tg.Select(color=attr2[0], shape=attr2[1], when='now')
        objs3 = tg.Select(color=attr3[0],
                          shape=attr3[1],
                          when=sg.random_when())
        bool1 = tg.And(tg.Exist(objs1), tg.Exist(objs2))
        self._operator = tg.Switch(bool1,
                                   tg.Go(objs1),
                                   tg.Go(objs3),
                                   both_options_avail=False)
Exemplo n.º 5
0
    def __init__(self):
        color1, color2, color3, color4 = sg.sample_color(4)
        objs1 = tg.Select(color=color1, when=sg.random_when())
        loc = tg.GetLoc(objs1)
        objs2 = tg.Select(loc=loc,
                          color=color2,
                          when='now',
                          space_type=sg.random_space())
        bool1 = tg.Exist(objs2)

        objs3 = tg.Select(color=color3)
        objs4 = tg.Select(color=color4)
        go1 = tg.Go(objs3)
        go2 = tg.Go(objs4)
        self._operator = tg.Switch(bool1, go1, go2, both_options_avail=True)
Exemplo n.º 6
0
    def __init__(self):
        shape1, shape2, shape3, shape4 = sg.sample_shape(4)
        objs1 = tg.Select(shape=shape1, when=sg.random_when())
        loc = tg.GetLoc(objs1)
        objs2 = tg.Select(loc=loc,
                          shape=shape2,
                          when='now',
                          space_type=sg.random_space())
        bool1 = tg.Exist(objs2)

        objs3 = tg.Select(shape=shape3)
        objs4 = tg.Select(shape=shape4)
        go1 = tg.Go(objs3)
        go2 = tg.Go(objs4)
        self._operator = tg.Switch(bool1, go1, go2, both_options_avail=True)
Exemplo n.º 7
0
    def testIsFinal(self):
        objs1 = tg.Select(color=sg.Color('red'),
                          shape=sg.Shape('square'),
                          when='now')
        objs2 = tg.Select(color=sg.Color('blue'),
                          shape=sg.Shape('square'),
                          when='now')
        objs3 = tg.Select(shape=sg.Shape('circle'), when='last1')
        bool1 = tg.Exist(objs1)
        go1 = tg.Go(objs2)
        go2 = tg.Go(objs3)
        op = tg.Switch(bool1, go1, go2, both_options_avail=False)

        self.assertFalse(op.parent)
        self.assertTrue(bool1.parent)
        self.assertTrue(go1.parent)
Exemplo n.º 8
0
 def __init__(self):
     color1, color2, color3 = sg.sample_color(3)
     objs1 = tg.Select(color=color1, when='latest')
     shape1 = tg.GetShape(objs1)
     objs2 = tg.Select(color=color2, shape=shape1, when='now')
     self._operator = tg.Go(objs2)
     self._color1, self._color2, self._color3 = color1, color2, color3
Exemplo n.º 9
0
    def __init__(self):
        color1, color2, color3 = sg.sample_color(3)
        shape3, shape4 = sg.sample_shape(2)
        when1 = sg.random_when()
        when2 = sg.random_when()

        objs1 = tg.Select(color=color1, when=when1)
        objs2 = tg.Select(color=color2, when=when2)
        s1 = tg.GetShape(objs1)
        s2 = tg.GetShape(objs2)
        bool1 = tg.IsSame(s1, s2)
        objs3 = tg.Select(color=color3, shape=shape3)
        objs4 = tg.Select(color=color3, shape=shape4)
        go1 = tg.Go(objs3)
        go2 = tg.Go(objs4)
        self._operator = tg.Switch(bool1, go1, go2, both_options_avail=True)
Exemplo n.º 10
0
    def __init__(self):
        shape1, shape2, shape3 = sg.sample_shape(3)
        color1, color2 = sg.sample_color(2)
        when1 = sg.random_when()
        when2 = sg.random_when()

        objs1 = tg.Select(shape=shape1, when=when1)
        objs2 = tg.Select(shape=shape2, when=when2)
        a1 = tg.GetColor(objs1)
        a2 = tg.GetColor(objs2)
        bool1 = tg.IsSame(a1, a2)

        objs3 = tg.Select(color=color1, shape=shape3)
        objs4 = tg.Select(color=color2, shape=shape3)
        go1 = tg.Go(objs3)
        go2 = tg.Go(objs4)
        self._operator = tg.Switch(bool1, go1, go2, both_options_avail=True)
Exemplo n.º 11
0
    def __init__(self):
        shape1, shape2, shape3 = sg.sample_shape(3)
        objs1 = tg.Select(shape=shape1, when='latest')
        color1 = tg.GetColor(objs1)
        objs2 = tg.Select(color=color1, shape=shape2, when='now')
        self._operator = tg.Go(objs2)

        self._shape1, self._shape2, self._shape3 = shape1, shape2, shape3
Exemplo n.º 12
0
    def __init__(self):
        attr1, attr2, attr3, attr4 = sg.sample_colorshape(4)
        objs1 = tg.Select(color=attr1[0],
                          shape=attr1[1],
                          when=sg.random_when())
        loc = tg.GetLoc(objs1)
        objs2 = tg.Select(loc=loc,
                          color=attr2[0],
                          shape=attr2[1],
                          when='now',
                          space_type=sg.random_space())
        bool1 = tg.Exist(objs2)

        objs3 = tg.Select(color=attr3[0], shape=attr3[1])
        objs4 = tg.Select(color=attr4[0], shape=attr4[1])
        go1 = tg.Go(objs3)
        go2 = tg.Go(objs4)
        self._operator = tg.Switch(bool1, go1, go2, both_options_avail=True)
Exemplo n.º 13
0
    def __init__(self):
        color1, color2 = sg.sample_color(2)
        when1 = sg.random_when()
        a2 = sg.random_shape()
        shape1, shape2 = sg.sample_shape(2)

        objs1 = tg.Select(color=color1, when=when1)
        a1 = tg.GetShape(objs1)

        if random.random() > 0.5:
            bool1 = tg.IsSame(a1, a2)
        else:
            bool1 = tg.IsSame(a2, a1)

        objs2 = tg.Select(color=color2, shape=shape1)
        objs3 = tg.Select(color=color2, shape=shape2)
        go1 = tg.Go(objs2)
        go2 = tg.Go(objs3)
        self._operator = tg.Switch(bool1, go1, go2, both_options_avail=True)
Exemplo n.º 14
0
 def testGoGuessObjset(self):
     objset = sg.ObjectSet(n_epoch=10)
     objs1 = tg.Select(shape=sg.Shape('square'), when='now')
     task = tg.Task(tg.Go(objs1))
     epoch_now = 1
     objset = task.guess_objset(objset, epoch_now)
     l1 = len(objset.select(epoch_now, shape=sg.Shape('square'),
                            when='now'))
     l2 = len(objset.select(epoch_now, shape=sg.Shape('circle'),
                            when='now'))
     self.assertEqual(1, l1)
     self.assertEqual(0, l2)
Exemplo n.º 15
0
 def __init__(self):
     shape1 = sg.random_shape()
     when1 = sg.random_when()
     objs1 = tg.Select(shape=shape1, when=when1)
     self._operator = tg.Go(objs1)
Exemplo n.º 16
0
    def testCompareChild(self):
        objs1 = tg.Select(color=sg.Color('red'), when='now')
        bool1 = tg.Exist(objs1)
        go1 = tg.Go(objs1)

        self.assertEqual(bool1.child[0], go1.child[0])
Exemplo n.º 17
0
 def __init__(self):
     color1 = sg.random_color()
     shape1 = sg.random_shape()
     when1 = sg.random_when()
     objs1 = tg.Select(color=color1, shape=shape1, when=when1)
     self._operator = tg.Go(objs1)