#!/usr/bin/env/bash FILE=input MAP_WIDTH=101 MAP_HEIGHT=103 MEDIAN_WIDTH=$(( MAP_WIDTH / 2 - 1 )) if [[ $(( MAP_WIDTH % 2 )) -eq 1 ]] then (( MEDIAN_WIDTH++ )) fi MEDIAN_HEIGHT=$(( MAP_HEIGHT / 2 - 1 )) if [[ $(( MAP_HEIGHT % 2 )) -eq 1 ]] then (( MEDIAN_HEIGHT++ )) fi printf "Median width: %s, median height: %s\n" "$MEDIAN_WIDTH" "$MEDIAN_HEIGHT" # Load bot positions and velocities read -r -a BOT_ARRAY <<< "$( grep -Eo '[-0-9]*' "$FILE" | paste -s -d " " )" #printf "%s " "${BOT_ARRAY[@]}" #printf "\n" printf "Bot array size: %s\n" "${#BOT_ARRAY[@]}" # Load arrangements for every second #for SECONDS in $( seq 1 9999 ) for SECONDS in $( seq 6514 6516 ) do # Compute positions for each bot printf "Working on +%s seconds.\n" "$SECONDS" IFS=';'; read -r -a FINAL_ARRAY <<< "$( for (( i=0; i<${#BOT_ARRAY[@]}; i+=4 )) do PX=${BOT_ARRAY[i]} PY=${BOT_ARRAY[i+1]} VX=${BOT_ARRAY[i+2]} VY=${BOT_ARRAY[i+3]} FINAL_X=$(( PX + ( VX * SECONDS ) )) FINAL_Y=$(( PY + ( VY * SECONDS ) )) printf "%s %s;" "$FINAL_X" "$FINAL_Y" done <<< "${BOT_ARRAY[@]}" )" unset IFS # Generate "empty" map # Map is a 1d array MAP_LEN=$(( MAP_HEIGHT * MAP_WIDTH )) read -r -a MAP_ARRAY <<< "$( for (( i=0; i