<commit_before>package com.gamefreezer.galaga;

public class Controller extends AllocGuard {

    private Screen screen;
    private int staySolo;

    public Controller(Screen screen, int staySolo) {
	super();
	this.screen = screen;
	this.staySolo = staySolo;
    }

    public void adjust(int delta, Alien alien, Location target) {
	if (atLeftEdge(alien) || atRightEdge(alien)) {
	    alien.flip(); // change direction
	}
	if (readyForTarget(alien, target)) {
	    alien.setTarget(target);
	} else if (alien.targetting()) {
	    alien.setTarget(target);
	    alien.move(delta);
	    int epsilon = 10;
	    if (nearEnoughToTarget(alien, target, epsilon)) {
		alien.moveTo(target);
		alien.setTarget(-1, -1);
		alien.setSolo(false);
		alien.setDiveComplete(false);
	    }
	} else {
	    alien.move(delta);
	}
    }

    private boolean nearEnoughToTarget(Alien alien, Location target, int epsilon) {
	return Math.abs(target.getXAsFloat() - alien.getXAsFloat()) < epsilon
		&& Math.abs(target.getYAsFloat() - alien.getYAsFloat()) < epsilon;
    }

    private boolean readyForTarget(Alien alien, Location target) {
	return alien.diveComplete && !alien.targetting()
		&& target.getYAsFloat() > staySolo;
    }

    private boolean atRightEdge(Alien alien) {
	return screen.inGameRight() == alien.rightEdge();
    }

    private boolean atLeftEdge(Alien alien) {
	return screen.inGameLeft() == alien.getX();
    }
}<commit_msg>fixed stay solo to reflect y=0 at top screen<commit_after>package com.gamefreezer.galaga;

public class Controller extends AllocGuard {

    private Screen screen;
    private int staySolo;

    public Controller(Screen screen, int staySolo) {
	super();
	this.screen = screen;
	this.staySolo = staySolo;
    }

    public void adjust(int delta, Alien alien, Location target) {
	if (atLeftEdge(alien) || atRightEdge(alien)) {
	    alien.flip(); // change direction
	}
	if (readyForTarget(alien, target)) {
	    alien.setTarget(target);
	} else if (alien.targetting()) {
	    alien.setTarget(target);
	    alien.move(delta);
	    int epsilon = 10;
	    if (nearEnoughToTarget(alien, target, epsilon)) {
		alien.moveTo(target);
		alien.setTarget(-1, -1);
		alien.setSolo(false);
		alien.setDiveComplete(false);
	    }
	} else {
	    alien.move(delta);
	}
    }

    private boolean nearEnoughToTarget(Alien alien, Location target, int epsilon) {
	return Math.abs(target.getXAsFloat() - alien.getXAsFloat()) < epsilon
		&& Math.abs(target.getYAsFloat() - alien.getYAsFloat()) < epsilon;
    }

    private boolean readyForTarget(Alien alien, Location target) {
	return alien.diveComplete && !alien.targetting()
		&& target.getYAsFloat() < staySolo;
    }

    private boolean atRightEdge(Alien alien) {
	return screen.inGameRight() == alien.rightEdge();
    }

    private boolean atLeftEdge(Alien alien) {
	return screen.inGameLeft() == alien.getX();
    }
}
{'fraction_non_alphanumeric': 0.12747481764501564, 'fraction_numerical': 0.003126085446335533, 'mean_word_length': 3.729064039408867, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 4, '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': '4543715', 'n_tokens_mistral': 1003, 'n_tokens_neox': 957, 'n_words': 208}