This commit is contained in:
2018-10-31 10:06:43 +01:00
parent e121c6f6dd
commit b3ad46d98a
39 changed files with 1757 additions and 1116 deletions

91
scripts/blocks2.sh Executable file
View File

@@ -0,0 +1,91 @@
#!/bin/bash
lescript=`basename $0 .sh`
#
# TOOLS
#
function debug
{
if [ -f $FLAG_PATH/debug ]
then
echo $1
fi
}
function sortie
{
exit $1
}
function succes
{
debug "SUCCES"
sortie 0
}
function echec
{
debug "ECHEC"
exit 1
}
#
# PARAMETRES PAR FICHIER FLAGS
#
if [ -f $FLAG_PATH/no_blocks ]
then
debug "No blocks"
echec
fi
while IFS='' read -r line || [[ -n "$line" ]]; do
BLOCK=`echo $line | awk '{print $2}'`
HEIGHT=`echo $line | awk '{print $3}'`
NBTX=`echo $line | awk '{print $4}'`
#
# TEST DU FLAG
#
flag=$FLAG_PATH/bot_${lescript}_${BLOCK}.flag
if [ -f $flag ]
then
debug "${lescript}_${BLOCK} already done"
continue
fi
touch $flag
#
# CHOISIR UNE METHODE2 AU HASARD
#
for METHODE in `ls $APPS_PATH/methode2 | grep -v robot | shuf`
do
echo $METHODE
if [ ! -d $DATA_PATH/$METHODE ]
then
mkdir -p $DATA_PATH/$METHODE
fi
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
then
cd $APPS_PATH/methode2
php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2
if [ "$2" == "" ];
then
rm -f $DATA_PATH/hasard/$BLOCK.png
ln $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png
ln $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
fi
fi
done
done < $DATA_PATH/block_list.txt
#
# List of finished blocks
#
rm -f $DATA_PATH/finished_block_list.txt
grep -v CACHE $DATA_PATH/block_list.txt >> $DATA_PATH/finished_block_list.txt
#
# SORTIE AVEC SUCCES
#
succes