TL;DR
Too hard to read? Here is a quick summary of the project.
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. The main goal is to develop an algorithm that is able to find the best path from the origin to the destination.
Check Elements for more details.
Installation
Just use the following command in your notebook:
!pip install git+https://github.com/jparisu/sIArena.git
Check the installation guide for more details.
How to generate a terrain
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.PerlinGenerator import PerlinGenerator
terrain = PerlinGenerator().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 Generate Terrain for more details.
How to write a path finding algorithm
Easy, create an algorithm that is able to retrieve a list of sequently Coordinate that goes from the origin to the destination of the terrain.
from sIArena.terrain.Terrain import Coordinate, Path, Terrain
from sIArena.measurements.measurements import measure_function
terrain = ... # Terrain already created
def my_algorithm(terrain: Terrain) -> Path:
path = [terrain.origin]
# To check the possible next cells:
terrain.get_neighbors(path[-1])
# Add new sequently coordinates till the destination
path.add(...)
# ...
return path + [terrain.destination]
# measure your algorithm cost and time
min_cost, second, path = measure_function(my_algorithm, terrain)
Check Measure tools for more details.
How to grade submissions
Use the autograder application to evaluate one notebook or one zip archive of notebooks against a YAML grader configuration:
python apps/autograder/autograder.py \
--input submissions.zip \
--config resources/graders/IA_practica_0.yaml \
--output results.csv
Check Autograder and Grading API for more details.