Browse Source

begin gtriangle tests

olinox 9 years ago
parent
commit
ddbaad43ea

+ 1 - 0
README.md

@@ -3,3 +3,4 @@
 [GNU License](https://github.com/olinox14/pypog/blob/master/LICENSE.txt) 
 
 [![Build Status](https://travis-ci.org/olinox14/pypog.svg?branch=master)](https://travis-ci.org/olinox14/pypog) [![Coverage Status](https://coveralls.io/repos/github/olinox14/pypog/badge.svg?branch=master)](https://coveralls.io/github/olinox14/pypog?branch=master)
+

+ 3 - 3
core/Cell.py

@@ -3,7 +3,7 @@ Created on 8 nov. 2016
     Cell of a board game
 @author: olinox
 '''
-from core import constants
+from core import geometry
 
 
 class Cell(object):
@@ -47,12 +47,12 @@ class Cell(object):
     def __update_neighbours(self):
         """update the tuple of neighbours cells"""
         x, y = self._x, self._y
-        if self._geometry == constants.HEX:
+        if self._geometry == geometry.HEX:
             if 1 == (x % 2):
                 self._neighbours = ( (x, y-1), (x+1, y), (x+1, y+1), (x,  y+1), (x-1, y+1), (x-1, y) )
             else:
                 self._neighbours = ( (x, y-1), (x+1, y-1), (x+1, y), (x,  y+1), (x-1, y), (x-1, y-1) )
-        elif self._geometry == constants.SQUARE:
+        elif self._geometry == geometry.SQUARE:
             self._neighbours = ( (x-1, y-1), (x, y-1), (x+1, y-1), \
                                 (x-1, y)  , (x, y-1), (x+1, y)  , \
                                 (x-1, y+1), (x, y+1),(x+1, y+1) )

+ 17 - 17
core/Grid.py

@@ -3,16 +3,16 @@ Created on 7 nov. 2016
     Game Grid
 @author: olinox
 '''
+from core import geometry
 from core.Cell import Cell
-from core.constants import GRID_GEOMETRIES
 from core.geometry import gline, gzone, gtriangle, grectangle
 from core.pathfinder import pathfinder
 
 
 class Grid(object):
-    def __init__(self, geometry, width, height):
-        self._geometry = None
-        self.geometry = geometry
+    def __init__(self, grid_shape, width, height):
+        self._grid_shape = None
+        self.grid_shape = grid_shape
         
         self._width = 0
         self.width = width
@@ -23,14 +23,14 @@ class Grid(object):
         
     # properties
     @property
-    def geometry(self):
-        return self._geometry
-    
-    @geometry.setter
-    def geometry(self, geometry):
-        if not geometry in GRID_GEOMETRIES:
-            raise ValueError("'geometry' has to be a value from GRID_GEOMETRIES")
-        self._geometry = geometry
+    def grid_shape(self):
+        return self._grid_shape
+    
+    @grid_shape.setter
+    def grid_shape(self, grid_shape):
+        if not grid_shape in geometry.GRID_GEOMETRIES:
+            raise ValueError("'grid_shape' has to be a value from GRID_GEOMETRIES")
+        self._grid_shape = grid_shape
         
     @property
     def width(self):
@@ -71,19 +71,19 @@ class Grid(object):
         return (x > 0 and x <= self._width and y > 0 and y <= self._height)
     
     def line(self, x1, y1, x2, y2):
-        return gline.line2d(self.geometry, x1, y1, x2, y2)
+        return gline.line2d(self.grid_shape, x1, y1, x2, y2)
     
     def line3d(self, x1, y1, z1, x2, y2, z2):
-        return gline.line3d(self.geometry, x1, y1, z1, x2, y2, z2)
+        return gline.line3d(self.grid_shape, x1, y1, z1, x2, y2, z2)
     
     def zone(self, x, y, radius):
-        return gzone.zone(self.geometry, x, y, radius)
+        return gzone.zone(self.grid_shape, x, y, radius)
     
     def triangle(self, xa, ya, xh, yh, iAngle):
-        return gtriangle.triangle(self.geometry, xa, ya, xh, yh, iAngle)
+        return gtriangle.triangle(self.grid_shape, xa, ya, xh, yh, iAngle)
     
     def triangle3d(self, xa, ya, za, xh, yh, zh, iAngle):
-        return gtriangle.triangle3d(self.geometry, xa, ya, za, xh, yh, zh, iAngle)
+        return gtriangle.triangle3d(self.grid_shape, xa, ya, za, xh, yh, zh, iAngle)
 
     def rect(self, x1, y1, x2, y2):
         return grectangle.rect(x1, y1, x2, y2)

+ 0 - 4
core/constants.py

@@ -4,7 +4,3 @@ Created on 7 nov. 2016
 @author: olinox
 '''
 
-# geometry
-GRID_GEOMETRIES = [4, 5]
-SQUARE = 4
-HEX = 5

+ 8 - 0
core/geometry/__init__.py

@@ -0,0 +1,8 @@
+"""
+    Geometric algorithms on square or hexagonal grids
+"""
+
+# geometry
+GRID_GEOMETRIES = [4, 5]
+SQUARE = 4
+HEX = 5

+ 6 - 6
core/geometry/gline.py

@@ -7,29 +7,29 @@ Created on 7 nov. 2016
 '''
 from math import sqrt
 
-from core import constants
+from core import geometry
 
 
-def line2d(geometry, x1, y1, x2, y2):
+def line2d(grid_shape, x1, y1, x2, y2):
     """returns a line from x1,y1 to x2,y2
     grid could be one of the GRIDTYPES values"""
     if not all(isinstance(c, int) for c in [x1, y1, x2, y2]):
         raise TypeError("x1, y1, x2, y2 have to be integers")
     if (x1, y1) == (x2, y2):
         return [(x1, y1)]
-    if geometry == constants.HEX:
+    if grid_shape == geometry.HEX:
         return hex_2d_line(x1, y1, x2, y2)
-    elif geometry == constants.SQUARE: 
+    elif grid_shape == geometry.SQUARE: 
         return squ_2d_line(x1, y1, x2, y2)
     else:
         raise ValueError("'geometry' has to be a value from GRID_GEOMETRIES")
 
-def line3d(geometry, x1, y1, z1, x2, y2, z2):
+def line3d(grid_shape, x1, y1, z1, x2, y2, z2):
     """returns a line from x1,y1,z1 to x2,y2,z2
     grid could be one of the GRIDTYPES values"""
     if not all(isinstance(c, int) for c in [x1, y1, z1, x2, y2, z2]):
         raise TypeError("x1, y1, z1, x2, y2, z2 have to be integers")
-    hoLine = line2d(geometry, x1, y1, x2, y2)
+    hoLine = line2d(grid_shape, x1, y1, x2, y2)
     if z1 == z2:
         return [(x, y, z1) for x, y in hoLine]
     else:

+ 5 - 3
core/geometry/gneighbours.py

@@ -3,11 +3,13 @@ Created on 19 nov. 2016
 
 @author: olinox
 '''
+from core import geometry
 
-def neighbours_of(geometry, x, y):
-    if geometry == 4:
+
+def neighbours_of(grid_shape, x, y):
+    if grid_shape == geometry.SQUARE:
         return squ_neighbours_of(x, y)
-    elif geometry == 5: 
+    elif grid_shape == geometry.HEX: 
         return hex_neighbours_of(x, y)
     else:
         raise ValueError("'geometry' has to be a value from GRID_GEOMETRIES")

+ 20 - 14
core/geometry/gtriangle.py

@@ -6,24 +6,25 @@ Created on 8 nov. 2016
 
 from math import sqrt
 
-from core import constants
+from core import geometry
+from core.geometry import gline
 from core.geometry.cube_coords import cv_off_cube, cube_round, cv_cube_off
 
 
-ANGLES = [1, 2, 3]
+ANGLES = (1, 2, 3)
 
-def triangle(geometry, xa, ya, xh, yh, iAngle):
-    if geometry == constants.SQUARE:
+def triangle(grid_shape, xa, ya, xh, yh, iAngle):
+    if grid_shape == geometry.SQUARE:
         return triangle_sq(xa, ya, xh, yh, iAngle)
-    elif geometry == constants.HEX: 
+    elif grid_shape == geometry.HEX: 
         return triangle_hex(xa, ya, xh, yh, iAngle)
     else:
         raise ValueError("'geometry' has to be a value from GRID_GEOMETRIES")
 
-def triangle3d(geometry, xa, ya, za, xh, yh, zh, iAngle):
-    if geometry == constants.SQUARE:
+def triangle3d(grid_shape, xa, ya, za, xh, yh, zh, iAngle):
+    if grid_shape == geometry.SQUARE:
         return triangle_sq_3d(xa, ya, za, xh, yh, zh, iAngle)
-    elif geometry == constants.HEX: 
+    elif grid_shape == geometry.HEX: 
         return triangle_hex_3d(xa, ya, za, xh, yh, zh, iAngle)
     else:
         raise ValueError("'geometry' has to be a value from GRID_GEOMETRIES")
@@ -61,7 +62,7 @@ def triangle_sq(xa, ya, xh, yh, iAngle):
     
     # base (lower slope)
     x1, y1, x2, y2 = min(lines, key=lambda x: (abs ( (x[3] - x[1]) / (x[2] - x[0]) ) if x[2] != x[0] else 10**10))
-    base = line.squ_2d_line(x1, y1, x2, y2)
+    base = gline.squ_2d_line(x1, y1, x2, y2)
     y_base = y1
     lines.remove( (x1, y1, x2, y2) )
     
@@ -71,7 +72,7 @@ def triangle_sq(xa, ya, xh, yh, iAngle):
     for x1, y1, x2, y2 in lines:
         if y_top == None: 
             y_top = y2
-        hat.extend( line.squ_2d_line(x1, y1, x2, y2) )
+        hat.extend( gline.squ_2d_line(x1, y1, x2, y2) )
     
     # sense (1 if top is under base, -1 if not)
     sense = 1 if y_top > y_base else -1
@@ -88,6 +89,9 @@ def triangle_sq(xa, ya, xh, yh, iAngle):
 def triangle_sq_3d(xa, ya, za, xh, yh, zh, iAngle):
     """returns a dictionnary {coord: (-dh, +dh)}
     coord keys are the cells in the triangle, (-dh, +dh) value is the vertical amplitude"""
+    
+    #TODO: review result form
+    
     if not all(isinstance(c, int) for c in [xa, ya, xh, yh]):
         raise TypeError("xa, ya, za, xh, yh have to be integers")
     if not iAngle in ANGLES:
@@ -102,7 +106,7 @@ def triangle_sq_3d(xa, ya, za, xh, yh, zh, iAngle):
 
     length = max( abs(xh - xa), abs(yh - ya) )
 
-    vertical_line = line.squ_2d_line(0, za, length, zh)
+    vertical_line = gline.squ_2d_line(0, za, length, zh)
     
     #on cree un dictionnaire ou x est la cle, et ou la valeur est une liste de z
     vertical_line_dict = {d:[] for d, z in vertical_line}
@@ -163,7 +167,7 @@ def triangle_hex(xa, ya, xh, yh, iAngle):
     
     # base (lower slope)
     x1, y1, x2, y2 = min(segments, key=lambda x: (abs ( (x[3] - x[1]) / (x[2] - x[0]) ) if x[2] != x[0] else 10**10))
-    base = line.hex_2d_line(x1, y1, x2, y2)
+    base = gline.hex_2d_line(x1, y1, x2, y2)
     y_base = y1
     segments.remove( (x1, y1, x2, y2) )
     
@@ -173,7 +177,7 @@ def triangle_hex(xa, ya, xh, yh, iAngle):
     for x1, y1, x2, y2 in segments:
         if y_sommet == None: 
             y_sommet = y2
-        chapeau.extend( line.hex_2d_line(x1, y1, x2, y2) )
+        chapeau.extend( gline.hex_2d_line(x1, y1, x2, y2) )
     
     # sense (1 if top is under base, -1 if not)
     sens = 1 if y_sommet > y_base else -1
@@ -193,6 +197,8 @@ def triangle_hex_3d(xa, ya, za, xh, yh, zh, iAngle):
     (-dh, +dh) value is the vertical amplitude"""
     flat_trangle = triangle_hex(xa, ya, xh, yh, iAngle)
     
+    #TODO: review result form
+    
     if (xa, ya) == (xh, yh):
         return [(xa, ya)]   
     result = {} 
@@ -204,7 +210,7 @@ def triangle_hex_3d(xa, ya, za, xh, yh, zh, iAngle):
     
     length = max( abs(xuh - xua), abs(yuh - yua), abs(zuh - zua) )
 
-    vertical_line = line.squ_2d_line(0, za, length, zh)
+    vertical_line = gline.squ_2d_line(0, za, length, zh)
     
     #on cree un dictionnaire ou x est la cle, et ou la valeur est une liste de z
     vertical_line_dict = {d:[] for d, z in vertical_line}

+ 2 - 2
core/geometry/gzone.py

@@ -6,7 +6,7 @@ Created on 19 nov. 2016
 from core.geometry import gneighbours
 
 
-def zone(geometry, x0, y0, radius):
+def zone(grid_shape, x0, y0, radius):
     """ returns the list of the coordinates of the cells in the zone around (x0, y0)
     """
     if not all(isinstance(c, int) for c in [x0, y0, radius]):
@@ -18,6 +18,6 @@ def zone(geometry, x0, y0, radius):
     for _ in range(0, radius):
         current = buffer
         for x, y in current:
-            buffer |= frozenset( gneighbours.neighbours_of( geometry, x, y ) )
+            buffer |= frozenset( gneighbours.neighbours_of( grid_shape, x, y ) )
 
     return list(buffer)

+ 27 - 27
tests/geometry/test_line.py

@@ -5,7 +5,7 @@ Created on 20 nov. 2016
 '''
 import unittest
 
-from core import constants
+from core import geometry
 from core.geometry import gline
 
 
@@ -14,81 +14,81 @@ class Test(unittest.TestCase):
 
     def test_hex_line(self):
         """ 2d line on hexagonal grid """
-        geometry = constants.HEX
-        line = gline.line2d(geometry, 1,1,1,1)
+        grid_shape = geometry.HEX
+        line = gline.line2d(grid_shape, 1,1,1,1)
         self.assertEqual(line, [(1,1)])
         
-        line = gline.line2d(geometry, 0,0,1,1)
+        line = gline.line2d(grid_shape, 0,0,1,1)
         self.assertEqual(line, [(0,0), (0,1), (1,1)])
  
-        line = gline.line2d(geometry, 0,0,7,3)
+        line = gline.line2d(grid_shape, 0,0,7,3)
         self.assertEqual(line, [(0,0), (1,0), (2,1), (3,1), (4,2), (5,2), (6,3), (7,3)] )
  
-        line = gline.line2d(geometry, 4,3,0,3)
+        line = gline.line2d(grid_shape, 4,3,0,3)
         self.assertEqual(line, [(4,3), (3,2), (2,3), (1,2), (0,3)] )
  
-        line = gline.line2d(geometry, 3,0,3,3)
+        line = gline.line2d(grid_shape, 3,0,3,3)
         self.assertEqual(line, [(3,0), (3,1), (3,2), (3,3)] )
  
         
     def test_squ_line(self):
         """ 2d line on square grid """
-        geometry = constants.SQUARE
-        line = gline.line2d(geometry,0,0,0,1)
+        grid_shape = geometry.SQUARE
+        line = gline.line2d(grid_shape,0,0,0,1)
         self.assertEqual(line, [(0,0), (0,1)])
         
-        line = gline.line2d(geometry,0,0,1,1)
+        line = gline.line2d(grid_shape,0,0,1,1)
         self.assertEqual(line, [(0,0), (1,1)])
         
-        line = gline.line2d(geometry,0,0,7,3)
+        line = gline.line2d(grid_shape,0,0,7,3)
         self.assertEqual(line, [(0,0), (1,0), (2,1), (3,1), (4,2), (5,2), (6,3), (7,3)] )
  
-        line = gline.line2d(geometry,4,3,0,3)
+        line = gline.line2d(grid_shape,4,3,0,3)
         self.assertEqual(line, [(4,3), (3,3), (2,3), (1,3), (0,3)] )
  
-        line = gline.line2d(geometry,3,0,3,3)
+        line = gline.line2d(grid_shape,3,0,3,3)
         self.assertEqual(line, [(3,0), (3,1), (3,2), (3,3)] )
     
     def test_hex_line_3d(self):
         """ 3d line on hexagonal grid """
-        geometry = constants.HEX
-        line = gline.line3d(geometry,1,1,1,1,1,1)
+        grid_shape = geometry.HEX
+        line = gline.line3d(grid_shape,1,1,1,1,1,1)
         self.assertEqual(line, [(1,1,1)])
     
-        line = gline.line3d(geometry,1,1,0,1,1,1)
+        line = gline.line3d(grid_shape,1,1,0,1,1,1)
         self.assertEqual(line, [(1,1,0), (1,1,1)])
     
-        line = gline.line3d(geometry,0,0,0,1,1,1)
+        line = gline.line3d(grid_shape,0,0,0,1,1,1)
         self.assertEqual(line, [(0,0,0), (0,1,0), (1,1,1)])
     
-        line = gline.line3d(geometry,0,0,0,7,3,7)
+        line = gline.line3d(grid_shape,0,0,0,7,3,7)
         self.assertEqual(line, [(0,0,0), (1,0,1), (2,1,2), (3,1,3), (4,2,4), (5,2,5), (6,3,6), (7,3,7)] )
  
-        line = gline.line3d(geometry,4,3,10,0,3,3)
+        line = gline.line3d(grid_shape,4,3,10,0,3,3)
         self.assertEqual(line, [(4,3,10), (3,2,9), (3,2,8), (2,3,7), (2,3,6), (1,2,5), (1,2,4), (0,3,3)] )
  
-        line = gline.line3d(geometry,3,0,0,3,3,0)
+        line = gline.line3d(grid_shape,3,0,0,3,3,0)
         self.assertEqual(line, [(3,0,0), (3,1,0), (3,2,0), (3,3,0)] )
         
     def test_squ_line_3d(self):
         """ 3d line on square grid """
-        geometry = constants.SQUARE
-        line = gline.line3d(geometry,1,1,1,1,1,1)
+        grid_shape = geometry.SQUARE
+        line = gline.line3d(grid_shape,1,1,1,1,1,1)
         self.assertEqual(line, [(1,1,1)])
     
-        line = gline.line3d(geometry,1,1,0,1,1,1)
+        line = gline.line3d(grid_shape,1,1,0,1,1,1)
         self.assertEqual(line, [(1,1,0), (1,1,1)])
     
-        line = gline.line3d(geometry,0,0,0,1,1,1)
+        line = gline.line3d(grid_shape,0,0,0,1,1,1)
         self.assertEqual(line, [(0,0,0), (1,1,1)])
     
-        line = gline.line3d(geometry,0,0,0,7,3,7)
+        line = gline.line3d(grid_shape,0,0,0,7,3,7)
         self.assertEqual(line, [(0,0,0), (1,0,1), (2,1,2), (3,1,3), (4,2,4), (5,2,5), (6,3,6), (7,3,7)] )
  
-        line = gline.line3d(geometry,4,3,10,0,3,3)
+        line = gline.line3d(grid_shape,4,3,10,0,3,3)
         self.assertEqual(line, [(4,3,10), (3,3,9), (3,3,8), (2,3,7), (2,3,6), (1,3,5), (1,3,4), (0,3,3)] )
  
-        line = gline.line3d(geometry,3,0,0,3,3,0)
+        line = gline.line3d(grid_shape,3,0,0,3,3,0)
         self.assertEqual(line, [(3,0,0), (3,1,0), (3,2,0), (3,3,0)] )
 
 

+ 55 - 0
tests/geometry/test_triangle.py

@@ -0,0 +1,55 @@
+'''
+Created on 22 nov. 2016
+
+@author: olinox
+'''
+import unittest
+
+from core import geometry
+from core.geometry import gtriangle
+
+
+class Test(unittest.TestCase):
+    """test triangle algorithms"""
+
+    def test_sq_triangle(self):
+        """test triangle algorithms on square grid"""
+        grid_shape = geometry.SQUARE
+        
+        for i in gtriangle.ANGLES:
+            self.assertCountEqual(gtriangle.triangle(grid_shape, 0, 0, 0, 0, i), [(0,0)])
+
+        #TODO: complete
+
+
+    def test_hex_triangle(self):
+        """test triangle algorithms on hexagonal grid"""
+        grid_shape = geometry.HEX
+        for i in gtriangle.ANGLES:
+            self.assertCountEqual(gtriangle.triangle(grid_shape, 0, 0, 0, 0, i), [(0,0)])
+        #TODO: complete
+    
+    def test_sq_triangle_3d(self):
+        """test triangle3d algorithms on square grid"""
+        grid_shape = geometry.SQUARE
+        #TODO: complete
+     
+    def test_hex_triangle_3d(self):
+        """test triangle3d algorithms on hexagonal grid"""
+        grid_shape = geometry.HEX
+        #TODO: complete
+
+    def test_errors(self):
+        
+        for grid_shape in (geometry.HEX, geometry.SQUARE):
+            self.assertRaises(ValueError, gtriangle.triangle, grid_shape, 0, 0, 0, 0, 0)
+            self.assertRaises(TypeError, gtriangle.triangle, grid_shape, "a", 0, 0, 0, 1)
+            self.assertRaises(TypeError, gtriangle.triangle, grid_shape, 0, "a", 0, 0, 1)
+            self.assertRaises(TypeError, gtriangle.triangle, grid_shape, 0, 0, "a", 0, 1)
+            self.assertRaises(TypeError, gtriangle.triangle, grid_shape, 0, 0, 0, "a", 1)
+            self.assertRaises(ValueError, gtriangle.triangle, grid_shape, 0, 0, 0, 0, "a")
+    
+
+if __name__ == "__main__":
+    #import sys;sys.argv = ['', 'Test.test_sq_triangle']
+    unittest.main()

+ 9 - 9
tests/geometry/test_zone.py

@@ -5,7 +5,7 @@ Created on 20 nov. 2016
 '''
 import unittest
 
-from core import constants
+from core import geometry
 from core.geometry import gzone
 
 
@@ -16,19 +16,19 @@ class Test(unittest.TestCase):
 
     def test_hex_zone(self):
         """ test the zone algo for hexagonal grid """
-        geometry = constants.HEX
-        self.assertCountEqual( gzone.zone( geometry, 3, 3, 0 ), [(3,3)])
-        self.assertCountEqual( gzone.zone( geometry, 3, 3, 1 ), [(3, 2), (2, 3), (3, 3), (4, 3), (4, 4), (3, 4), (2, 4)])
-        self.assertCountEqual( gzone.zone( geometry, 3, 3, 2 ), [(3, 2), (1, 3), (5, 4), (4, 5), (1, 4), (2, 3), (4, 2), \
+        grid_shape = geometry.HEX
+        self.assertCountEqual( gzone.zone( grid_shape, 3, 3, 0 ), [(3,3)])
+        self.assertCountEqual( gzone.zone( grid_shape, 3, 3, 1 ), [(3, 2), (2, 3), (3, 3), (4, 3), (4, 4), (3, 4), (2, 4)])
+        self.assertCountEqual( gzone.zone( grid_shape, 3, 3, 2 ), [(3, 2), (1, 3), (5, 4), (4, 5), (1, 4), (2, 3), (4, 2), \
                                                             (2, 5), (5, 3), (1, 2), (3, 5), (3, 3), (4, 4), (3, 1), \
                                                             (4, 3), (2, 2), (3, 4), (2, 4), (5, 2)] )
 
     def test_squ_zone(self):
         """ test the zone algo for square grid """
-        geometry = constants.SQUARE
-        self.assertCountEqual( gzone.zone( geometry, 3, 3, 0 ), [(3,3)])
-        self.assertCountEqual( gzone.zone( geometry, 3, 3, 1 ), [(3, 2), (3, 3), (4, 4), (2, 3), (4, 3), (2, 2), (4, 2), (3, 4), (2, 4)])
-        self.assertCountEqual( gzone.zone( geometry, 3, 3, 2 ), [(2, 4), (3, 2), (5, 4), (1, 3), (4, 5), (2, 1), (1, 4), (2, 3), (4, 2), \
+        grid_shape = geometry.SQUARE
+        self.assertCountEqual( gzone.zone( grid_shape, 3, 3, 0 ), [(3,3)])
+        self.assertCountEqual( gzone.zone( grid_shape, 3, 3, 1 ), [(3, 2), (3, 3), (4, 4), (2, 3), (4, 3), (2, 2), (4, 2), (3, 4), (2, 4)])
+        self.assertCountEqual( gzone.zone( grid_shape, 3, 3, 2 ), [(2, 4), (3, 2), (5, 4), (1, 3), (4, 5), (2, 1), (1, 4), (2, 3), (4, 2), \
                                                                     (5, 1), (2, 5), (3, 5), (5, 3), (1, 2), (3, 3), (5, 5), (4, 4), (3, 1), \
                                                                     (1, 5), (4, 3), (2, 2), (4, 1), (5, 2), (3, 4), (1, 1)])
 

+ 7 - 7
tests/test_grid.py

@@ -5,7 +5,7 @@ Created on 20 nov. 2016
 '''
 import unittest
 
-from core import constants
+from core import geometry
 from core.Grid import Grid, SquareGrid, HexGrid
 
 
@@ -13,19 +13,19 @@ class Test(unittest.TestCase):
 
     def test_init(self):
         #square grid
-        _ = Grid( constants.SQUARE, 1, 1 )
+        _ = Grid( geometry.SQUARE, 1, 1 )
         _ = SquareGrid( 1, 1 )
         
         #hex grid
-        _ = Grid( constants.HEX, 1, 1 )
+        _ = Grid( geometry.HEX, 1, 1 )
         _ = HexGrid( 1, 1 )
 
     def test_geometry(self):
-        grid = Grid( constants.SQUARE, 1, 1 )
-        self.assertEqual( grid.geometry, constants.SQUARE )
+        grid = Grid( geometry.SQUARE, 1, 1 )
+        self.assertEqual( grid.geometry, geometry.SQUARE )
         
-        grid.geometry = constants.HEX
-        self.assertEqual( grid.geometry, constants.HEX )
+        grid.geometry = geometry.HEX
+        self.assertEqual( grid.geometry, geometry.HEX )
 
         def _set_invalid_geometry():
             grid.geometry = -1