Merge remote-tracking branch 'origin/Strategy' into Strategy
This commit is contained in:
commit
6403ee958f
|
@ -21,6 +21,7 @@ public class PathFinderStrategy implements MoveStrategy{
|
|||
private void test(){
|
||||
ArrayList<tryOutPaths> temporary = new ArrayList<>();
|
||||
Iterator<tryOutPaths> it = possiblePaths.iterator();
|
||||
|
||||
while(it.hasNext()) {
|
||||
tryOutPaths current = it.next();
|
||||
if (!current.isFeasible()) {
|
||||
|
@ -29,7 +30,9 @@ public class PathFinderStrategy implements MoveStrategy{
|
|||
else {
|
||||
for (PositionVector.Direction direction : directions) {
|
||||
temporary.add(current);
|
||||
temporary.get(temporary.size() - 1).takeDirection(direction);
|
||||
if (temporary.get(temporary.size() - 1).takeDirection(direction)){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +52,7 @@ public class PathFinderStrategy implements MoveStrategy{
|
|||
public PositionVector.Direction nextMove() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public class tryOutPaths {
|
||||
ArrayList<PositionVector.Direction> directionsTaken = new ArrayList<>();
|
||||
PositionVector currentPosition;
|
||||
|
@ -58,18 +62,23 @@ public class PathFinderStrategy implements MoveStrategy{
|
|||
public tryOutPaths(Track track){
|
||||
this.track = track;
|
||||
}
|
||||
|
||||
public boolean isFeasible(){
|
||||
return feasible;
|
||||
}
|
||||
public void takeDirection(PositionVector.Direction direction) {
|
||||
|
||||
public boolean takeDirection(PositionVector.Direction direction) {
|
||||
if(directionsTaken.size() >= 50){
|
||||
feasible = false;
|
||||
return false;
|
||||
}
|
||||
else if(finished){
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
//check if possible eventuell hier??
|
||||
directionsTaken.add(direction);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue