<commit_before>package shooting.example.examplestage;

import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import shooting.core.*;

/// AĨTv
public class ExampleAI extends Player {
	public static final int DEFAULT_WIDTH = 30;	///< ftHg̕
	public static final int DEFAULT_HEIGHT = 30;	///< ftHg̍
	public static final int MAX_DAMAGE = 100;	///< ő_[W
	/// ̎擾
	/// @return 
	public int getWidth() { return getImage() != null ? getImage().getWidth(null) : DEFAULT_WIDTH; }
	/// ̎擾
	/// @return 
	public int getHeight() { return getImage() != null ? getImage().getHeight(null) : DEFAULT_HEIGHT; }
	/// ő_[W̎擾
	/// @return ő_[W
	public int getMaxDamage() { return MAX_DAMAGE; }
	private Weapon subWeapon;	///< Player.weaponƂ͕ʂWeapon

	/// RXgN^
	/// @param shooting ShootingNX̃IuWFNg
	/// @param team `[ԍ
	/// @param x zu鍶ォXW
	/// @param y zu鍶ォYW
	/// @param sx ˂̕EXW
	/// @param sy ˂̕EYW
	public ExampleAI(Shooting shooting, int team, int x, int y, int sx, int sy) {
		this(shooting, null, team, x, y, sx, sy);
	}

	/// RXgN^
	/// @param shooting ShootingNX̃IuWFNg
	/// @param image @̂̉摜
	/// @param team `[ԍ
	/// @param x zu鍶ォXW
	/// @param y zu鍶ォYW
	/// @param sx ˂̕EXW
	/// @param sy ˂̕EYW
	public ExampleAI(Shooting shooting, Image image, int team, int x, int y, int sx, int sy) {
		super(shooting, team, x, y, sx, sy);
		setImage(image);
		setWeapon(new ExampleWeapon(this));
		setMovingX(1);
		subWeapon = new DefaultWeapon(this);
	}

	/// C[vĂ΂鏈
	///
	/// ł͈ړƃ[U̔ˏsĂ
	public void runMainLoopJob() {
		// subWeapon͌Ă鎞͖񌂂
		subWeapon.shoot();
		if (getWeapon().isCharged()) {
			// WeapongpłꍇAGAI_ʒuɂ邩𔻒fĂ猂
			for (Player player : getShooting().getPlayers()) {
				if (player.getTeam() != this.getTeam()) {
					int shootxpos = this.getX() + this.getWidth()/2;
					if (player.getMovingX() > 0) {
						// EɈړĂꍇ̕␳
						shootxpos -= 50;
					} else if (player.getMovingX() < 0) {
						// ɈړĂꍇ̕␳
						shootxpos += 50;
					}
					if (shootxpos >= player.getX() && shootxpos <= player.getX()+player.getWidth()) {
						getWeapon().shoot();
					}
				}
			}
		}

		// 1/400̊mŕ]
		if ((int)(Math.random()*400) == 0) {
			setMovingX(-getMovingX());
		}

		for (Lazer lazer : getShooting().getLazers()) {
			if (lazer.getPlayer().getTeam() != this.getTeam()) {
				// 100pxȓɓGLazer߂ÂĂĂ悤Ƃ
				if (lazer.getY()-(getY()+getHeight()) <= 100) {
					if (lazer.getX() >= this.getX()-20 && lazer.getX()+lazer.getWidth() <= this.getX()+this.getWidth()+20) {
						setMovingX(lazer.getX() < this.getCenterX() ? 1 : -1);
					}
				}
			}
		}

		// ȏ㍡̌֐i߂ȂȂ]
		if (!canMoveTo(getX()+getMovingX(), getY(), getWidth(), getHeight())) {
			setMovingX(-getMovingX());
		}
		setX(getX()+getMovingX());
	}
}
<commit_msg>Improve ExampleAI<commit_after>package shooting.example.examplestage;

import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import shooting.core.*;

