<commit_before><?php
require_once('lib_log.php');
require_once('maze_utility.php');

/*
 * Nil command, does not execute any steps and returns the current coordinate.
 */
function command_nil($telegram_id, $current_coordinate) {
    return array('', $current_coordinate);
}

function command_safe($telegram_id, $current_coordinate) {
    // TODO
    return command_nil($telegram_id, $current_coordinate);
}

function command_1($telegram_id, $current_coordinate) {
    $target = coordinate_advance($current_coordinate);
    if($target == null) {
        Logger::fatal('Cannot execute command_1 from position (null target)');
    }

    return array(
        'a',
        $target
    );
}

/* Turn right or left (if ahead is not empty) */
function command_2($telegram_id, $current_coordinate) {
    $possible_directions = array();
    $possible_directions_coords = array();

    $c_turned_right = coordinate_turn_right($current_coordinate);
    if(!coordinate_out_ahead($c_turned_right)){
        $possible_directions_coords[]= $c_turned_right;
        $possible_directions[]= 'd';
    }

    $c_turned_left = coordinate_turn_left($current_coordinate);
    if(!coordinate_out_ahead($c_turned_left)){
        $possible_directions_coords[]= $c_turned_left;
        $possible_directions[]= 's';
    }

    if(count($possible_directions) < 1) {
        Logger::fatal('Cannot execute command_2 from position (no valid option)');
    }

    $direction_index = array_rand($possible_directions);

    return array(
        $possible_directions[$direction_index],
        $possible_directions_coords[$direction_index]
    );
}

function command_3($telegram_id, $current_coordinate) {
    return command_1($telegram_id, $current_coordinate);
}

function command_4($telegram_id, $current_coordinate) {
    if(!coordinate_out_ahead(coordinate_turn_left($current_coordinate), 3)) {
        return array(
            'sa',
            coordinate_advance(coordinate_turn_left($current_coordinate))
        );
    }
    else if(!coordinate_out_ahead(coordinate_turn_right($current_coordinate), 3)) {
        return array(
            'da',
            coordinate_advance(coordinate_turn_right($current_coordinate))
        );
    }
    else {
        return command_safe($telegram_id, $current_coordinate);
    }
}

function command_5($telegram_id, $current_coordinate) {
    if(coordinate_out_ahead($current_coordinate, 2)){
        Loger::fatal('Cannot execute command_5 from position (no valid path)');
    }

    return array(<commit_msg>Fix typos<commit_after><?php
require_once('lib_log.php');
require_once('maze_utility.php');

/*
 * Nil command, does not execute any steps and returns the current coordinate.
 */
function command_nil($telegram_id, $current_coordinate) {
    return array('', $current_coordinate);
}

function command_safe($telegram_id, $current_coordinate) {
    // TODO
    return command_nil($telegram_id, $current_coordinate);
}

function command_1($telegram_id, $current_coordinate) {
    $target = coordinate_advance($current_coordinate);
    if($target == null) {
        Logger::fatal('Cannot execute command_1 from position (null target)');
    }

    return array(
        'a',
        $target
    );
}

/* Turn right or left (if ahead is not out) */
function command_2($telegram_id, $current_coordinate) {
    $possible_directions = array();
    $possible_directions_coords = array();

    $c_turned_right = coordinate_turn_right($current_coordinate);
    if(!coordinate_out_ahead($c_turned_right)){
        $possible_directions_coords[]= $c_turned_right;
        $possible_directions[]= 'd';
    }

    $c_turned_left = coordinate_turn_left($current_coordinate);
    if(!coordinate_out_ahead($c_turned_left)){
        $possible_directions_coords[]= $c_turned_left;
        $possible_directions[]= 's';
    }

    if(count($possible_directions) < 1) {
        Logger::fatal('Cannot execute command_2 from position (no valid option)');
    }

    $direction_index = array_rand($possible_directions);

    return array(
        $possible_directions[$direction_index],
        $possible_directions_coords[$direction_index]
    );
}

function command_3($telegram_id, $current_coordinate) {
    return command_1($telegram_id, $current_coordinate);
}

function command_4($telegram_id, $current_coordinate) {
    if(!coordinate_out_ahead(coordinate_turn_left($current_coordinate), 3)) {
        return array(
            'sa',
            coordinate_advance(coordinate_turn_left($current_coordinate))
        );
    }
    else if(!coordinate_out_ahead(coordinate_turn_right($current_coordinate), 3)) {
        return array(
            'da',
            coordinate_advance(coordinate_turn_right($current_coordinate))
        );
    }
    else {
        return command_safe($telegram_id, $current_coordinate);
    }
}

function command_5($telegram_id, $current_coordinate) {
    if(coordinate_out_ahead($current_coordinate, 2)){
        Logger::fatal('Cannot execute command_5 from position (no valid path)');
    }

    return array(
{'fraction_non_alphanumeric': 0.11778703152885188, 'fraction_numerical': 0.005155661312710688, 'mean_word_length': 4.0239043824701195, 'pattern_counts': {'":': 0, '<': 7, '<?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': '77269', 'n_tokens_mistral': 1600, 'n_tokens_neox': 1490, 'n_words': 266}