diff --git a/docs/resources/images/pernil100x100_0.png b/docs/resources/images/perlin100x100_0.png similarity index 100% rename from docs/resources/images/pernil100x100_0.png rename to docs/resources/images/perlin100x100_0.png diff --git a/docs/resources/scripts/tutorial.py b/docs/resources/scripts/tutorial.py index b43fd11..a278b5e 100644 --- a/docs/resources/scripts/tutorial.py +++ b/docs/resources/scripts/tutorial.py @@ -2,9 +2,9 @@ ##################################################################### from sIArena.terrain.Terrain import Coordinate, Terrain, Path -from sIArena.terrain.generator.PernilGenerator import PernilGenerator +from sIArena.terrain.generator.PerlinGenerator import PerlinGenerator -terrain = PernilGenerator().generate_random_terrain( +terrain = PerlinGenerator().generate_random_terrain( n=25, m=25, min_height=0, diff --git a/docs/rst/getting_started/tldr.rst b/docs/rst/getting_started/tldr.rst index 4761e0f..6164923 100644 --- a/docs/rst/getting_started/tldr.rst +++ b/docs/rst/getting_started/tldr.rst @@ -44,9 +44,9 @@ Use the following code changing some parameters: from sIArena.terrain.generator.Generator import TerrainGenerator from sIArena.terrain.generator.FocusedGenerator import FocusedGenerator - from sIArena.terrain.generator.PernilGenerator import PernilGenerator + from sIArena.terrain.generator.PerlinGenerator import PerlinGenerator - terrain = PernilGenerator().generate_random_terrain( + terrain = PerlinGenerator().generate_random_terrain( n=20, m=20, min_height=0, diff --git a/docs/rst/modules/generation.rst b/docs/rst/modules/generation.rst index 9308b59..10f3ae6 100644 --- a/docs/rst/modules/generation.rst +++ b/docs/rst/modules/generation.rst @@ -31,7 +31,7 @@ There exist different generators that create the random matrix from different cr .. code-block:: python from sIArena.terrain.generator.FocusedGenerator import FocusedGenerator - from sIArena.terrain.generator.PernilGenerator import PernilGenerator + from sIArena.terrain.generator.PerlinGenerator import PerlinGenerator from sIArena.terrain.generator.MazeGenerator import MazeGenerator In order to generate a terrain, the user must create a generator object and call the function ``generate_random_terrain``: @@ -57,7 +57,7 @@ It tends to create very craggy and with diagonal mountains. .. image:: /resources/images/focused100x100_0.png -Pernil Generator +Perlin Generator ================ This generator uses perlin noise to generate the terrain. @@ -66,9 +66,9 @@ It tends to create smooth terrains with some hills and valleys. .. code-block:: python - terrain = PernilGenerator().generate_random_terrain(n=100, m=100, seed=0) + terrain = PerlinGenerator().generate_random_terrain(n=100, m=100, seed=0) -.. image:: /resources/images/pernil100x100_0.png +.. image:: /resources/images/perlin100x100_0.png diff --git a/docs/spelling/spelling_wordlist.txt b/docs/spelling/spelling_wordlist.txt index 63c4617..a03cf63 100644 --- a/docs/spelling/spelling_wordlist.txt +++ b/docs/spelling/spelling_wordlist.txt @@ -1,4 +1,4 @@ Colab IArena sIArena -pernil +perlin diff --git a/resources/measurement_template.ipynb b/resources/measurement_template.ipynb index 71a8402..7842b04 100644 --- a/resources/measurement_template.ipynb +++ b/resources/measurement_template.ipynb @@ -20,7 +20,7 @@ "\n", "from sIArena.terrain.plot.plot_2D import plot_terrain_2D\n", "from sIArena.terrain.plot.plot_3D import plot_terrain_3D\n", - "from sIArena.terrain.generator.PernilGenerator import PernilGenerator\n", + "from sIArena.terrain.generator.PerlinGenerator import PerlinGenerator\n", "\n", "N = 50\n", "M = 50\n", @@ -32,7 +32,7 @@ "ORIGIN = None\n", "DESTINATION = None\n", "\n", - "terrain = PernilGenerator().generate_random_terrain(\n", + "terrain = PerlinGenerator().generate_random_terrain(\n", " n=N,\n", " m=M,\n", " min_height=MIN_HEIGHT,\n", diff --git a/src/sIArena/terrain/Terrain.py b/src/sIArena/terrain/Terrain.py index a0ef767..d4b8471 100644 --- a/src/sIArena/terrain/Terrain.py +++ b/src/sIArena/terrain/Terrain.py @@ -120,13 +120,16 @@ def get_path_cost(self, path: Path) -> int: return cost - def is_complete_path(self, path: Path) -> Tuple[bool, str]: + def is_complete_path(self, path: Path) -> bool: """True if valid path""" return self.is_valid_path(path) - def is_valid_path(self, path: Path) -> bool: - return self.why_valid_path()[0] + return self.why_valid_path(path)[0] + + def why_valid_path(self, path: Path) -> Tuple[bool, str]: + """Returns True if the given path is valid""" + return self.why_valid_path(path) def why_valid_path(self, path: Path) -> Tuple[bool, str]: """Returns True if the given path is valid""" @@ -189,12 +192,12 @@ def __init__( def is_complete_path(self, path: Path) -> bool: - return self.is_complete_path()[0] + return self.why_complete_path(path)[0] def why_complete_path(self, path: Path) -> Tuple[bool, str]: """Returns True if the given path goes from the origin to the destination""" # Check that the path is valid - valid = self.is_valid_path(path) + valid = self.why_valid_path(path) if not valid[0]: return valid @@ -282,12 +285,12 @@ def __init__( def is_complete_path(self, path: Path) -> bool: - return self.why_complete_path()[0] + return self.why_complete_path(path)[0] def why_complete_path(self, path: Path) -> Tuple[bool, str]: """Returns True if the given path goes from the origin to all the destinations""" # Check that the path is valid - valid = self.is_valid_path(path) + valid = self.why_valid_path(path) if not valid[0]: return valid diff --git a/src/sIArena/terrain/generator/PernilGenerator.py b/src/sIArena/terrain/generator/PerlinGenerator.py similarity index 92% rename from src/sIArena/terrain/generator/PernilGenerator.py rename to src/sIArena/terrain/generator/PerlinGenerator.py index b0cf99f..0e9d9b4 100644 --- a/src/sIArena/terrain/generator/PernilGenerator.py +++ b/src/sIArena/terrain/generator/PerlinGenerator.py @@ -8,7 +8,7 @@ from sIArena.utils.decorators import override -class PernilGenerator(TerrainGenerator): +class PerlinGenerator(TerrainGenerator): @override def generate_random_matrix_( @@ -33,12 +33,12 @@ def generate_random_matrix_( map = np.zeros((n,m)) for i in range(n): for j in range(m): - map[i][j] = PernilGenerator.pernil_value_generator( + map[i][j] = PerlinGenerator.perlin_value_generator( i, j, base, scale) return map - def pernil_value_generator( + def perlin_value_generator( i: int, j: int, base: int, @@ -48,7 +48,7 @@ def pernil_value_generator( lacunarity: float = 2.0 ) -> int: """ - Generates a random value for a cell of a terrain using Pernil noise + Generates a random value for a cell of a terrain using Perlin noise :param i: row of the cell :param j: column of the cell