<commit_before>PF.BaseFinder = function() {
    
};

PF.BaseFinder.prototype.init = function(startX, startY, endX, endY, grid) {
    this.startX = startX;
    this.startY = startY;
    this.endX = endX;
    this.endY = endY;
    this.grid = grid;

    this.gridHeight = grid.numCols;
    this.gridWidth = grid.numRows;
};

PF.BaseFinder.prototype.isValidPos = function(x, y) {
    return this.grid.isValidPos(x, y);
};

PF.BaseFinder.prototype.setWalkable = function(x, y, walkable) {
    this.grid.setWalkable(x, y, walkable);
};

PF.BaseFinder.constructor = PF.BaseFinder;<commit_msg>add: doc to core/BaseFinder.js<commit_after>/**
 * A base class for path-finders.
 * This class *SHOULD NOT* be directly instantiated, as it does not provide 
 * any path-finding algorithms or methods and is intended to be extended 
 * by all the other path-finder classes.
 *
 * *Note*: The constructor does *NOT* receive any arguments for instantiation.
 *     All the parameters should be passed in in the {@code init} method.
 *     Therefore, you only need to instantiate this class once, and call
 *     the {@code init} method each time you changed the coordinates or grid
 *     status for a new path-finding scenario. 
 *
 * @constructor
 */
PF.BaseFinder = function() {
    this.startX = null; // avoids to be garbage collected
    this.startY = null;
    this.endX = null;
    this.endY = null;
    this.grid = null;

    this.gridHeight = null;
    this.gridWidth = null;
};

/**
 * Initiate the path-finder by providing the coordinates and the grid.
 * @param {integer} startX The x coordinate of the start position.
 * @param {integer} startY The y coordinate of the start position.
 * @param {integer} endX The x coordinate of the end position.
 * @param {integer} endY The y coordinate of the end position.
 */
PF.BaseFinder.prototype.init = function(startX, startY, endX, endY, grid) {
    this.startX = startX;
    this.startY = startY;
    this.endX = endX;
    this.endY = endY;
    this.grid = grid;

    this.gridWidth = grid.numCols;
    this.gridHeight = grid.numRows;
};

/**
 * Determine whether the given postition is inside the grid.
 * @param {integer} x The x coordinate of the position.
 * @param {integer} y The y coordinate of the position.
 * @return {boolean} Whether it is inside.
 */
PF.BaseFinder.prototype.isInsideGrid = function(x, y) {
    // delegates to grid.
    return this.grid.isInside(x, y);
};

/**
 * Set the walkable attribute of the given position on the grid.
 * @param {integer} x The x coordinate of the position.
 * @param {integer} y The y coordinate of the position.
 */
PF.BaseFinder.prototype.setWalkable = function(x, y, walkable) {
    // delegates to grid.
    this.grid.setWalkable(x, y, walkable);
};

/**
 * The constructor of each BaseFinder instance.
 */
PF.BaseFinder.prototype.constructor = PF.BaseFinder;
{'fraction_non_alphanumeric': 0.1118490038448095, 'fraction_numerical': 0.0, 'mean_word_length': 3.2972972972972974, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3063239', 'n_tokens_mistral': 901, 'n_tokens_neox': 895, 'n_words': 306}