commit
67a1365af7
@ -0,0 +1,2 @@ |
||||
*.pdf filter=lfs diff=lfs merge=lfs -text |
||||
*.png filter=lfs diff=lfs merge=lfs -text |
@ -0,0 +1,10 @@ |
||||
2 1:316 2:151 |
||||
1 1:279 2:157 |
||||
1 1:144 2:157 |
||||
1 1:398 2:321 |
||||
1 1:315 2:37 |
||||
2 1:441 2:169 |
||||
1 1:181 2:281 |
||||
2 1:267 2:57 |
||||
1 1:292 2:138 |
||||
2 1:349 2:44 |
@ -0,0 +1,8 @@ |
||||
#Battle Properties |
||||
robocode.battleField.width=500 |
||||
robocode.battleField.height=500 |
||||
robocode.battle.numRounds=1 |
||||
robocode.battle.gunCoolingRate=0.1 |
||||
robocode.battle.rules.inactivityTime=450 |
||||
robocode.battle.selectedRobots=sample.TrackFire,sample.TrackFire |
||||
robocode.battle.initialPositions=(250,250,0),(349,44,274) |
@ -0,0 +1,5 @@ |
||||
#Robocode Properties |
||||
#Wed Apr 22 18:10:36 CEST 2015 |
||||
robocode.cpu.constant=14014678 |
||||
robocode.options.battle.desiredTPS=10000 |
||||
robocode.version.lastrun=1.9.2.3 |
@ -0,0 +1,57 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
set -u |
||||
set -e |
||||
|
||||
# File locations |
||||
path="$HOME/dev/bash/robocode/svm" |
||||
settings="$path/.settings.battle" |
||||
results="$path/.results.data" |
||||
training="$path/training.data" |
||||
testing="$path/testing.data" |
||||
|
||||
# Battle parameters |
||||
rounds=10 |
||||
width=500 |
||||
height=500 |
||||
|
||||
# Make sure files are right |
||||
cd $path |
||||
rm -f "$results"; touch "$results" |
||||
|
||||
# Repeat the battle desired number of times |
||||
for i in `seq 1 $rounds`; |
||||
do |
||||
# Generate input parameters |
||||
number=$RANDOM; let "number %= $width"; x=$number |
||||
number=$RANDOM; let "number %= $height"; y=$number |
||||
number=$RANDOM; let "number %= 360"; alpha=$number |
||||
|
||||
# Write current settings to a file; first robot starts in the middle, with fixed gun angle; |
||||
# the other one start at random known position, with random known gun angle |
||||
echo "#Battle Properties |
||||
robocode.battleField.width=$width |
||||
robocode.battleField.height=$height |
||||
robocode.battle.numRounds=1 |
||||
robocode.battle.gunCoolingRate=0.1 |
||||
robocode.battle.rules.inactivityTime=450 |
||||
robocode.battle.selectedRobots=sample.TrackFire,sample.TrackFire |
||||
robocode.battle.initialPositions=($(($width/2)),$(($height/2)),0),($x,$y,$alpha)" > "$settings" |
||||
|
||||
# Extract the winner from battle |
||||
winner=$(robocode -nodisplay -battle "$settings" | tail -2 | awk 'NR==1 {print substr($3,2,1)}') |
||||
|
||||
# Inform user about the winner of current round and append the results to the file |
||||
echo "Round $i winner: $winner" |
||||
echo "$winner 1:$x 2:$y" >> "$results" |
||||
# echo "$winner 1:$x 2:$y 3:$alpha" >> "$results" |
||||
done |
||||
|
||||
# Calculate the lines needed to split the data to 90% and 10% |
||||
tr=$(bc <<< "scale=0; $rounds * 0.9 / 1"); |
||||
te=$(bc <<< "scale=0; ($rounds - $tr) / 1"); |
||||
echo "tr: $tr, te: $te" |
||||
|
||||
# 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 |
@ -0,0 +1 @@ |
||||
2 1:0.690236 2:0.0246479 |
@ -0,0 +1,9 @@ |
||||
2 1:0.579125 2:0.401408 |
||||
1 1:0.454545 2:0.422535 |
||||
1 2:0.422535 |
||||
1 1:0.855219 2:1 |
||||
1 1:0.575758 |
||||
2 1:1 2:0.464789 |
||||
1 1:0.124579 2:0.859155 |
||||
2 1:0.414141 2:0.0704225 |
||||
1 1:0.498316 2:0.355634 |
Loading…
Reference in new issue