<commit_before>import libtcodpy as libtcod

import algebra
from components import *
import ai
import actions
import miscellany


def _insert(creature, new_map):
    new_map.objects.append(creature)
    creature.current_map = new_map


def _ignoring_monster(new_map, pos, player, glyph, name, color, hp=12, unarmed_damage=2):
    creature = Object(pos, glyph, name, color, blocks=True,
        fighter=Fighter(hp=hp, unarmed_damage=unarmed_damage, death_function=ai.monster_death),
        ai=AI(ai.ignoring_monster, None))
    _insert(creature, new_map)
    return creature


def _hostile_monster(new_map, pos, player, glyph, name, color, hp=12, unarmed_damage=2, skills={}):
    creature = Object(pos, glyph, name, color, blocks=True,
        fighter=Fighter(hp=hp, unarmed_damage=unarmed_damage, death_function=ai.monster_death,
                        skills=skills),
        ai=AI(ai.hostile_monster, ai.hostile_monster_metadata(player)))
    _insert(creature, new_map)
    return creature


def _territorial_monster(new_map, pos, player, glyph, name, color, hp=12, unarmed_damage=2, skills={}, radius=3):
    creature = Object(pos, glyph, name, color, blocks=True,
        fighter=Fighter(hp=hp, unarmed_damage=unarmed_damage, death_function=ai.monster_death,
                        skills=skills),
        ai=AI(ai.territorial_monster, ai.territorial_monster_metadata(pos, radius)))
    _insert(creature, new_map)
    return creature


def _add_inventory(creature):
    creature.inventory = []
    return creature


def bandit(new_map, pos, player):
    return _add_inventory(
        _hostile_monster(new_map, pos, player,
                         'p', 'bandit', libtcod.blue, hp=24,
                         skills={'grappling':30, 'sword':30, 'spear':30, 'bow':30, 'shield':20}))

def ghul(new_map, pos, player):
    return _hostile_monster(new_map, pos, player,
                            'z', 'ghul', libtcod.dark_orange, hp=30, unarmed_damage=4,
                            skills={'grappling':30})

def slime(new_map, pos, player):<commit_msg>Increase safety of monster generation<commit_after>import libtcodpy as libtcod

import algebra
from components import *
import ai
import actions
import miscellany


def _insert(creature, new_map):
    new_map.objects.append(creature)
    creature.current_map = new_map


def _ignoring_monster(new_map, pos, player, glyph, name, color, hp=12, unarmed_damage=2):
    pos.bound(new_map.loc_bound)
    creature = Object(pos, glyph, name, color, blocks=True,
        fighter=Fighter(hp=hp, unarmed_damage=unarmed_damage, death_function=ai.monster_death),
        ai=AI(ai.ignoring_monster, None))
    _insert(creature, new_map)
    return creature


def _hostile_monster(new_map, pos, player, glyph, name, color, hp=12, unarmed_damage=2, skills={}):
    pos.bound(new_map.loc_bound)
    creature = Object(pos, glyph, name, color, blocks=True,
        fighter=Fighter(hp=hp, unarmed_damage=unarmed_damage, death_function=ai.monster_death,
                        skills=skills),
        ai=AI(ai.hostile_monster, ai.hostile_monster_metadata(player)))
    _insert(creature, new_map)
    return creature


def _territorial_monster(new_map, pos, player, glyph, name, color, hp=12, unarmed_damage=2, skills={}, radius=3):
    pos.bound(new_map.loc_bound)
    creature = Object(pos, glyph, name, color, blocks=True,
        fighter=Fighter(hp=hp, unarmed_damage=unarmed_damage, death_function=ai.monster_death,
                        skills=skills),
        ai=AI(ai.territorial_monster, ai.territorial_monster_metadata(pos, radius)))
    _insert(creature, new_map)
    return creature


def _add_inventory(creature):
    creature.inventory = []
    return creature


def bandit(new_map, pos, player):
    return _add_inventory(
        _hostile_monster(new_map, pos, player,
                         'p', 'bandit', libtcod.blue, hp=24,
                         skills={'grappling':30, 'sword':30, 'spear':30, 'bow':30, 'shield':20}))

def ghul(new_map, pos, player):
    return _hostile_monster(new_map, pos, player,
                            'z', 'ghul', libtcod.dark_orange, hp=30, unarmed_damage=4,
                            skills={'grappling':30})

def slime(new_map, pos, player):
{'fraction_non_alphanumeric': 0.11417787213965558, 'fraction_numerical': 0.012738853503184714, 'mean_word_length': 3.62882096069869, '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': '1586691', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1455, 'n_words': 286}