@ -186,12 +197,48 @@ inchance() { # increase the chance of $1 being picked $2 times # $3 should be `;
@@ -186,12 +197,48 @@ inchance() { # increase the chance of $1 being picked $2 times # $3 should be `;
[ "$LINES" -a "$COLUMNS" ] || exit 10 # exit code 10 will be for rgrid errors
unset IFS otypelist
:>./debug # write `true` to debug (empty)
ml=0; for l in $(s 1 $((LINES-2))); do # for each line
ml=0; for l in $(s 1 $LINES); do # for each line
mc=0; for c in $(s 1 $COLUMNS); do # left to right across screen
# basically the idea here is have a list of all possible things a 1x1 space can be
@ -199,21 +246,42 @@ ml=0; for l in $(s 1 $((LINES-2))); do # for each line
@@ -199,21 +246,42 @@ ml=0; for l in $(s 1 $((LINES-2))); do # for each line
# basically use ran() and some pain to have it pick what a block should be
# the list should be dynamic based on the pos and blocks around it
# ie; placing a door when there is no where for it to lead makes no sense
if [ "$l1c1" ]; then # counter logic is handled in sgrid() as items are handed off to it after being picked
if [ "$l3c3" ]; then # counter logic is handled in sgrid() as items are handed off to it after being picked
@ -237,18 +305,22 @@ ml=0; for l in $(s 1 $((LINES-2))); do # for each line
@@ -237,18 +305,22 @@ ml=0; for l in $(s 1 $((LINES-2))); do # for each line
typelist=$(listr "topwall" "${typelist}" ";")
typelist=$(listr "blank" "${typelist}" ";")
} || {
[ "$topwallc" -lt 6 ] 2>/dev/null && {
[ "$topwallc" -lt $((MiC+1)) ] 2>/dev/null && {
typelist=$(listr "corner" "${typelist}" ";")
}
}
inchance "topwall" "3" ";"
[ "$c" -eq $((COLUMNS -1)) ] && {
inchance "corner" "2" ";"
typelist=$(listr "topwall" "${typelist}" ";")
} || :
;; # increase the chance of topwall
# topwall logic
?"# "??)
"b# "??)
room="true"
typelist=$(listr "door" "${typelist}" ";")
typelist=$(listr "blank" "${typelist}" ";")
typelist=$(listr "corner" "${typelist}" ";")
typelist=$(listr "topwall" "${typelist}" ";")
typelist=$(listr "wall" "${typelist}" ";") ;;
?"# "??|"#"?" "??)
typelist=$(listr "door" "${typelist}" ";")
typelist=$(listr "corner" "${typelist}" ";")
typelist=$(listr "topwall" "${typelist}" ";")
typelist=$(listr "wall" "${typelist}" ";") ;;
@ -256,37 +328,61 @@ ml=0; for l in $(s 1 $((LINES-2))); do # for each line
@@ -256,37 +328,61 @@ ml=0; for l in $(s 1 $((LINES-2))); do # for each line
'#'????|?'# '??|?'| '??) typelist=$(listr "wall" "${typelist}" ";") ;; # cannot be wall if wall is 2 blocks over
?"b "??|?" "??)
inchance "wall" "2" ";"
esac
typelist=$(listr "topwall" "${typelist}" ";")
typelist=$(listr "corner" "${typelist}" ";")
typelist=$(listr "blank" "${typelist}" ";") ;;
??" +"?)
case "$pos" in
'#'????|?'# '??|?'| '??) typelist=$(listr "wall" "${typelist}" ";") ;; # cannot be wall if wall is 2 blocks over
?"b "??|?" "??)
inchance "wall" "3" ";"
esac
typelist=$(listr "topwall" "${typelist}" ";")
typelist=$(listr "corner" "${typelist}" ";") ;;
??" ="?|??" b=")
@ -295,14 +391,42 @@ ml=0; for l in $(s 1 $((LINES-2))); do # for each line
@@ -295,14 +391,42 @@ ml=0; for l in $(s 1 $((LINES-2))); do # for each line
typelist=$(listr "corner" "${typelist}" ";")
typelist=$(listr "door" "${typelist}" ";") ;;
??" -"?)
typelist=$(listr "door" "${typelist}" ";")
typelist=$(listr "wall" "${typelist}" ";")
esac
case "$pos" in
?'= #'?|?'= |'?)
?'= #'?|?'= |'?|?'= +'?|?'+ #'?|?'+ +'?)
typelist=$(listr "wall" "${typelist}" ";")
inchance "corner" "2" ";"
esac
## DIAGONAL
case "$dpos" in
?' +'|'+ '?|?' #')
typelist=$(listr "corner" "${typelist}" ";") ;;
??'b'|??' ')
case "$pos" in
?'b '??)
typelist=$(listr "door" "${typelist}" ";")
typelist=$(listr "wall" "${typelist}" ";")
esac
:
#?' ')
# typelist=$(listr "wall" "${typelist}" ";")
# typelist=$(listr "corner" "${typelist}" ";") ;;
esac
## FLOOR
[ "$room" ] && {
case "$pos" in
??" =") inchance "blank" "4" ";" ;;
*)
typelist=$(listr "blank" "${typelist}" ";")
inchance "floor" "3" ";"
esac
} || typelist=$(listr "floor" "${typelist}" ";")
else # below may run if last exit code is !0 and not handled
typelist=$(listr "floor" "${typelist}" ";")
typelist=$(listr "door" "${typelist}" ";")
typelist=$(listr "topwall" "${typelist}" ";")
typelist=$(listr "wall" "${typelist}" ";")
@ -315,7 +439,6 @@ ml=0; for l in $(s 1 $((LINES-2))); do # for each line
@@ -315,7 +439,6 @@ ml=0; for l in $(s 1 $((LINES-2))); do # for each line
clist "${typelist}" # correct any errors in the list
# $tln is not globally adjusted by listr -- since it runs in a subshell; below is the simplest fix
IFS=";"; set -- ${typelist}; tln=${#}; unset IFS ran