Skip to content

Commit

Permalink
Fix wfc string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
aardappel committed Sep 16, 2023
1 parent e7735c3 commit 790e5b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
5 changes: 4 additions & 1 deletion dev/src/builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,10 @@ nfr("wave_function_collapse", "tilemap,size", "S]I}:2", "S]I",
iint cols = 0;
for (ssize_t i = 0; i < rows; i++) {
auto sv = tilemap.vval()->At(i).sval()->strv();
if (i) { if (ssize(sv) != cols) vm.BuiltinError("all columns must be equal length"); }
if (i) {
if (ssize(sv) != cols)
vm.BuiltinError("all columns must be equal length");
}
else cols = sv.size();
inmap[i] = sv.data();
}
Expand Down
24 changes: 11 additions & 13 deletions samples/wave_function_collapse.lobster
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
// Example of using Wave Function Collapse to generate gameworlds based on tiles.
// Using ascii chars here for simplicity.

// Using """ string literals so we don't have to escape \ :(

let tilemap = [
""" /--\ """,
""" | | """,
""" | | """,
"""/--J L--\ """,
"""| | """,
"""| | """,
"""L--\ /--J """,
""" | | """,
""" | | """,
""" L--J """,
""" """,
" /--\\ ", // Not aligned because we escape \\
" | | ",
" | | ",
"/--J L--\\ ",
"| | ",
"| | ",
"L--\\ /--J ",
" | | ",
" | | ",
" L--J ",
" ",
]

let benchmark = false
Expand Down

0 comments on commit 790e5b2

Please sign in to comment.