Strategy #31

Merged
schrom01 merged 24 commits from Strategy into main 2022-03-25 09:24:21 +01:00
1 changed files with 11 additions and 2 deletions
Showing only changes of commit 6403ee958f - Show all commits

View File

@ -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;
}
}
}