#!/bin/bash # # Copyright (C) 2007 LAFKON/Christoph Haag # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA # # 111111111 # ACCUMULATION OF CONNECTORS IS DEFINED HERE VERT=$1 HORIZ=$2 LSDIR=$3 TILEDIR=tiles TILEPATH=i/$TILEDIR VARCONNECTORS=`sed -n '/ACCUMULATION/p' ./ioioi4mini.sh |\ sed -n '/sed/!p' |\ cut -d "#" -f 2 |\ rl --count=1` echo $VARCONNECTORS J=1 while [ $J -le $VERT ] do LS=$J.list I=1 while [ $I -le $HORIZ ] do # GENERATE 2 DIFFERENT RANDOM NUMBERS # RBNDOM=`echo $RANDOM | cut -c 1` RCNDOM=`echo $RANDOM | cut -c 1` LSBEFORE=$LSDIR/$((J - 1)).list LINE=`expr $HORIZ + 1 - $I` if [ $J -gt 1 ] then F3=`sed -n "$((LINE))p" $LSBEFORE | cut -d _ -f 2` else F3=0 fi if [ $I -le 1 ] then F1=`echo $VARCONNECTORS | cut -c $RBNDOM` F2=0 # F3 IS DEFINED AT LOOPSTART # F4=`echo $VARCONNECTORS | cut -c $RCNDOM` F4=0 RNDMZR=`ls $TILEDIR |\ grep $F1"_"$F2"_"$F3"_"$F4"_".svg |\ rl --count=1` echo $TILEPATH/$RNDMZR > $LS I=`expr $I + 1` elif [ $I -lt $HORIZ ] then F1=`echo $VARCONNECTORS | cut -c $RBNDOM` F2=$F4 # F3 IS DEFINED AT LOOPSTART F4=`echo $VARCONNECTORS | cut -c $RCNDOM` RNDMZR=`ls $TILEDIR |\ grep $F1"_"$F2"_"$F3"_"$F4"_".svg |\ rl --count=1` echo $TILEPATH/$RNDMZR >> $LS I=`expr $I + 1` else F1=`echo $VARCONNECTORS | cut -c $RBNDOM` F2=$F4 # F3 IS DEFINED AT LOOPSTART F4=0 RNDMZR=`ls $TILEDIR |\ grep $F1"_"$F2"_"$F3"_"$F4"_".svg |\ rl --count=1` echo $TILEPATH/$RNDMZR >> $LS I=`expr $I + 1` fi done ################################################ ## HAPPY END ################################### ################################################ if [ $J -ge $((VERT - 0)) ] ### FADE OUT ### then rm $LS I=1 while [ $I -le $HORIZ ] do LS=$J.list LSBEFORE=$LSDIR/$((J - 1)).list LINE=`expr $HORIZ + 1 - $I` # IF BOTTOM-CONNECTION = 0 -> TOP-CONNECTION = 0 # F1=`sed -n "$((LINE))p" $LSBEFORE | cut -d _ -f 2` # IF BOTTOM-CONNECTION = 1 -> TOP-CONNECTION = RANDOM # if [ $F1 -ge 1 ] then #F1=`echo $VARCONNECTORS | cut -c $RBNDOM` F1=`echo "111111000" | cut -c $RBNDOM` fi # IF LAST LINE -> TOP-CONNECTION = 0 # if [ $J -ge $VERT ] then F1=0 fi F2=$F4 F3=`sed -n "$((LINE))p" $LSBEFORE | cut -d _ -f 2` F4=`echo $VARCONNECTORS | cut -c $RBNDOM` # PREVENT FLYING INSTRUMENTS # if [ $F3 -le 0 ] then F4=0 fi # CLOSE LEFT BORDER # if [ $I -ge $HORIZ ] then F4=0 fi ### GREP HOL*(LYWOOD) FOR HAPPY END ### RNDMZR=`ls $TILEDIR |\ grep $F1"_"$F2"_"$F3"_"$F4"_".svg |\ rl --count=1` # RNDMZR=`ls $TILEDIR |\ # grep $F1"_"$F2"_"$F3"_"$F4"_".svg |\ # rl --count=1` echo $TILEPATH/$RNDMZR >> $LS I=`expr $I + 1` done fi ################################################ ################################################ ################################################ # ZEILEN UMDREHEN UND WIEDER AUSGEBEN # sed '1!G;h;$!d' $LS > /tmp/$LS.tmp rm $LS cat /tmp/$LS.tmp > $LSDIR/$LS J=`expr $J + 1` done exit 0;