<commit_before>var utils = require('../lib/utils.js');

var enemies = {}

module.exports = {
    info: {
        name: 'Ψ',
        style: 3
    },
    ai: (playerState, enemiesStates, gameEnvironment) => { /* Siegfried */
        var directionToAmmo;

        if (utils.canKill(playerState, enemiesStates) && playerState.ammo) {
            return 'shoot';
        }

        if (gameEnvironment.ammoPosition.length) {

            var closestAmmo = findClosestAmmo(gameEnvironment.ammoPosition);

            // if (playerState.ammo < 1) {
                directionToAmmo = utils.fastGetDirection(playerState.position, closestAmmo);
                if (directionToAmmo !== playerState.direction) return directionToAmmo;
                return 'move';
            // } else {
            //     directionToAmmo = utils.fastGetDirection(playerState.position, closestAmmo);
            //     if (closestAmmo[0] === playerState.position[0] || closestAmmo[1] === playerState.position[1]) {
            //         if (directionToAmmo !== playerState.direction) return directionToAmmo;
            //     }
            // }
            //
            // if (playerState.ammo > 2) {
            //
            // }
        }

        return utils.safeRandomMove();

        function findClosestAmmo(ammos) {
            var min = 0;
            ammos.forEach((a, i) => {
                if (utils.getDistance(playerState.position, a) < utils.getDistance(playerState.position, ammos[min])) {
                    min = i;
                }
            });
            return ammos[min];
        }
    }
};<commit_msg>next iteration<commit_after>var utils = require('../lib/utils.js');

var enemies = {};

module.exports = {
    info: {
        name: 'Ψ',
        style: 3
    },
    ai: (playerState, enemiesStates, gameEnvironment) => { /* Siegfried */
        var directionToAmmo;

        if (utils.canKill(playerState, enemiesStates) && playerState.ammo) {
            return 'shoot';
        }

        if (gameEnvironment.ammoPosition.length) {

            var closestAmmo = findClosestAmmo(gameEnvironment.ammoPosition);

            if (playerState.ammo === 0) {
                directionToAmmo = utils.fastGetDirection(playerState.position, closestAmmo);
                if (directionToAmmo !== playerState.direction) return directionToAmmo;
                return 'move';
            }
            //     directionToAmmo = utils.fastGetDirection(playerState.position, closestAmmo);
            //     if (closestAmmo[0] === playerState.position[0] || closestAmmo[1] === playerState.position[1]) {
            //         if (directionToAmmo !== playerState.direction) return directionToAmmo;
            //     }
            // }
            //
            var dir = utils.fastGetDirection(playerState.position, fx());
            if (dir !== playerState.direction) return dir;
            return 'move';

        }


        return utils.safeRandomMove();

        function findClosestAmmo(ammos) {
            var min = 0;
            ammos.forEach((a, i) => {
                if (utils.getDistance(playerState.position, a) < utils.getDistance(playerState.position, ammos[min])) {
                    min = i;
                }
            });
            return ammos[min];
        }

        function fx() {
            var min = 0;
            enemiesStates.forEach((e, i) => {
                if (utils.getDistance(playerState.position, e.position) < utils.getDistance(playerState.position, enemiesStates[min].position)) {
                    min = i;
                }
            });
            return enemiesStates[min].position;
        }
    }
};
{'fraction_non_alphanumeric': 0.12319038514067195, 'fraction_numerical': 0.004370390603660202, 'mean_word_length': 1.6710430342815463, 'pattern_counts': {'":': 0, '<': 7, '<?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': '77311', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1027, 'n_words': 178}