add algo
This commit is contained in:
@@ -0,0 +1,92 @@
|
|||||||
|
const Orientation = Object.freeze({
|
||||||
|
HAUT: Symbol("haut"),
|
||||||
|
BAS: Symbol("bas"),
|
||||||
|
GAUCHE: Symbol("gauche"),
|
||||||
|
DROITE: Symbol("droite")
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
class ModeAutomatique {
|
||||||
|
|
||||||
|
casesParcourues = new Array();
|
||||||
|
cheminsParcours = new Array();
|
||||||
|
cheminsConnus = new Array();
|
||||||
|
|
||||||
|
|
||||||
|
constructor(){
|
||||||
|
// valeurs pour la première position
|
||||||
|
posX=0;
|
||||||
|
posY=0;
|
||||||
|
rotation=HAUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
run(){
|
||||||
|
this.analyseEnvironnement(); // met à jour les obstacles
|
||||||
|
this.move(); // en fonction des chemins connus non encore parcourus
|
||||||
|
|
||||||
|
//obstacle
|
||||||
|
if (!this.aBouge){
|
||||||
|
// recule
|
||||||
|
// teste de 30 degrés
|
||||||
|
// tente d'avancer
|
||||||
|
// teste de 30 degrés
|
||||||
|
// tente d'avancer
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
analyseEnvironnement(){
|
||||||
|
if (isCaseAnalysee()) {
|
||||||
|
isObstacleDevant();
|
||||||
|
tourne(); //
|
||||||
|
isObstacleDevant();
|
||||||
|
tourne();
|
||||||
|
isObstacleDevant();
|
||||||
|
tourne();
|
||||||
|
isObstacleDevant();
|
||||||
|
tourne();
|
||||||
|
}
|
||||||
|
|
||||||
|
// SI case déjà visitée, alors on connait ses obstacles
|
||||||
|
}
|
||||||
|
|
||||||
|
isCaseAnalysee(){
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCoordonnees() {
|
||||||
|
switch (this.rotation) {
|
||||||
|
case Orientation.HAUT:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case Orientation.BAS:
|
||||||
|
case Orientation.GAUCHE:
|
||||||
|
console.log("Mangoes and papayas are $2.79 a pound.");
|
||||||
|
// Expected output: "Mangoes and papayas are $2.79 a pound."
|
||||||
|
break;
|
||||||
|
case Orientation.DROITE:
|
||||||
|
console.log(`Sorry, we are out of ${expr}.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Case {
|
||||||
|
coordX;
|
||||||
|
coordY;
|
||||||
|
chemins;
|
||||||
|
|
||||||
|
constructor(coordX, coordY){
|
||||||
|
this.coordX = coordX;
|
||||||
|
this.coordY = coordY;
|
||||||
|
chemins = new Array();
|
||||||
|
}
|
||||||
|
|
||||||
|
addCheminPossible(chemin){
|
||||||
|
this.chemins.push(chemin)
|
||||||
|
}
|
||||||
|
|
||||||
|
getCheminsPossibles(){
|
||||||
|
return this.chemins
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user