/// AĨTv
public class ExampleAI extends Player {
	public static final int DEFAULT_WIDTH = 30;	///< ftHg̕
	public static final int DEFAULT_HEIGHT = 30;	///< ftHg̍
	public static final int MAX_DAMAGE = 100;	///< ő_[W
	/// ̎擾
	/// @return 
	public int getWidth() { return getImage() != null ? getImage().getWidth(null) : DEFAULT_WIDTH; }
	/// ̎擾
	/// @return 
	public int getHeight() { return getImage() != null ? getImage().getHeight(null) : DEFAULT_HEIGHT; }
	/// ő_[W̎擾
	/// @return ő_[W
	public int getMaxDamage() { return MAX_DAMAGE; }
	private Weapon subWeapon;	///< Player.weaponƂ͕ʂWeapon

	/// RXgN^
	/// @param shooting ShootingNX̃IuWFNg
	/// @param team `[ԍ
	/// @param x zu鍶ォXW
	/// @param y zu鍶ォYW
	/// @param sx ˂̕EXW
	/// @param sy ˂̕EYW
	public ExampleAI(Shooting shooting, int team, int x, int y, int sx, int sy) {
		this(shooting, null, team, x, y, sx, sy);
	}

	/// RXgN^
	/// @param shooting ShootingNX̃IuWFNg
	/// @param image @̂̉摜
	/// @param team `[ԍ
	/// @param x zu鍶ォXW
	/// @param y zu鍶ォYW
	/// @param sx ˂̕EXW
	/// @param sy ˂̕EYW
	public ExampleAI(Shooting shooting, Image image, int team, int x, int y, int sx, int sy) {
		super(shooting, team, x, y, sx, sy);
		setImage(image);
		setWeapon(new ExampleWeapon(this));
		setMovingX(1);
		subWeapon = new DefaultWeapon(this);
	}

	/// C[vĂ΂鏈
	///
	/// ł͈ړƃ[U̔ˏsĂ
	public void runMainLoopJob() {
		// subWeapon͌Ă鎞͖񌂂
		subWeapon.shoot();
		if (getWeapon().isCharged()) {
			// WeapongpłꍇAGAI_ʒuɂ邩𔻒fĂ猂
			for (Player player : getShooting().getPlayers()) {
				if (player.getTeam() != this.getTeam()) {
					int shootxpos = this.getX() + this.getWidth()/2;
					if (player.getMovingX() > 0) {
						// EɈړĂꍇ̕␳
						shootxpos -= 50;
					} else if (player.getMovingX() < 0) {
						// ɈړĂꍇ̕␳
						shootxpos += 50;
					}
					if (shootxpos >= player.getX() && shootxpos <= player.getX()+player.getWidth()) {
						getWeapon().shoot();
					}
				}
			}
		}

		// 1/400̊mŕ]
		if ((int)(Math.random()*400) == 0) {
			setMovingX(-getMovingX());
		}

		boolean nearlazer = false;
		for (Lazer lazer : getShooting().getLazers()) {
			if (lazer.getPlayer().getTeam() != this.getTeam()) {
				// 100pxȓɓGLazer߂ÂĂĂ悤Ƃ
				if (lazer.getY()-(getY()+getHeight()) <= 100) {
					if (lazer.getX() >= this.getX()-20 && lazer.getX()+lazer.getWidth() <= this.getX()+this.getWidth()+20) {
						setMovingX(lazer.getX() < this.getCenterX() ? 1 : -1);
						nearlazer = true;
					}
				}
			}
		}
		if (!nearlazer) {
			// Lazerɂ肻ł͂Ȃ̂œKȓGɋ߂ÂƂ
			for (Player player : getShooting().getPlayers()) {
				if (player.getTeam() != this.getTeam()) {
					setMovingX(player.getCenterX() < this.getCenterX() ? -1 : 1);
					break;
				}
			}
		}

		// ȏ㍡̌֐i߂ȂȂ]
		if (!canMoveTo(getX()+getMovingX(), getY(), getWidth(), getHeight())) {
			setMovingX(-getMovingX());
		}
		setX(getX()+getMovingX());
	}
}

{'fraction_non_alphanumeric': 0.19395728425073797, 'fraction_numerical': 0.013370376801528043, 'mean_word_length': 2.9263803680981595, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 9, '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': '5821431', 'n_tokens_mistral': 2898, 'n_tokens_neox': 2534, 'n_words': 487}