Skip to content
This repository has been archived by the owner on Mar 3, 2019. It is now read-only.

Commit

Permalink
Gestion symétrie
Browse files Browse the repository at this point in the history
  • Loading branch information
PFGimenez committed May 23, 2017
1 parent f489a2f commit 43de62a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
11 changes: 6 additions & 5 deletions pc/src/obstacles/types/ObstaclesFixes.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@

public enum ObstaclesFixes
{
// TODO visibilité à mettre à jour selon le robot / les capteurs
ZONE_DEPART_ENNEMI(new ObstacleRectangular(new Vec2RO(1070 / 2 - 1500, 2000 - 360 / 2), 1070, 360, Couleur.OBSTACLES), false, false),
BASCULE_GAUCHE(new ObstacleRectangular(new Vec2RO(-(1140 - 350 / 2), 2000 - 360 / 2), 350, 360, Couleur.OBSTACLES), true, false),
ZONE_DEPART_GAUCHE_GAUCHE(new ObstacleRectangular(new Vec2RO(-(1500 - 360 / 2), 2000 - 360 / 2), 360, 360, Couleur.OBSTACLES), true, false),
ZONE_DEPART_GAUCHE_CENTRE(new ObstacleRectangular(new Vec2RO(-(790 - 360 / 2), 2000 - 360 / 2), 360, 360, Couleur.OBSTACLES), true, false),

// CECI EST UN HACK. Vu qu'on n'est pas censé voir d'ennemis sur notre zone de départ, mettre ces obstacles en visibles permettent d'ignorer ce qu'on y voit
BASCULE(new ObstacleRectangular(new Vec2RO(1140 - 350 / 2, 2000 - 360 / 2), 350, 360, Couleur.OBSTACLES), true, true),
ZONE_DEPART_A_NOUS(new ObstacleRectangular(new Vec2RO(1500 - 360 / 2, 2000 - 360 / 2), 360, 360, Couleur.OBSTACLES), true, true),
BASCULE_DROITE(new ObstacleRectangular(new Vec2RO(1140 - 350 / 2, 2000 - 360 / 2), 350, 360, Couleur.OBSTACLES), true, false),
ZONE_DEPART_DROITE_DROITE(new ObstacleRectangular(new Vec2RO(1500 - 360 / 2, 2000 - 360 / 2), 360, 360, Couleur.OBSTACLES), true, false),
ZONE_DEPART_DROITE_CENTRE(new ObstacleRectangular(new Vec2RO(790 - 360 / 2, 2000 - 360 / 2), 360, 360, Couleur.OBSTACLES), true, false),

TASSEAU_DROITE(new ObstacleRectangular(new Vec2RO(1500 - 710 / 2, 2000 - 360 - 11), 710, 22, Couleur.OBSTACLES), true, false),
TASSEAU_GAUCHE(new ObstacleRectangular(new Vec2RO(-1500 + 710 / 2, 2000 - 360 - 11), 710, 22, Couleur.OBSTACLES), true, false),
Expand Down
18 changes: 13 additions & 5 deletions pc/src/pathfinding/astar/AStarCourbe.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import pathfinding.dstarlite.gridspace.PointGridSpace;
import config.Config;
import config.ConfigInfo;
import config.DynamicConfigurable;
import container.Service;
import container.dependances.HighPFClass;
import exceptions.MemoryManagerException;
Expand All @@ -56,9 +57,10 @@
*
*/

public class AStarCourbe implements Service, HighPFClass
public class AStarCourbe implements Service, HighPFClass, DynamicConfigurable
{
protected Log log;
private boolean symetrie;
private ArcManager arcmanager;
private DStarLite dstarlite;
private RealGameState state;
Expand Down Expand Up @@ -207,7 +209,7 @@ public final synchronized void process(CheminPathfindingInterface chemin, boolea
CinematiqueObs obsDepart = cinemMemory.getNewNode();
Cinematique cinemDepart = depart.state.robot.getCinematique();
obsDepart.updateReel(cinemDepart.getPosition().getX(), cinemDepart.getPosition().getY(), cinemDepart.orientationReelle, cinemDepart.enMarcheAvant, cinemDepart.courbureReelle);
arcmanager.disableObstaclesFixes(obsDepart);
arcmanager.disableObstaclesFixes(symetrie, obsDepart);
}

trajetDeSecours = null;
Expand Down Expand Up @@ -471,7 +473,7 @@ public void initializeNewSearch(Cinematique arrivee, SensFinal sens, boolean sho
CinematiqueObs obsDepart = cinemMemory.getNewNode();
Cinematique cinemDepart = depart.state.robot.getCinematique();
obsDepart.updateReel(cinemDepart.getPosition().getX(), cinemDepart.getPosition().getY(), cinemDepart.orientationReelle, cinemDepart.enMarcheAvant, cinemDepart.courbureReelle);
arcmanager.disableObstaclesFixes(obsDepart);
arcmanager.disableObstaclesFixes(symetrie, obsDepart);
}

dstarlite.computeNewPath(depart.state.robot.getCinematique().getPosition(), arrivee.getPosition(), shoot);
Expand Down Expand Up @@ -503,7 +505,7 @@ public void initializeNewSearchToCircle(boolean shoot, GameState<? extends Robot
CinematiqueObs obsDepart = cinemMemory.getNewNode();
Cinematique cinemDepart = depart.state.robot.getCinematique();
obsDepart.updateReel(cinemDepart.getPosition().getX(), cinemDepart.getPosition().getY(), cinemDepart.orientationReelle, cinemDepart.enMarcheAvant, cinemDepart.courbureReelle);
arcmanager.disableObstaclesFixes(obsDepart);
arcmanager.disableObstaclesFixes(symetrie, obsDepart);
}

dstarlite.computeNewPath(depart.state.robot.getCinematique().getPosition(), cercle.arriveeDStarLite, shoot);
Expand Down Expand Up @@ -546,7 +548,7 @@ public void updatePath(Cinematique lastValid) throws PathfindingException, Memor
CinematiqueObs obsDepart = cinemMemory.getNewNode();
Cinematique cinemDepart = depart.state.robot.getCinematique();
obsDepart.updateReel(cinemDepart.getPosition().getX(), cinemDepart.getPosition().getY(), cinemDepart.orientationReelle, cinemDepart.enMarcheAvant, cinemDepart.courbureReelle);
arcmanager.disableObstaclesFixes(obsDepart);
arcmanager.disableObstaclesFixes(symetrie, obsDepart);
}

// On met à jour le D* Lite
Expand All @@ -564,4 +566,10 @@ public boolean isArrivedAsser()
return arcmanager.isArrivedAsser(state.robot.getCinematique());
}

