Example #1
0
    def test_constructors(self):

        """Test space constructors"""

        a = space.space()
        self.assertEqual(a.x, 0)
        self.assertEqual(a.y, 0)
        self.assertEqual(a.z, 0)
        self.assertSpaceAreEqual(a, space.Uo)

        a = space.space(self.x1)
        self.assertEqual(a.x, self.x1)
        self.assertEqual(a.y, 0)
        self.assertEqual(a.z, 0)

        a = space.space(self.x1, self.y1)
        self.assertEqual(a.x, self.x1)
        self.assertEqual(a.y, self.y1)
        self.assertEqual(a.z, 0)

        a = space.space(self.x1, self.y1, self.z1)
        self.assertSpaceAreEqual(self.space1, a)

        a = space.space(z=self.z2, x=self.x2, y=self.y2)
        self.assertSpaceAreEqual(self.space2, a)
Example #2
0
 def test_subtract(self):
     """Test subtract"""
     a = space.space(self.A, self.B, self.C)
     b = space.space(self.A, self.B, self.C)
     c = a - b
     self.assertEqual(c.x, 0)
     self.assertEqual(c.y, 0)
     self.assertEqual(c.z, 0)
Example #3
0
 def test_space_noop_richcompare_space(self):
     """Test space >, >=, <, <= space"""
     a = space.space(1, 2, 3)
     b = space.space(4, 5, 5)
     self.assertRaises(TypeError, lambda a, b: a > b)
     self.assertRaises(TypeError, lambda a, b: a >= b)
     self.assertRaises(TypeError, lambda a, b: a < b)
     self.assertRaises(TypeError, lambda a, b: a <= b)
Example #4
0
 def test_add(self):
     """Test add"""
     a = space.space(self.A, self.B, self.C)
     b = space.space(-self.A, -self.B, -self.C)
     c = a + b
     self.assertEqual(0, c.x)
     self.assertEqual(0, c.y)
     self.assertEqual(0, c.z)
Example #5
0
    def test_copy_constructor(self):
        """Test space copy constructor"""

        a = space.space(self.A, self.B, self.C)
        b = space.space(a)
        self.assertEqual(self.A, b.x)
        self.assertEqual(self.B, b.y)
        self.assertEqual(self.C, b.z)
Example #6
0
 def createSpaces(self):
     for x in range(8):
         List = []
         for y in range(8):
             List.append(space(y,x))
         self.spaces.append(List)
     self.spaces.reverse()
Example #7
0
 def test_xyz_assignments(self):
     """Test space xyz assignment operators"""
     a = space.space()
     a.x = self.p1.x
     a.y = self.p1.y
     a.z = self.p1.z
     self.assertSpacesAreEqual(self.p1, a)
Example #8
0
def create_map(height, width):
    map = []
    for row in range(height):
        map.append([])
        for col in range(width):
            map[row].append(space(' '))
    return map
Example #9
0
 def test_copy_assign_2(self):
     """Test copy assignment operator is shallow"""
     a = space.space(1,2,3)
     b = a
     b.x = 4.0
     self.assertSpacesAreEqual(a, b)
     self.assertEqual(4, b.x)
Example #10
0
 def test_space_minus_space(self):
     """Test space - space"""
     result = space.space(self.p1.x - self.p2.x,
                          self.p1.y - self.p2.y,
                          self.p1.z - self.p2.z)
     a = self.p1 - self.p2
     self.assertTrue(result == a)
Example #11
0
 def test_copy_assign_2(self):
     """Test copy assignment operator is shallow"""
     a = space.space(1,2,3)
     b = a
     b.x(4.0)
     self.assertTrue(a == b)
     self.assertEqual(4, b.x())
Example #12
0
 def test_space_minus_space(self):
     """Test space - space"""
     result = space.space(self.p1.x() - self.p2.x(),
                          self.p1.y() - self.p2.y(),
                          self.p1.z() - self.p2.z())
     a = self.p1 - self.p2
     self.assertTrue(result == a)
Example #13
0
 def test_xyz_assignments(self):
     """Test space xyz assignment operators"""
     a = space.space()
     a.x(self.p1.x())
     a.y(self.p1.y())
     a.z(self.p1.z())
     self.assertTrue(self.p1 == a)
Example #14
0
 def test_space_plus_space(self):
     """Test space + space"""
     result = space.space(self.p1.x() + self.p2.x(),
                          self.p1.y() + self.p2.y(),
                          self.p1.z() + self.p2.z())
     a = self.p1 + self.p2
     self.assertTrue(result == a)
Example #15
0
 def test_default_constructor(self):
     """Test default constructor"""
     a = space.space()
     self.assertEqual(0, a.x)
     self.assertEqual(0, a.y)
     self.assertEqual(0, a.z)
     self.assertSpacesAreEqual(space.space.Uo, a)
Example #16
0
 def test_default_constructor(self):
     """Test default constructor"""
     a = space.space()
     self.assertEqual(0, a.x)
     self.assertEqual(0, a.y)
     self.assertEqual(0, a.z)
     self.assertTrue(space.Uo == a)
Example #17
0
 def test_space_eq_space(self):
     """Test space == space"""
     result = space.space(self.p1.x + self.p2.x,
                          self.p1.y + self.p2.y,
                          self.p1.z + self.p2.z)
     a = self.p1 + self.p2
     self.assertTrue(result == a)
Example #18
0
    def test_prints(self):
        """Test space print and repr"""

        a = space.space(self.x2, self.y2, self.z2)

        self.assertEqual(self.two_as_str, str(a))
        self.assertEqual(self.two_as_repr, repr(a))
Example #19
0
 def test_space_plus_space(self):
     """Test space + space"""
     result = space.space(self.p1.x + self.p2.x,
                          self.p1.y + self.p2.y,
                          self.p1.z + self.p2.z)
     a = self.p1 + self.p2
     self.assertSpacesAreEqual(result, a)
Example #20
0
 def test_space_minus_space(self):
     """Test space - space"""
     result = space.space(self.p1.x - self.p2.x,
                          self.p1.y - self.p2.y,
                          self.p1.z - self.p2.z)
     a = self.p1 - self.p2
     self.assertSpacesAreEqual(result, a)
Example #21
0
 def test_unitary_minus(self):
     """Test space = -space"""
     result = space.space(-self.p1.x,
                          -self.p1.y,
                          -self.p1.z)
     a = -self.p1
     self.assertTrue(result == a)
Example #22
0
 def test_divide(self):
     """Test divide (scale)"""
     result = space.space(self.p1.x / 2.0,
                          self.p1.y / 2.0,
                          self.p1.z / 2.0)
     a = self.p1 / 2.0
     self.assertSpacesAreEqual(result, a)
Example #23
0
 def test_divide(self):
     """Test divide (scale)"""
     result = space.space(self.p1.x / 2.0,
                          self.p1.y / 2.0,
                          self.p1.z / 2.0)
     a = self.p1 / 2.0
     self.assertTrue(result == a)
Example #24
0
 def test_xyz_assignments(self):
     """Test space xyz assignment operators"""
     a = space.space()
     a.x = self.p1.x
     a.y = self.p1.y
     a.z = self.p1.z
     self.assertTrue(self.p1 == a)
Example #25
0
 def test_inplace_add(self):
     """Test space +="""
     result = space.space(self.p1.x() + self.p2.x(),
                          self.p1.y() + self.p2.y(),
                          self.p1.z() + self.p2.z())
     a = self.p1
     a += self.p2
     self.assertTrue(result == a)
Example #26
0
    def test_copy_assign(self):
        """Test space copy assign"""

        a = space.space(self.A, self.B, self.C)
        b = a
        self.assertEqual(self.A, b.x)
        self.assertEqual(self.B, b.y)
        self.assertEqual(self.C, b.z)
Example #27
0
    def test_inplace_subtract(self):
        """Test inplace subtract"""
        a = space.space(self.A, self.B, self.C)
        a -= a

        self.assertEqual(0, a.x)
        self.assertEqual(0, a.y)
        self.assertEqual(0, a.z)
Example #28
0
    def test_inplace_divide(self):
        """Test inplace divide, a.k.a. scale"""
        a = space.space(self.A, self.B, self.C)
        a /= 10

        self.assertEqual(self.A/10, a.x)
        self.assertEqual(self.B/10, a.y)
        self.assertEqual(self.C/10, a.z)
Example #29
0
    def test_inplace_multiply(self):
        """Test inplace multiply

        This is weird because a becomes a float since this is a dot product.
        """
        a = space.space(self.A, self.B, self.C)
        a *= a
        self.assertAlmostEqual(self.product, a, self.places)
Example #30
0
 def test_inplace_add(self):
     """Test space +="""
     result = space.space(self.p1.x + self.p2.x,
                          self.p1.y + self.p2.y,
                          self.p1.z + self.p2.z)
     a = self.p1
     a += self.p2
     self.assertSpacesAreEqual(result, a)
Example #31
0
 def test_copy_assign_3(self):
     """Test copy assignment operator can use deep copy"""
     import copy
     a = space.space(1,2,3)
     b = copy.deepcopy(a)
     b.x = 4.0
     self.assertEqual(1, a.x)
     self.assertEqual(4, b.x)
Example #32
0
 def test_inplace_subtract(self):
     """Test space -="""
     result = space.space(self.p1.x - self.p2.x,
                          self.p1.y - self.p2.y,
                          self.p1.z - self.p2.z)
     a = self.p1
     a -= self.p2
     self.assertSpacesAreEqual(result, a)
Example #33
0
 def test_inplace_subtract(self):
     """Test space -="""
     result = space.space(self.p1.x - self.p2.x,
                          self.p1.y - self.p2.y,
                          self.p1.z - self.p2.z)
     a = self.p1
     a -= self.p2
     self.assertTrue(result == a)
Example #34
0
 def test_inplace_add(self):
     """Test space +="""
     result = space.space(self.p1.x + self.p2.x,
                          self.p1.y + self.p2.y,
                          self.p1.z + self.p2.z)
     a = self.p1
     a += self.p2
     self.assertTrue(result == a)
Example #35
0
    def test_divide(self):
        """Test divide, a.k.a. scale"""
        a = space.space(self.A, self.B, self.C)
        b = a / 10

        self.assertEqual(self.A/10, b.x)
        self.assertEqual(self.B/10, b.y)
        self.assertEqual(self.C/10, b.z)
Example #36
0
    def test_inplace_add(self):
        """Test inplace add"""
        a = space.space(self.A, self.B, self.C)
        a += a

        self.assertEqual(2*self.A, a.x)
        self.assertEqual(2*self.B, a.y)
        self.assertEqual(2*self.C, a.z)
Example #37
0
    def test_assignments(self):
        """Test space assignment operators"""

        a = space.space()

        a.x = self.x1
        a.y = self.y1
        a.z = self.z1

        self.assertSpaceAreEqual(self.space1, a)
Example #38
0
    def test_accessors(self):
        """Test space accessors"""

        a = space.space()
        a.setX(self.A)
        a.setY(-self.B)
        a.setZ(self.C)

        self.assertEqual(self.A, a.getX())
        self.assertEqual(-self.B, a.getY())
        self.assertEqual(self.C, a.getZ())
Example #39
0
    def test_properties(self):
        """Test properties"""

        a = space.space()
        a.x = self.A
        a.y = -self.B
        a.z = self.C

        self.assertEqual(self.A, a.x)
        self.assertEqual(-self.B, a.y)
        self.assertEqual(self.C, a.z)
Example #40
0
    def test_cross_product(self):
        """Test space cross product"""

        # simple axis rotation.
        a = space.cross(space.Ux, space.Uy)
        self.assertSpaceAreEqual(a, space.Uz)

        a = space.cross(space.Uy, space.Uz)
        self.assertSpaceAreEqual(a, space.Ux)

        a = space.cross(space.Uz, space.Ux)
        self.assertSpaceAreEqual(a, space.Uy)

        # more complex
        a = space.space(1, 1, 1)
        b = space.space(0, 0, 0.5)

        c = space.cross(a, b)

        self.assertSpaceAreEqual(space.space(0.5, -0.5, 0), c)
Example #41
0
File: Blok.py Project: 123byl/test
 def partition(self,S):
     # According to Figure a in the article
     # Front space 
     self.pos=[S.pos[0],S.pos[4]-self.W,S.pos[2]]
     fl2=S.pos[0]+self.L
     fw2=S.pos[4]-self.W
     Front_space=space(S.pos[0],S.pos[1],S.pos[2],fl2,fw2,S.pos[5])
     # Upper sapce 
     ul2=self.L+S.pos[0]
     uw1=S.pos[4]-self.W
     uh1=self.H+S.pos[2]
     Upper_space=space(S.pos[0],uw1,uh1,ul2,S.pos[4],S.pos[5])
     Upper_space.lowerBox_type=[self.boxtype]
     # Right space 
     rl1=S.pos[0]+self.L
     Right_space=space(rl1,S.pos[1],S.pos[2],S.pos[3],S.pos[4],S.pos[5])
     # delete the initial space
     S.delet()
     Blok.AllBloks.append(self) 
     return 
