<commit_before>package spacefront;

import java.awt.Dimension;
import java.util.HashSet;
import java.util.Observable;
import java.util.Queue;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;

public class Spacefront extends Observable implements Runnable {

    private static final Random RNG = new Random();
    private static final long DELAY = 33;
    private static final int SIDE = 600;
    private static final Dimension SIZE = new Dimension(SIDE, SIDE);

    private Set<Meteoroid> meteoroids = new HashSet<Meteoroid>();
    private Set<Shot> shots = new HashSet<Shot>();
    private Set<Debris> debris = new HashSet<Debris>();

    private Queue<SpaceObject> incoming =
        new ConcurrentLinkedQueue<SpaceObject>();
    private Queue<SpaceObject> outgoing =
        new ConcurrentLinkedQueue<SpaceObject>();

    private Planet home = new Planet();

    private Weapon weapon = new BasicWeapon();
    private long lastFire;
    private boolean firing = false;
    private double fireX, fireY;
    private double danger = 0.05;
    private double difficulty = 0.00001;
    private boolean running = false;

    public Spacefront() {
    }

    @Override
    public void run() {
        running = true;
        while (running) {
            synchronized (this) {
                if (firing) {
                    long now = System.currentTimeMillis();
                    long diff = now - lastFire;
                    if (diff >= weapon.getSpeed()) {
                        shots.add(weapon.fire(fireX, fireY));
                        lastFire = now;
                    }
                }

                danger += difficulty;
                if (RNG.nextFloat() < danger) {
                    double d = SIDE / 2d * Math.sqrt(2);
                    double a = RNG.nextDouble() * Math.PI * 2;
                    double x = Math.cos(a) * d;
                    double y = Math.sin(a) * d;
                    meteoroids.add(new Meteoroid(x, y));
                }
                Set<Meteoroid> dead = new HashSet<Meteoroid>();
                Set<Shot> spent = new HashSet<Shot>();
                Set<Debris> old = new HashSet<Debris>();
                for (Debris d : debris) {
                    d.step();
                    if (d.getTTL() <= 0f) {
                        old.add(d);
                    }
                }
                for (Meteoroid m : meteoroids) {
                    if (m.step(home)) {
                        dead.add(m);
                        home.absorb(m);
                    }
                }
                for (Shot s : shots) {
                    Meteoroid m = s.step(this);
                    if (m != null) {
                        dead.add(m);
                        spent.add(s);<commit_msg>Support higher levels of difficulty.<commit_after>package spacefront;

import java.awt.Dimension;
import java.util.HashSet;
import java.util.Observable;
import java.util.Queue;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;

public class Spacefront extends Observable implements Runnable {

    private static final Random RNG = new Random();
    private static final long DELAY = 33;
    private static final int SIDE = 600;
    private static final Dimension SIZE = new Dimension(SIDE, SIDE);

    private Set<Meteoroid> meteoroids = new HashSet<Meteoroid>();
    private Set<Shot> shots = new HashSet<Shot>();
    private Set<Debris> debris = new HashSet<Debris>();

    private Queue<SpaceObject> incoming =
        new ConcurrentLinkedQueue<SpaceObject>();
    private Queue<SpaceObject> outgoing =
        new ConcurrentLinkedQueue<SpaceObject>();

    private Planet home = new Planet();

    private Weapon weapon = new BasicWeapon();
    private long lastFire;
    private boolean firing = false;
    private double fireX, fireY;
    private double danger = 0.05;
    private double difficulty = 0.00001;
    private boolean running = false;

    public Spacefront() {
    }

    @Override
    public void run() {
        running = true;
        while (running) {
            synchronized (this) {
                if (firing) {
                    long now = System.currentTimeMillis();
                    long diff = now - lastFire;
                    if (diff >= weapon.getSpeed()) {
                        shots.add(weapon.fire(fireX, fireY));
                        lastFire = now;
                    }
                }

                danger += difficulty;
                double spawn = danger;
                while (spawn > 0) {
                    if (RNG.nextFloat() < danger) {
                        double d = SIDE / 2d * Math.sqrt(2);
                        double a = RNG.nextDouble() * Math.PI * 2;
                        double x = Math.cos(a) * d;
                        double y = Math.sin(a) * d;
                        meteoroids.add(new Meteoroid(x, y));
                    }
                    spawn -= 1d;
                }
                Set<Meteoroid> dead = new HashSet<Meteoroid>();
                Set<Shot> spent = new HashSet<Shot>();
                Set<Debris> old = new HashSet<Debris>();
                for (Debris d : debris) {
                    d.step();
                    if (d.getTTL() <= 0f) {
                        old.add(d);
                    }
                }
                for (Meteoroid m : meteoroids) {
                    if (m.step(home)) {
                        dead.add(m);
                        home.absorb(m);
                    }
                }
                for (Shot s : shots) {
                    Meteoroid m = s.step(this);
                    if (m != null) {
                        dead.add(m);
                        spent.add(s);
{'fraction_non_alphanumeric': 0.0986060918946825, 'fraction_numerical': 0.006539321975563586, 'mean_word_length': 1.427736006683375, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3721108', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1482, 'n_words': 417}