kapott icon

tilegen.js

kapott | PRO | 01/02/19 07:24:36 PM UTC | 0 ⭐ | 268 👁️ | Never ⏰ | []
JavaScript |

740 B

|

None

|

0 👍

/

0 👎

/**
  Codegolf flexcercise:
  Create a field with randomly selected tiles, using unicode characters.
  
  fun tilesets (copy paste in console, preload t with the string):
    ["\u2550","\u2551","\u2557","\u255A","\u255D","\u2560","\u2563","\u2566","\u2569","\u256C"," "]
    ["\u2571","\u2572"," "]
    ["\u2500", "\u2502","\u250C", "\u2510", "\u2514", "\u2518","\u251C","\u2524", "\u252C", "\u2534", "\u253C"]
 
  q -   The string we're building
  s -   string length
  f -   total field length (number of lines)
  t -   tileset
  c -   line counter
  n -   character counter
 
  2019-01-04: 130 bytes (108chr.)
*/
 
for(q="",s=f=32,t=[...'─│┌┐└┘├┤┬┴┼'],c=0;c<=f/2;c++){for(n=0;n<=s;n++)q+=t[Math.random()*t.length|0];q+="\n"}

Comments