

# change_rules counts the number of rules that change the state of a cell
# in the same spirit as total_rules


case $# in
0)	echo 'Usage: change_rules rule_file [state_number]' 1>&2; exit 1;;

1)	awk '   BEGIN                   {cnt = 0}
        	$1 != "state" && substr($1,1,1) != $3   {cnt++}
        	END                     {print cnt}' $1;;

2)	sed /$2/q $1 | awk 'BEGIN	{cnt = 0}
			    $1 != "state" && substr($1,1,1) != $3 {cnt++}
			    END		{print cnt}' ;;
esac
	
