Search in sources :

Example 1 with GroupId

use of bwem.area.typedef.GroupId in project BWAPI4J by OpenBW.

the class Graph method updateGroupIds.

private void updateGroupIds() {
    int nextGroupId = 1;
    AreaInitializerImpl.getStaticMarkable().unmarkAll();
    for (final Area start : getAreas()) {
        if (!((AreaInitializer) start).getMarkable().isMarked()) {
            final List<Area> toVisit = new ArrayList<>();
            toVisit.add(start);
            while (!toVisit.isEmpty()) {
                final Area current = toVisit.remove(toVisit.size() - 1);
                ((AreaInitializer) current).setGroupId(new GroupId(nextGroupId));
                for (final Area next : current.getAccessibleNeighbors()) {
                    if (!((AreaInitializer) next).getMarkable().isMarked()) {
                        ((AreaInitializer) next).getMarkable().setMarked();
                        toVisit.add(next);
                    }
                }
            }
            ++nextGroupId;
        }
    }
}
Also used : Area(bwem.area.Area) AreaInitializer(bwem.area.AreaInitializer) ArrayList(java.util.ArrayList) GroupId(bwem.area.typedef.GroupId)

Aggregations

Area (bwem.area.Area)1 AreaInitializer (bwem.area.AreaInitializer)1 GroupId (bwem.area.typedef.GroupId)1 ArrayList (java.util.ArrayList)1