Example #42
0
 def __init__(self, height, width, players):
     self.height = height
     self.width = width
     self.map = create_map(height, width)
     self.rebels = []
     self.players = players
     self.bullets = []
     for i in range(players):
         self.rebels.append(dude(self, 1, i * 5, 10))
     for i in range(self.width):
         self.map[self.height - 3][i] = space('-', full=True)
Example #43
0
    def test_default_constructors(self):
        """Test space default constructors"""

        a = space.space()
        self.assertEqual(0, a.x)
        self.assertEqual(0, a.y)
        self.assertEqual(0, a.z)

        a = space.space(self.A)
        self.assertEqual(self.A, a.x)
        self.assertEqual(0, a.y)
        self.assertEqual(0, a.z)

        a = space.space(self.A, self.B)
        self.assertEqual(self.A, a.x)
        self.assertEqual(self.B, a.y)
        self.assertEqual(0, a.z)

        a = space.space(self.A, self.B, self.C)
        self.assertEqual(self.A, a.x)
        self.assertEqual(self.B, a.y)
        self.assertEqual(self.C, a.z)
Example #44
0
    def setUp(self):

        self.places = 7 # almost equal places

        self.zero = space.space()
        self.A = 1.1
        self.B = 2.2
        self.C = 3.3

        self.product = self.A*self.A + self.B*self.B + self.C*self.C
        self.magnitude = math.sqrt(self.product)

        self.a_str = '<space><x>1.1</x><y>2.2</y><z>3.3</z></space>'
Example #45
0
    def setUp(self):

        """Set up test parameters."""

        self.places = 7 # almost equal places

        # various types to check math operators
        self.most_exception_types = (
            'foo', 0, 1, -2, 3.1415, -2.7, complex(1.2, -3.4))

        self.divisor_exception_types = ('foo', complex(1.2, -3.4))

        # one point
        self.x1 = 1
        self.y1 = 2
        self.z1 = 3

        self.space1 = space.space(self.x1, self.y1, self.z1)

        self.space1_mag = math.sqrt(self.x1*self.x1 + self.y1*self.y1 + self.z1*self.z1)
        self.normal1 = space.space(self.x1/self.space1_mag,
                                   self.y1/self.space1_mag,
                                   self.z1/self.space1_mag)


        # hardcoded strings keep this from being too circular.
        self.one_as_str = '<space><x>1</x><y>2</y><z>3</z></space>'
        self.one_as_repr = '(1, 2, 3)'

        # another point
        self.x2 = 0.123456789
        self.y2 = -2.71828
        self.z2 = 3.14159

        self.space2 = space.space(self.x2, self.y2, self.z2)

        # Note: space print precision (default) is less than in Body.
        self.two_as_str = '<space><x>0.123457</x><y>-2.71828</y><z>3.14159</z></space>'
        self.two_as_repr = '(0.123457, -2.71828, 3.14159)'

        # sum
        self.sum_space1_space2 = space.space(self.x1 + self.x2,
                                             self.y1 + self.y2,
                                             self.z1 + self.z2)

        # difference
        self.diff_space1_space2 = space.space(self.x1 - self.x2,
                                              self.y1 - self.y2,
                                              self.z1 - self.z2)

        # dot product
        self.dot_prod_space1_space2 = \
            self.x1 * self.x2 + \
            self.y1 * self.y2 + \
            self.z1 * self.z2

        self.quotient_space1_over_2 = space.space(self.x1 / 2.0,
                                                  self.y1 / 2.0,
                                                  self.z1 / 2.0)
