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(){
|
private void test(){
|
||||||
ArrayList<tryOutPaths> temporary = new ArrayList<>();
|
ArrayList<tryOutPaths> temporary = new ArrayList<>();
|
||||||
Iterator<tryOutPaths> it = possiblePaths.iterator();
|
Iterator<tryOutPaths> it = possiblePaths.iterator();
|
||||||
|
|
||||||
while(it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
tryOutPaths current = it.next();
|
tryOutPaths current = it.next();
|
||||||
if (!current.isFeasible()) {
|
if (!current.isFeasible()) {
|
||||||
|
@ -29,7 +30,9 @@ public class PathFinderStrategy implements MoveStrategy{
|
||||||
else {
|
else {
|
||||||
for (PositionVector.Direction direction : directions) {
|
for (PositionVector.Direction direction : directions) {
|
||||||
temporary.add(current);
|
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() {
|
public PositionVector.Direction nextMove() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class tryOutPaths {
|
public class tryOutPaths {
|
||||||
ArrayList<PositionVector.Direction> directionsTaken = new ArrayList<>();
|
ArrayList<PositionVector.Direction> directionsTaken = new ArrayList<>();
|
||||||
PositionVector currentPosition;
|
PositionVector currentPosition;
|
||||||
|
@ -58,18 +62,23 @@ public class PathFinderStrategy implements MoveStrategy{
|
||||||
public tryOutPaths(Track track){
|
public tryOutPaths(Track track){
|
||||||
this.track = track;
|
this.track = track;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFeasible(){
|
public boolean isFeasible(){
|
||||||
return feasible;
|
return feasible;
|
||||||
}
|
}
|
||||||
public void takeDirection(PositionVector.Direction direction) {
|
|
||||||
|
public boolean takeDirection(PositionVector.Direction direction) {
|
||||||
if(directionsTaken.size() >= 50){
|
if(directionsTaken.size() >= 50){
|
||||||
feasible = false;
|
feasible = false;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else if(finished){
|
else if(finished){
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//check if possible eventuell hier??
|
//check if possible eventuell hier??
|
||||||
directionsTaken.add(direction);
|
directionsTaken.add(direction);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue