Wave function collapse: Difference between revisions

→‎{{header|C}}: remove (bungled) "discard one row and one column from small tiles" mechanism
(→‎{{header|J}}: use full tiles in result rather than dropping a row and column of pixels)
(→‎{{header|C}}: remove (bungled) "discard one row and one column from small tiles" mechanism)
Line 6:
 
=={{header|C}}==
{{trans|J}}<lang C>#include <assertstdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Line 141 ⟶ 140:
free(possible);
if (!R) return NULL;
char *tiled= malloc(t0*t1*(td1-1)*(td2-1));
for (int i0= 0; i0<t0; i0++)
for (int i1= 0; i1<td1; i1++)
for (int j0= 0; j0<t1; j0++)
for (int j1= 0; j1<td2; j1++)
tiled[j1 + (td2-1)*(j0 + (t1*td1)*(i1 + (td1-1)*i0))]=
tiles[j1 + td1td2*(i1 + td2td1*R[j0+t1*i0])];
free(R);
return tiled;
Line 159 ⟶ 158:
char *tiled= wfc((char*)tiles, tdims, size);
if (!tiled) exit(0);
for (int i= 0; i<1624; i++) {
for (int j= 0; j<1624; j++) {
printf("%c ", " #"[tiled[j+i*1624]]);
}
printf("\n");
Line 171 ⟶ 170:
 
{{out}}
<pre> # # # # # #
# # # # # # # # # # # # # # # # # # # # # #
# # # # # #
# # # # # # # # # #
# # # # # # # # # # # # # # # # #
# # # # # # # # # # #
# # # # # # # #
# # # # # # # # # # # # # # # # #
# # # # # # #
# # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # #
# # # # #
# # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # #
# # # # # # # # # # # # # # #</pre>
# # # #
# #
# # # # # #
# # # # # # # # # # # # # # # # # # # # # # # #
# #
# # # #
# # # # # # # # # # # # # #
# # # # # #</pre>
 
=={{header|J}}==
6,962

edits