Example #46
0
    def test_exceptions(self):
        """Test space exceptions"""

        a_space = space.space()

        self.assertRaises(TypeError, a_space.x, 'foo')
        self.assertRaises(TypeError, a_space.y, 'foo')
        self.assertRaises(TypeError, a_space.z, 'foo')

        # assert exceptions on operators of different types.

        if False:
            # FN
            self.assertRaises(TypeError, lambda a, b: a + b,
                              self.space1, self.space2)

        for type_ in self.most_exception_types:
            self.assertRaises(TypeError, lambda a, b: a + b, a_space, type_)
            self.assertRaises(TypeError, lambda a, b: b + a, a_space, type_)
        # TODO +=

        for type_ in self.most_exception_types:
            self.assertRaises(TypeError, lambda a, b: a - b, a_space, type_)
            self.assertRaises(TypeError, lambda a, b: b - a, a_space, type_)
        # TODO -=

        for type_ in self.most_exception_types:
            self.assertRaises(TypeError, lambda a, b: a * b, a_space, type_)
            self.assertRaises(TypeError, lambda a, b: b * a, a_space, type_)
       # TODO *=

        for type_ in self.divisor_exception_types:
            self.assertRaises(TypeError, lambda a, b: a / b, a_space, type_)
            self.assertRaises(TypeError, lambda a, b: b / a, a_space, type_)
        # TODO /=

        # divide by 0
        self.assertRaises(space.space_error, lambda a, b: a / b, a_space, 0)
Example #47
0
    def loading(self, Data):
        #### loading hurestic ###
        space.reset()
        BOX.reset()
        Blok.reset()
        (L, W, H) = Data.contdim
        S = space(0, 0, 0, L, W, H)
        BOXS = []
        for j in self.value:
            BOXS.append(BOX(Data, j))

        while len(space.remainlist) != 0 or BOX.Is_unloaded_BOX():
            S = S.merge()
            j = 0
            while (j < Data.ntype and len(space.remainlist) != 0):
                currentbox = BOXS[j]

                if (currentbox.quantity > 0 and currentbox.Can_Load(Data, S)):
                    BBlok = currentbox.Best_Blok(S)
                    BBlok.partition(S)
                    if len(space.remainlist) != 0:
                        S = space.curentspace()
                        j = 0
                    else:
                        break

                    S = S.merge()
                    #j+=1
                else:
                    j += 1

            S.waste()
            if len(space.remainlist) != 0:
                S = space.curentspace()
            else:
                break
Example #48
0
    def test_magnitude(self):
        """Test magnitude"""
        a = space.space(self.A, self.B, self.C)

        self.assertAlmostEqual(self.magnitude, a.magnitude(), self.places)
Example #49
0
 def DISABLED_test_divide_zero(self):
     """Test divide by zero to raise exception"""
     a = space.space(self.A, self.B, self.C)
     self.assertRaises(RuntimeError, a / 0)
Example #50
0
 def test_normalized(self):
     """Test normalized"""
     a = space.space(self.A, self.B, self.C)
     b = a.normalized()
     self.assertAlmostEqual(1.0, b.magnitude())
Example #51
0
 def test_str(self):
     """Test string representation."""
     a = space.space(self.A, self.B, self.C)
     self.assertEqual(self.a_str, str(a))
Example #52
0
 def remove_dude (self):
     for row in range(self.y,self.y + self.height):
         for col in range(self.x, self.x + self.width):
             self.game.map[row][col] = space(' ')
Example #53
0
pygame.init()
size = width, height = 1920, 1020
screen = pygame.display.set_mode(size)
icon = pygame.image.load("./hatLogo.ico")
pygame.display.set_icon(icon)
pygame.display.set_caption("Generic Property Game-opoly")

#input()
#reads in content from csv
boardArray = []
with open(root.filename, newline='') as boardFile:
    boardReader = csv.reader(boardFile, delimiter=',')
    for i in boardReader:
        #print(i)
        boardArray.append(
            space.space(i[0], i[1], int(i[3]), int(i[4]), 90, colourDict[i[2]],
                        i))
        #print(boardArray)

chanceArray = []
with open("CHANCE.csv", newline='') as chanceFile:
    chanceReader = csv.reader(chanceFile, delimiter=",")
    for i in chanceReader:
        chanceArray.append(space.chance(i))
        #print(chanceArray)

random.shuffle(chanceArray)

background = pygame.image.load("background2.png")

diceArray = [space.dice(0), space.dice(1)]
mainMenuArray = resetMenu()
Example #54
0
 def test_multiply(self):
     """Test multiply, a.k.a. dot product"""
     a = space.space(self.A, self.B, self.C)
     b = space.space(self.A, self.B, self.C)
     c = a * b
     self.assertAlmostEqual(self.product, c, self.places)