|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
#!/usr/bin/env bash |
|
|
|
|
|
|
|
|
|
set -u |
|
|
|
|
set -e |
|
|
|
|
# set -x |
|
|
|
|
|
|
|
|
|
# File locations |
|
|
|
|
path="$HOME/dev/bash/robocode/svm" |
|
|
|
@ -20,15 +20,15 @@ robot2="sample.VelociRobot" |
|
|
|
|
|
|
|
|
|
# Run battle without GUI, following the settings file, and returning the lines containing winners |
|
|
|
|
battle() { |
|
|
|
|
echo $(robocode -nodisplay -battle "$settings" | tail -2); |
|
|
|
|
robocode -nodisplay -battle "$settings" | tail -2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# Make sure files are right |
|
|
|
|
cd $path |
|
|
|
|
cd "$path"; |
|
|
|
|
rm -f "$results"; touch "$results" |
|
|
|
|
|
|
|
|
|
# Repeat the battle desired number of times |
|
|
|
|
for i in `seq 1 $rounds`; |
|
|
|
|
for i in $(seq 1 $rounds); |
|
|
|
|
do |
|
|
|
|
# Generate input parameters |
|
|
|
|
number=$RANDOM; let "number %= $width"; x=$number |
|
|
|
@ -44,7 +44,7 @@ robocode.battle.numRounds=1 |
|
|
|
|
robocode.battle.gunCoolingRate=0.1 |
|
|
|
|
robocode.battle.rules.inactivityTime=450 |
|
|
|
|
robocode.battle.selectedRobots=$robot1,$robot2 |
|
|
|
|
robocode.battle.initialPositions=($(($width/2)),$(($height/2)),0),($x,$y,$alpha)" > "$settings" |
|
|
|
|
robocode.battle.initialPositions=($((width/2)),$((height/2)),0),($x,$y,$alpha)" > "$settings" |
|
|
|
|
|
|
|
|
|
# If the robots are of the same name |
|
|
|
|
if [ "$robot1" == "$robot2" ] ; then |
|
|
|
@ -72,5 +72,5 @@ te=$(bc <<< "scale=0; ($rounds - $tr) / 1"); |
|
|
|
|
|
|
|
|
|
# Scale the results to interval <0, 1> and split them to training set and testing set; |
|
|
|
|
# misuse tee for 'process substituion' and send its stdout do /dev/null |
|
|
|
|
svm-scale -l 0 -u 1 "$results" | tee >(head -n $tr > "$training") >(tail -n $te > "$testing") > /dev/null |
|
|
|
|
svm-scale -l 0 -u 1 "$results" | tee >(head -n "$tr" > "$training") >(tail -n "$te" > "$testing") > /dev/null |
|
|
|
|
|
|
|
|
|