Ejemplo n.º 1
0
 def __init_enemy_bot(self):
     if self.__big_enemy_bot is not None:
         self.__big_enemy_poly = Poly().initFromCircle(
             (-1000, -1000), self.__big_enemy_bot["getRayon"] +
             self.__our_bot["getRayon"] + MARGE_PASSAGE_PATH,
             POINTS_PAR_CERCLE)
         self.__ng.add_dynamic_obstacle(self.__big_enemy_poly)
     if self.__small_enemy_bot is not None:
         self.__small_enemy_poly = Poly().initFromCircle(
             (-1000, -1000), self.__small_enemy_bot["getRayon"] +
             self.__our_bot["getRayon"] + MARGE_PASSAGE_PATH,
             POINTS_PAR_CERCLE)
         self.__ng.add_dynamic_obstacle(self.__small_enemy_poly)
     self.__update_enemy_bot()
Ejemplo n.º 2
0
 def __init_allied_bot(self):
     if self.__our_bot_count == 2:
         self.__other_bot_poly = Poly().initFromCircle(
             self.__other_bot["getPosition"], self.__other_bot["getRayon"] +
             self.__our_bot["getRayon"] + MARGE_PASSAGE_PATH,
             POINTS_PAR_CERCLE)
         self.__ng.add_dynamic_obstacle(self.__other_bot_poly)
Ejemplo n.º 3
0
def xml_to_circle(xml_circle):
    x, y, r, n = int(xml_circle.getAttribute("x")), int(
        xml_circle.getAttribute("y")), int(
            xml_circle.getAttribute("rayon")), int(
                xml_circle.getAttribute("n"))
    poly = Poly().initFromCircle((x, y), r, n)
    return poly
Ejemplo n.º 4
0
 def draw(self):
     '''Draw the funnel.'''
     return Poly(prev_position=self.prev_position,
                 prev_depth=self.prev_depth,
                 prev_output_dim=self.prev_output_dim,
                 curr_position=self.curr_position,
                 curr_depth=self.curr_depth,
                 curr_output_dim=self.curr_output_dim,
                 color=self.color).draw()
Ejemplo n.º 5
0



import
	>>> from geometry import Poly


init
	>>> poly = Poly(((0,0),(4,0),(2,2)))

aabb
	>>> poly.AABB.p == (0,0)
	True
	>>> poly.AABB.w
	4
	>>> poly.AABB.h
	2

adjacent
	>>> poly1 = Poly(((0,0),(4,0),(2,2)))
	>>> poly2 = Poly(((0,0),(2,-2),(4,0)))
	>>> poly1.adjacent(poly2)
	True
	>>> poly3 = Poly(((0,1),(4,1),(2,2)))
	>>> poly1.adjacent(poly3)
	False


move
	>>> poly = Poly(((0,0),(4,0),(2,2)))
Ejemplo n.º 6
0
def xml_to_carre(xml_carre):
    x, y, w = int(xml_carre.getAttribute("x")), int(
        xml_carre.getAttribute("y")), int(xml_carre.getAttribute("width"))
    poly = Poly().initFromCarre((x, y), w, True)
    return poly
Ejemplo n.º 7
0
def xml_to_polygon(xml_poly):
    poly = Poly(((int(vertex.getAttribute("x")), int(vertex.getAttribute("y")))
                 for vertex in xml_poly.getElementsByTagName("vertex")))
    return poly
Ejemplo n.º 8
0
	def test_move_to(self):
		poly = Poly(((0,0),(4,0),(4,4),(0,4)))
		_ = poly.move_to((0,0)).round()
		self.assertEqual(poly.points, [(-2, -2), (2, -2), (2, 2), (-2, 2)])
Ejemplo n.º 9
0
	def test_move(self):
		poly = Poly(((0,0),(4,0),(2,2)))
		_ = poly.move((2,2)).round()
		self.assertEqual(poly.points, [(2,2), (6,2), (4,4)])
Ejemplo n.º 10
0
	def test_adjacent2(self):
		poly1 = Poly(((0,0),(4,0),(2,2)))
		poly2 = Poly(((0,1),(4,1),(2,2)))
		self.assertFalse(poly1.adjacent(poly2))
Ejemplo n.º 11
0
	def test_adjacent1(self):
		poly1 = Poly(((0,0),(4,0),(2,2)))
		poly2 = Poly(((0,0),(2,-2),(4,0)))
		self.assertTrue(poly1.adjacent(poly2))