Wave function collapse: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
Line 32: Line 32:
}}</lang>
}}</lang>


Task example:<lang J> 1j1#"1 ' #'{~ tiles wfc 8 8
Task example (the initial tiles and two runs of wave function collapse (two, to illustrate randomness):<lang J> (<"2) 1j1#"1 ' #'{~ tiles
┌──────┬──────┬──────┬──────┬──────┐
│ │ │ # │ # │ # │
│ │# # # │ # # │# # # │# # │
│ │ # │ # │ │ # │
└──────┴──────┴──────┴──────┴──────┘

1j1#"1 ' #'{~ tiles wfc 8 8
# # # #
# # # #
# # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # #
Line 57: Line 64:
# # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # #
# # # # # # #
# # # # # # #

1j1#"1 ' #'{~ tiles wfc 8 8
1j1#"1 ' #'{~ tiles wfc 8 8
# # # #
# # # #

Revision as of 09:59, 10 July 2022

Wave function collapse is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion.

Write the solution for Wave Function Collapse based on the Coding Challenge 171: Wave Function Collapse and create new map 8x8 tiles with fourth T-blocks with variously directions (┤ ┴ ┬ ├) or blank tiles (space).

Reference WFC explained and another WFC explained

J

Implementation:<lang J>tiles=: 0,(|.@|:)^:(i.4)0,1 1 1,:0 1 0 wfc=: Template:M=.</lang>

Task example (the initial tiles and two runs of wave function collapse (two, to illustrate randomness):<lang J> (<"2) 1j1#"1 ' #'{~ tiles ┌──────┬──────┬──────┬──────┬──────┐ │ │ │ # │ # │ # │ │ │# # # │ # # │# # # │# # │ │ │ # │ # │ │ # │ └──────┴──────┴──────┴──────┴──────┘

  1j1#"1 ' #'{~ tiles wfc 8 8
       #           #     #                 #   
     # #   # # #   # # # #   # # # # # #   # # 
       #     #     #     #     #     #     #   
 #           #                 #     #         
  1. # # # # # # # # # # # # # # # # # # # # # # #
       #           #     #                 #   
 #           #     #     #                 #   
 # #       # #   # # # # # # # # # # # # # # # 
 #           #                 #     #         
 #     #     #     #           #     #     #   
  1. # # # # # # # # # # # # # # # # # # #
 #           #     #     #                 #   
       #     #     #           #     #     #   
  1. # # # # # # # # # # # # # #
 #     #     #     #           #     #     #   
 #                       #     #     #         
  1. # # # # # # # # # # # # # # # # # # # # #
       #     #     #           #     #     #   
 #     #     #     #     #     #     #         
  1. # # # # # # # # # # # # # # # #
 #                       #     #     #         
       #     #     #     #     #     #     #   
  1. # # # # # # # # # # # # # # # # #
 #     #     #     #     #     #     #         
  1j1#"1 ' #'{~ tiles wfc 8 8
 #     #                       #           #   
  1. # # # # # # # # # # # # # # # # # #
             #     #     #     #           #   
 #     #     #     #     #           #         
 # # # #   # # # # # # # # # # # # # # # # # # 
 #     #                       #           #   
 #     #     #     #     #     #     #         
  1. # # # # # # # # # # # # # #
 #     #     #     #     #           #         
 #     #                       #     #     #   
 # # # #   # # # # # # # # #   # # # #   # # # 
 #     #     #     #     #     #     #         
 #     #                       #           #   
  1. # # # # # # # # # #
 #     #                       #     #     #   
 #     #     #     #     #           #         
 # # # #   # # # # # # # # # # # # # # # # # # 
 #     #                       #           #   
             #     #     #           #     #   
  1. # # # # # # # # # # # # # # # #
 #     #     #     #     #           #         
             #     #     #     #           #   
           # #     # # # #   # # # # # #   # # 
             #     #     #           #     #   </lang>