You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: ai.rs
    path of file: ./repos/zemeroth/src/core/battle
    
    the code of the file until where you have to start completion: use log::info;

use crate::core::{
    battle::{
        ability::Ability,
        check,
        command::{self, Command},
        effect,
        movement::{self, Path, Pathfinder},
        state, Id, PlayerId, State,
    },
    map::{self, Distance, HexMap},
    utils::shuffle_vec,
};

fn does_agent_have_ability(state: &State, id: Id, ability: &Abili
    
    fn try_to_move(&mut self, state: &State, agent_id: Id) -> Option<Command> {
        let path_result = if does_agent_have_ability(state, agent_id, &Ability::Summon) {
            let range = DistanceRange {
                min: Distance(2),
                max: Distance(4),
            };
            self.try_to_keep_distance(state, agent_id, range)
        } else if does_agent_have_ability(state, agent_id, &Ability::BombDemonic) {
            let range = DistanceRange {
                min: Distance(1),
                max: Distance(3),
            };
            self.try_to_keep_distance(state, agent_id, range)
        } else {
            self.try_to_move_closer(state, agent_id)
        };
        match path_result {
            PathfindingResult::Path(path) => {
                let command = command::MoveTo { id: agent_id, path }.into();
                if check(state, &command).is_ok() {
                    Some(command)
                } else {
                    None
                }
            }
            PathfindingResult::CantFindPath => self.try_to_find_bad_path(state, agent_id),
            PathfindingResult::DontNeedToMove => None,
        }
    }