public class PacmanState {

    private char[][] board;
    private Position pacmanPosition;

    private Position[] ghostPositions;

    private int score = 0;

    public PacmanState(String board) {
        board = board.strip();
        String[] lines = board.split("\n");
        this.board = new char[lines.length][lines[0].strip().length()];
        ArrayList<Position> tempGhosts = new ArrayList<>();
        for (int i = 0; i < lines.length; i++) {
            String line = lines[i].strip();
            for (int j = 0; j < line.length(); j++) {
                if (line.charAt(j) == 'P') {
                    this.pacmanPosition = new Position(i, j);
                    this.board[i][j] = ' ';
                } else if (line.charAt(j) == 'G') {
                    tempGhosts.add(new Position(i, j));
                    this.board[i][j] = ' ';
                } else {
                    this.board[i][j] = line.charAt(j);
                }
            }
        }
        this.ghostPositions = new Position[tempGhosts.size()];
        tempGhosts.toArray(this.ghostPositions);
    }

    public PacmanState(char[][] board, Position pacmanPosition) {
        this.board = board;
        this.pacmanPosition = pacmanPosition;
        this.ghostPositions = new Position[0];
    }

    public PacmanState(char[][] board, Position pacmanPosition, Position[] ghostPositions) {
        this.board = board;
        this.pacmanPosition = pacmanPosition;
        this.ghostPositions = ghostPositions;
    }
}