Skip to content

Commit

Permalink
fix some minor stuff
Browse files Browse the repository at this point in the history
Signed-off-by: jparisu <[email protected]>
  • Loading branch information
jparisu committed Feb 3, 2024
1 parent 24c13e5 commit edb95f3
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 55 deletions.
Binary file modified docs/resources/images/3dplot_big_solved.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 17 additions & 45 deletions docs/rst/getting_started/tldr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ Project Overview
================

This project helps you to generate 2D terrains, that are matrix of integers, with a point of origin and a point of destination.
Over these terrains you have several features:
The main goal is to develop an algorithm that is able to find the best path from the origin to the destination.

- You can print it in the console
- You can plot it in a ``matplotlib`` 2D plot
- You can plot it in 3D with different angles
- **You can check the total length of a given path from origin to destination**
- You can even draw the paths in the plots previously mentioned
Check :ref:`elements` for more details.


============
Expand All @@ -35,52 +31,26 @@ Check the :ref:`installation guide <getting_started_installation>` for more deta
How to generate a terrain
=========================

In order to generate a pseudorandom :ref:`elements_terrain`,
the abstract class ``TerrainGenerator`` is provided.
The main function use the following parameters:

- ``n: int`` number of rows
- ``m: int`` number of columns
- ``min_height: int = 0`` minimum height of the terrain
- ``max_height: int = 99`` maximum height of the terrain
- ``min_step: int = 1`` minimum step between two heights
- ``abruptness: float = 0.2`` 0: smooth, 1: abrupt
- ``seed: int = None`` seed for the random number generator
- ``origin: Coordinate = None`` origin of the terrain
- ``destination: Coordinate = None`` destination of the terrain

There are 2 main generators: ``FocusedTerrainGenerator`` and ``PernilTerrainGenerator``.

Create your terrain as follows:
Use the following code changing some parameters:

.. code-block:: py
from sIArena.terrain.generator.Generator import TerrainGenerator
from sIArena.terrain.generator.FocusedGenerator import FocusedGenerator
from sIArena.terrain.generator.PernilGenerator import PernilGenerator
N = 20
M = 20
MIN_HEIGHT = 0
MAX_HEIGHT = 10
MIN_STEP = 1
ABR = 0.1
ORIGIN = None
DESTINATION = None
SEED = 60
GENERATOR = PernilGenerator()
terrain = TerrainGenerator.generate_random_terrain(
GENERATOR,
n=N,
m=M,
min_height=MIN_HEIGHT,
max_height=MAX_HEIGHT,
min_step=MIN_STEP,
abruptness=ABR,
seed=SEED,
origin=ORIGIN,
destination=DESTINATION)
terrain = PernilGenerator().generate_random_terrain(
n=20,
m=20,
min_height=0,
max_height=10,
min_step=1,
abruptness=0.1,
seed=0,
origin=(0,0),
destination=(19,19))
Check :ref:`generation` for more details.


=====================================
Expand Down Expand Up @@ -111,3 +81,5 @@ that goes from the origin to the destination of the terrain.
# measure your algorithm cost and time
min_cost, second, path = measure_function(my_algorithm, terrain)
Check :ref:`measure` for more details.
13 changes: 9 additions & 4 deletions docs/rst/modules/elements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@
Elements
########

.. contents::
:local:
:backlinks: none
:depth: 1

In the following sections, we will describe the different elements in this project.

The main elements are a :ref:`elements_coordinate`,
a :ref:`elements_terrain` and a :ref:`elements_path`.



.. include:: rst/modules/elements/coordinate.rst
.. include:: elements/coordinate.rst

.. include:: rst/modules/elements/terrain.rst
.. include:: elements/terrain.rst

.. include:: rst/modules/elements/path.rst
.. include:: elements/path.rst

.. include:: rst/modules/elements/example.rst
.. include:: elements/example.rst
4 changes: 2 additions & 2 deletions docs/rst/modules/elements/terrain.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ The origin and destination cells are marked with the characters ``+`` and ``x``
2D plot
*******

.. image:: resources/image/2dplot_55.png
.. image:: /resources/image/2dplot_55.png

In order to learn how to visualize a 2D plot of the terrain, please refer to the :ref:`plotting_2d` section.


3D plot
*******

.. image:: resources/image/3dplot_55.png
.. image:: /resources/image/3dplot_55.png

In order to learn how to visualize a 3D plot of the terrain, please refer to the :ref:`plotting_3d` section.
15 changes: 15 additions & 0 deletions docs/rst/modules/generation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,18 @@ Generate Terrain

Coming soon.
TODO

.. contents::
:local:
:backlinks: none
:depth: 1

- ``n: int`` number of rows
- ``m: int`` number of columns
- ``min_height: int = 0`` minimum height of the terrain
- ``max_height: int = 99`` maximum height of the terrain
- ``min_step: int = 1`` minimum step between two heights
- ``abruptness: float = 0.2`` 0: smooth, 1: abrupt
- ``seed: int = None`` seed for the random number generator
- ``origin: Coordinate = None`` origin of the terrain
- ``destination: Coordinate = None`` destination of the terrain
5 changes: 5 additions & 0 deletions docs/rst/modules/measure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ Measure tools

Coming soon.
TODO

.. contents::
:local:
:backlinks: none
:depth: 1
13 changes: 9 additions & 4 deletions docs/rst/modules/plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
Plot Terrain
############

.. contents::
:local:
:backlinks: none
:depth: 1

Certain functions allow to plot a :ref:`elements_terrain` to visualize the heights easily.


Expand Down Expand Up @@ -52,7 +57,7 @@ Example
paths_legends=['Path 1'],
add_cost_to_legend=True)
.. image:: resources/images/2dplot_3_4_path.png
.. image:: /resources/images/2dplot_3_4_path.png


.. _plotting_3d:
Expand Down Expand Up @@ -98,7 +103,7 @@ Example
angles=[(80, 10), (30, 190), (30, 10)],
paths=[path])
.. image:: resources/images/3dplot_3_4_path.png
.. image:: /resources/images/3dplot_3_4_path.png



Expand All @@ -107,9 +112,9 @@ Examples

When used in bigger terrains, the result is much more interesting.

.. image:: resources/images/2dplot_10_10_solved.png
.. image:: /resources/images/2dplot_10_10_solved.png

.. image:: resources/images/3dplot_10_10_solved.png
.. image:: /resources/images/3dplot_10_10_solved.png


.. warning::
Expand Down

0 comments on commit edb95f3

Please sign in to comment.