def __init__(self, text=None, white=False):

        # 1. Set the initial values
        self.loc = (0, 0)
        self.facing = FACE_UP
        self.computer = intcode.IntCode(text=text)

        # 2. If we want to start on a white panel, paint it white
        if white:
            self.hull = hull.Hull(white=self.loc)
        else:
            self.hull = hull.Hull()
Exemple #2
0
    def test_empty_init(self):
        """Test default Hull object creation"""

        # 1. Create default Hull object
        myhull = hull.Hull()

        # 2. Make sure it has the default values
        self.assertEqual(myhull.panels, {})

        # 3. Check methods
        self.assertEqual(myhull.at_least_once(), 0)
        self.assertEqual(myhull.color((7, 11)), panel.COLOR_BLACK)
Exemple #3
0
    def test_painting(self):
        "Test Asteroids object creation with text"

        # 1. Create default Hull object
        myhull = hull.Hull()

        # 2. Do what the robot did part one of the problem
        # 2a. Starts at (0,0), input 0 -> 1, 0
        self.assertEqual(myhull.color((0, 0)), panel.COLOR_BLACK)
        myhull.paint((0, 0), panel.COLOR_WHITE)
        self.assertEqual(myhull.color((0, 0)), panel.COLOR_WHITE)

        # 2b. input 0 -> 0, 0
        self.assertEqual(myhull.color((0, -1)), panel.COLOR_BLACK)
        myhull.paint((0, -1), panel.COLOR_BLACK)
        self.assertEqual(myhull.color((0, -1)), panel.COLOR_BLACK)

        # 2c. input 0 -> 1, 0
        self.assertEqual(myhull.color((-1, -1)), panel.COLOR_BLACK)
        myhull.paint((-1, -1), panel.COLOR_WHITE)
        self.assertEqual(myhull.color((-1, -1)), panel.COLOR_WHITE)

        # 2d. input 0 -> 1, 0
        self.assertEqual(myhull.color((-1, 0)), panel.COLOR_BLACK)
        myhull.paint((-1, 0), panel.COLOR_WHITE)
        self.assertEqual(myhull.color((-1, 0)), panel.COLOR_WHITE)

        # 2e. Back at the start, input 1 -> 0, 1
        self.assertEqual(myhull.color((0, 0)), panel.COLOR_WHITE)
        myhull.paint((0, 0), panel.COLOR_BLACK)
        self.assertEqual(myhull.color((0, 0)), panel.COLOR_BLACK)

        # 2f. input 0 -> 1, 0
        self.assertEqual(myhull.color((0, 1)), panel.COLOR_BLACK)
        myhull.paint((0, 1), panel.COLOR_WHITE)
        self.assertEqual(myhull.color((0, 1)), panel.COLOR_WHITE)

        # 2g. input 0 -> 1, 0
        self.assertEqual(myhull.color((1, 1)), panel.COLOR_BLACK)
        myhull.paint((1, 1), panel.COLOR_WHITE)
        self.assertEqual(myhull.color((1, 1)), panel.COLOR_WHITE)

        # 3. Check the results
        self.assertEqual(myhull.at_least_once(), 6)
Exemple #4
0
def one_two_three():
    strings = ['1', '2', '3']
    persp = perspective.Persp()
    persp.fix_Q(special='cylinder', number=3)
    for font in text.fonts:
        arrays = text.array(strings, font=font)
        imgs = image.images(arrays, labels=strings, justify='vertical')
        h = hull.Hull(imgs, persp)
        h.add_points(10000)
        np.savetxt('examples/123/' + font + '_10000_123.csv',
                   h.X,
                   delimiter=',')
        np.savetxt('examples/123/' + font + '_10000_1.csv',
                   h.Y[0],
                   delimiter=',')
        np.savetxt('examples/123/' + font + '_10000_2.csv',
                   h.Y[1],
                   delimiter=',')
        np.savetxt('examples/123/' + font + '_10000_3.csv',
                   h.Y[2],
                   delimiter=',')
        h.figure(plot=False)
        plt.savefig('examples/123/' + font + '_10000')

        for target in [1000, 500, 200, 100]:
            h.uniformize(target=target)
            target = str(target)
            np.savetxt('examples/123/' + font + '_' + target + '_123.csv',
                       h.X,
                       delimiter=',')
            np.savetxt('examples/123/' + font + '_' + target + '_1.csv',
                       h.Y[0],
                       delimiter=',')
            np.savetxt('examples/123/' + font + '_' + target + '_2.csv',
                       h.Y[1],
                       delimiter=',')
            np.savetxt('examples/123/' + font + '_' + target + '_3.csv',
                       h.Y[2],
                       delimiter=',')
            h.figure(plot=False)
            plt.savefig('examples/123/' + font + '_' + target + '_image')
Exemple #5
0
def xyz():
    strings = ['x', 'y', 'z']
    persp = perspective.Persp()
    persp.fix_Q(special='standard', number=3)
    for font in text.fonts:
        arrays = text.array(strings, font=font)
        imgs = image.images(arrays, labels=strings, justify='vertical')
        h = hull.Hull(imgs, persp)
        h.add_points(10000)
        np.savetxt('examples/xyz/' + font + '_10000_xyz.csv',
                   h.X,
                   delimiter=',')
        h.figure(plot=False)
        plt.savefig('examples/xyz/' + font + '_10000')

        for target in [1000, 500, 200, 100]:
            h.uniformize(target=target)
            target = str(target)
            np.savetxt('examples/xyz/' + font + '_' + target + '_xyz.csv',
                       h.X,
                       delimiter=',')
            h.figure(plot=False)
            plt.savefig('examples/xyz/' + font + '_' + target + '_image')