@Override
public void updateConfig(Config config)
{
symetrie = config.getSymmetry();
}

}
6 changes: 5 additions & 1 deletion pc/src/pathfinding/astar/arcs/ArcManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,13 @@ public double heuristicDirect(Cinematique cinematique)
return 3 * cinematique.getPosition().distanceFast(arrivee.getPosition());
}

public void disableObstaclesFixes(CinematiqueObs obs)
public void disableObstaclesFixes(boolean symetrie, CinematiqueObs obs)
{
disabledObstaclesFixes.clear();
if(symetrie)
disabledObstaclesFixes.add(ObstaclesFixes.ZONE_DEPART_GAUCHE_CENTRE);
else
disabledObstaclesFixes.add(ObstaclesFixes.ZONE_DEPART_DROITE_CENTRE);
for(ObstaclesFixes o : ObstaclesFixes.values())
if(!o.bordure && o.getObstacle().isColliding(obs.obstacle))
{
Expand Down
1 change: 1 addition & 0 deletions pc/src/tests/lowlevel/JUnit_AStarCourbe.java
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ public void test_recherche_shoot2() throws Exception
{
Cinematique depart = new Cinematique(-200, 1600, -Math.PI / 3 + Math.PI, true, 0);
robot.setCinematique(depart);
Thread.sleep(100);
Cinematique c = new Cinematique(1000, 1200, Math.PI, false, 0);
astar.initializeNewSearch(c, true, state);
astar.process(chemin,false);
Expand Down

0 comments on commit 43de62a

Please sign in to comment.