{"size": 743, "ext": "js", "max_stars_repo_path": "examples/randomSmart.js", "max_stars_repo_name": "blaumeise20/global-azure-2021-battleship", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples/randomSmart.js", "max_issues_repo_name": "blaumeise20/global-azure-2021-battleship", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/randomSmart.js", "max_forks_repo_name": "blaumeise20/global-azure-2021-battleship", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.3043478261, "max_line_length": 144, "alphanum_fraction": 0.6056527591}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const __1 = require("..");
class RandomPlayer extends __1.Player {
    constructor() {
        super(...arguments);
        this.triedFields = [];
    }
    getNextShot() {
        if (this.triedFields.length) {
            return this.triedFields.pop();
        }
        const val = Math.floor(Math.random() * this.board.unknownCells.length);
        return this.board.unknownCells[val];
    }
    registerShotContent(cell) {
        if (cell.is(__1.CellState.Ship)) {
            this.triedFields.push(...cell.neighbours().filter(n => this.board.unknownCells.includes(n) && !this.triedFields.find(x => x == n)));
        }
    }
}
exports.default = RandomPlayer;
