commit
This commit is contained in:
parent
56e0195600
commit
4f59633394
4 changed files with 74 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.class
|
9
AppLaser.java
Normal file
9
AppLaser.java
Normal file
|
@ -0,0 +1,9 @@
|
|||
public class AppLaser {
|
||||
|
||||
public static void main(String [] args) {
|
||||
Universe universe = new Universe(12, 12);
|
||||
|
||||
universe.print();
|
||||
}
|
||||
|
||||
}
|
44
Universe.java
Normal file
44
Universe.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
// Antoine CRETUAL, Lukian LEIZOUR, 14/02/2024
|
||||
|
||||
public class Universe {
|
||||
// Atributes
|
||||
|
||||
private int[][] grid;
|
||||
private int length, height;
|
||||
|
||||
// Constructors
|
||||
|
||||
public Universe(int length, int height) {
|
||||
this.grid = new int[height][length];
|
||||
this.height = height;
|
||||
this.length = length;
|
||||
int i, j;
|
||||
for (i = 1; i < this.height - 1; i++) {
|
||||
for (j = 1; j < this.length - 1; j++) {
|
||||
grid[i][j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < this.height; i++) {
|
||||
grid[i][0] = -1;
|
||||
grid[i][length - 1] = -1;
|
||||
}
|
||||
|
||||
for (j = 0; j < this.length; j++) {
|
||||
grid[0][j] = -1;
|
||||
grid[height - 1][j] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Methods
|
||||
|
||||
public void print() {
|
||||
int i, j;
|
||||
for (i = 0; i < this.height; i++) {
|
||||
for (j = 0; j < this.length; j++) {
|
||||
System.out.printf("%3d", this.grid[i][j]);
|
||||
}
|
||||
System.out.print("\n");
|
||||
}
|
||||
}
|
||||
}
|
20
algo.txt
Normal file
20
algo.txt
Normal file
|
@ -0,0 +1,20 @@
|
|||
Setup:
|
||||
- Taille de la grille
|
||||
- Obstacles
|
||||
- Départ du rayon (avec l'orientation)
|
||||
- Point d'arrivée
|
||||
|
||||
Déplacement:
|
||||
- A chaque position on teste à gauche, à droite et en face
|
||||
- Si en face, ne pas mettre de miroir et continuer
|
||||
- Si a gauche ou à droite, mettre un miroir
|
||||
- Si aucune solution, retour en arrirère (backtrack)
|
||||
- Exceptions:
|
||||
- Impossible de mettre un miroir sur un rayon déjà existant
|
||||
- Impossible de viser la base du laser
|
||||
- Impossible de finir dans un cul de sac (sauf si fin)
|
||||
- /!\ attention aux cases vides non accessibles
|
||||
|
||||
Condition de fin:
|
||||
- Si la pile est vide cela veut dire que toute les possibilités ont été testés et donc on renvoie la meilleure
|
||||
- La meilleur solution est celle qui remplie le plus de cases vides avec le moins de miroirs
|
Loading…
Add table
Add a link
Reference in a new issue