<commit_before>/**
 * An abstract class for all smellable objects.
 */
class SmellableObject extends Collider {
	
	/**
	* Creates a smellable object
	* @constructor
	* @abstract
	* @param {object} canvas - The canvas used to draw.
    * @param {object} position - 2D position of where the object shall be created (if no collision occurs).
    * @param {number} size - Size of the objects collider.
    * @param {number} sizeSmellingFactor - Size of the objects smell.
    * @param {Objects[]} collisionObjs - Objects in simulation that can collide with this.
    * @param {number} [rotation=0]rotation - ID of the ants hive.
	*/
	constructor(canvas, position, size, sizeSmellingFactor, collisionObjs, rotation = 0){
		if (new.target === SmellableObject) {
			throw new TypeError("Cannot construct SmellableObject instances directly");
		}
		super(canvas, position, ShapeType.CIRCLE, size, rotation, collisionObjs);
		this.sizeSmellingFactor = sizeSmellingFactor;
	}

	getSmellDistance(){
		var smellingDistance = this.getSize() * this.sizeSmellingFactor;
		return smellingDistance;
	}
	
	canBeSmelledBy(ant)
	{
		var distance = getDistance(this.getPosition(), ant.getPosition());
		return (distance - this.getSmellDistance() - ant.getSmellingDistance() <= 0);
	}
	
	smellPositionFrom(ant)
	{
		if (!this.canBeSmelledBy(ant)){
			// should not be able to smell it.... did someone cheat here?!
			return math.matrix([rand(-1000,1000), rand(-1000,1000)])
		}
		
		var distance = getDistance(this.getPosition(), ant.getPosition());
		// [0, 1] <-> [1/4 smellingDistance, smellingDistance+smellDistance] 
		var farthest = ant.getSmellingDistance() + this.getSmellDistance();
		var nearest  = ant.getSmellingDistance()/4;
		// [0,1]
		var smellPos = {x: this.getPosition().x, y:this.getPosition().y }; // clone position
		if (distance > nearest){
			var percentage = distance / (farthest-nearest);
			var smellPosDist = percentage * this.getSmellDistance(); // distance from actual position
			var addVec = rotateVector({x: smellPosDist, y:0}, rand(0, Math.PI*2));<commit_msg>- changed smell position distance to square<commit_after>/**
 * An abstract class for all smellable objects.
 */
class SmellableObject extends Collider {
	
	/**
	* Creates a smellable object
	* @constructor
	* @abstract
	* @param {object} canvas - The canvas used to draw.
    * @param {object} position - 2D position of where the object shall be created (if no collision occurs).
    * @param {number} size - Size of the objects collider.
    * @param {number} sizeSmellingFactor - Size of the objects smell.
    * @param {Objects[]} collisionObjs - Objects in simulation that can collide with this.
    * @param {number} [rotation=0]rotation - ID of the ants hive.
	*/
	constructor(canvas, position, size, sizeSmellingFactor, collisionObjs, rotation = 0){
		if (new.target === SmellableObject) {
			throw new TypeError("Cannot construct SmellableObject instances directly");
		}
		super(canvas, position, ShapeType.CIRCLE, size, rotation, collisionObjs);
		this.sizeSmellingFactor = sizeSmellingFactor;
	}

	getSmellDistance(){
		var smellingDistance = this.getSize() * this.sizeSmellingFactor;
		return smellingDistance;
	}
	
	canBeSmelledBy(ant)
	{
		var distance = getDistance(this.getPosition(), ant.getPosition());
		return (distance - this.getSmellDistance() - ant.getSmellingDistance() <= 0);
	}
	
	smellPositionFrom(ant)
	{
		if (!this.canBeSmelledBy(ant)){
			// should not be able to smell it.... did someone cheat here?!
			return math.matrix([rand(-1000,1000), rand(-1000,1000)])
		}
		
		var distance = getDistance(this.getPosition(), ant.getPosition());
		// [0, 1] <-> [0, smellingDistance+smellDistance] 
		var farthest = ant.getSmellingDistance() + this.getSmellDistance();
		var nearest  = 0;
		// [0,1]
		var smellPos = {x: this.getPosition().x, y:this.getPosition().y }; // clone position
		if (distance > nearest){
			var percentage = distance / (farthest-nearest);
			var smellPosDist = percentage * percentage * this.getSmellDistance(); // distance from actual position
			var addVec = rotateVector({x: smellPosDist, y:0}, rand(0, Math.PI*2));
{'fraction_non_alphanumeric': 0.1278395360077332, 'fraction_numerical': 0.014258095698405027, 'mean_word_length': 4.148009950248756, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1739200', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1244, 'n_words': 369}