diff --git a/src/main/java/ch/zhaw/pm2/racetrack/strategy/PathFinderStrategy.java b/src/main/java/ch/zhaw/pm2/racetrack/strategy/PathFinderStrategy.java new file mode 100644 index 0000000..084e690 --- /dev/null +++ b/src/main/java/ch/zhaw/pm2/racetrack/strategy/PathFinderStrategy.java @@ -0,0 +1,76 @@ +package ch.zhaw.pm2.racetrack.strategy; + +import ch.zhaw.pm2.racetrack.PositionVector; +import ch.zhaw.pm2.racetrack.Track; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +public class PathFinderStrategy implements MoveStrategy{ + private ArrayList possiblePaths; + private Track track; + List directions = Arrays.asList(PositionVector.Direction.values()); + + public PathFinderStrategy(Track track, int carIndex) { + this.track = track; + possiblePaths = new ArrayList<>(); + } + + private void test(){ + ArrayList temporary = new ArrayList<>(); + Iterator it = possiblePaths.iterator(); + while(it.hasNext()) { + tryOutPaths current = it.next(); + if (!current.isFeasible()) { + it.remove(); + } + else { + for (PositionVector.Direction direction : directions) { + temporary.add(current); + temporary.get(temporary.size() - 1).takeDirection(direction); + } + } + } + //ab hier zu löschen + for (tryOutPaths paths : possiblePaths){ + for (PositionVector.Direction direction : directions) { + temporary.add(paths); + temporary.get(temporary.size() - 1).takeDirection(direction); + } + } + //bis hier löschen + possiblePaths.clear(); + possiblePaths.addAll(temporary); + } + + @Override + public PositionVector.Direction nextMove() { + return null; + } + public class tryOutPaths { + ArrayList directionsTaken = new ArrayList<>(); + PositionVector currentPosition; + Track track; + private boolean feasible; + private boolean finished; + public tryOutPaths(Track track){ + this.track = track; + } + public boolean isFeasible(){ + return feasible; + } + public void takeDirection(PositionVector.Direction direction) { + if(directionsTaken.size() >= 50){ + feasible = false; + } + else if(finished){ + } + else { + //check if possible eventuell hier?? + directionsTaken.add(direction); + } + } + } +}