Skip to content
Snippets Groups Projects
Commit aecf9ee3 authored by BACHTARZI Imed eddine's avatar BACHTARZI Imed eddine
Browse files

Changed FFboardFiller so no two element are on the same position in the start

parent efe3a934
No related branches found
No related tags found
No related merge requests found
Pipeline #41841 failed
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -20,9 +20,12 @@ public class FFboardFiller { ...@@ -20,9 +20,12 @@ public class FFboardFiller {
Element element; Element element;
Position p; Position p;
do { do {
p=new Position(random.nextInt(boardData.getRowCount()), random.nextInt(boardData.getColumnCount())); p=positions.get(random.nextInt(positions.size()));
element= ve.instanciate(boardData,p); element= ve.instanciate(boardData,p);
}while (!boardData.addElement(element) && positions.contains(element.getPosition())); }while (!boardData.addElement(element));
if (element instanceof ConnexElement) {
positions.removeAll(boardData.getElements().get(element.getType().ordinal()).stream().map(x ->x.getPosition()).toList());
System.out.println("0");}
positions.remove(p); positions.remove(p);
counter[ve.ordinal()]--; counter[ve.ordinal()]--;
} }
......
...@@ -11,6 +11,6 @@ public class Road extends Land implements Element,ConnexElement { ...@@ -11,6 +11,6 @@ public class Road extends Land implements Element,ConnexElement {
@Override @Override
public ElementFactory getFactory() { public ElementFactory getFactory() {
return null; return factory;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment