Newer
Older
package model;
import util.Position;
import java.util.*;
public class FirefighterManager {
private List<Position> firefighterPositions;
private FirefighterMovementStrategy movementStrategy;
public FirefighterManager(FirefighterMovementStrategy movementStrategy) {
this.movementStrategy = movementStrategy;
firefighterPositions = new ArrayList<>();
public void initializeFireFightersPositions(int count, int rowCount, int columnCount, Random random) {
firefighterPositions.add(new Position(random.nextInt(rowCount), random.nextInt(columnCount)));
public List<Position> moveFireFighters(Set<Position> firePositions, Map<Position, List<Position>> neighbors,List<Position> firefighterPositions) {
List<Position> modifiedPositions = new ArrayList<>();
for (Position firefighterPosition : firefighterPositions) {
// Move firefighters towards the nearest fire
Position newPosition = movementStrategy.moveToClosestFire(firefighterPosition, firePositions, neighbors);
System.out.println(newPosition);
System.out.println(firefighterPosition);
modifiedPositions.add(newPosition); // Track the new firefighter position
firefighterPositions.clear();
firefighterPositions = modifiedPositions; // Update the firefighter positions list with new positions
public List<Position> getFirefighterPositions() {
return firefighterPositions;