diff --git a/init_empty_blocks.sh b/init_empty_blocks.sh new file mode 100755 index 0000000..4f8d81d --- /dev/null +++ b/init_empty_blocks.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# +# VARIABLES +# +export APPS_PATH=`dirname "$(readlink -f "$0")"` +export TMP_PATH=$APPS_PATH/../tmp +export DATA_PATH=$APPS_PATH/../data +export FLAG_PATH=$APPS_PATH/../flags + +export TS=`date +%s` +export MINUTE=`date +%M | sed 's/^0*//'` +export DATE=`date +%Y%m%d0000` +export DATEHOUR=`date +%Y%m%d%H` + +# +# Synchronize the Blockchain +# +$APPS_PATH/scripts/synchronize.sh + +# +# Draw the HASHES +# +$APPS_PATH/scripts/hashes.sh + +# +# Draw the BLOCKS +# +$APPS_PATH/scripts/empty_blocks.sh diff --git a/methode2/mondrian/draw.php b/methode2/mondrian/draw.php index ff70095..12000dd 100644 --- a/methode2/mondrian/draw.php +++ b/methode2/mondrian/draw.php @@ -25,10 +25,10 @@ function DrawBlock($the_block, $vImage, $parametres) imagefilledrectangle($vImage, $x, $y, $x+$width, $y+$height, $vFgColor); $couleurs = array(); - $couleurs[0] = imagecolorallocate($vImage, 255, 255, 255); - $couleurs[1] = imagecolorallocate($vImage, 255, 0, 0); - $couleurs[2] = imagecolorallocate($vImage, 0, 0, 255); - $couleurs[3] = imagecolorallocate($vImage, 255, 255, 0); + $couleurs[0] = imagecolorallocate($vImage, 245, 245, 240); // 255,255,255 Blanc + $couleurs[1] = imagecolorallocate($vImage, 155, 30, 10); // Rouge + $couleurs[2] = imagecolorallocate($vImage, 12, 102, 153); // Behr Mondrian Blue #0c6699 + $couleurs[3] = imagecolorallocate($vImage, 240, 200, 5); // Jaune $full_area = $width * $height; if ($full_area == 0) $full_area = 1; diff --git a/scripts/empty_blocks.sh b/scripts/empty_blocks.sh new file mode 100755 index 0000000..75d4dc3 --- /dev/null +++ b/scripts/empty_blocks.sh @@ -0,0 +1,99 @@ +#!/bin/bash +lescript=`basename $0 .sh` +flag=$TMP_PATH/bot_$lescript.flag + +# +# 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 + + NAME=`echo $line | awk '{print $1}'` + 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 + + # + # POUR CHAQUE METHODE2 + # + LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf ` + + cd $APPS_PATH/methode2 + for METHODE in $LISTE_METHODE + do + if [ ! -d $DATA_PATH/$METHODE ] + then + mkdir -p $DATA_PATH/$METHODE + fi + echo $BLOCK $NAME $METHODE + if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ] + then + echo Drawing $BLOCK $METHODE + php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2 + cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png + fi + done + cd - >> /dev/null + + if [ ! -f $DATA_PATH/hasard/$BLOCK.png ] + then + cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png + fi + + if [ ! -f $DATA_PATH/nonce/$BLOCK.png ] + then + cp $DATA_PATH/hasard/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png + fi + + rm -f $flag + +done < $DATA_PATH/emptybot/list.txt + +# +# SORTIE AVEC SUCCES +# +succes diff --git a/scripts/known_blocks.sh b/scripts/known_blocks.sh index 1c4c1ad..ca7fbc6 100755 --- a/scripts/known_blocks.sh +++ b/scripts/known_blocks.sh @@ -84,6 +84,11 @@ while IFS='' read -r line || [[ -n "$line" ]]; do cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png fi + if [ ! -f $DATA_PATH/nonce/$BLOCK.png ] + then + cp $DATA_PATH/hasard/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png + fi + rm -f $flag done < $DATA_PATH/block_list.txt