kapott

tilegen.js

Jan 2nd, 2019
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.   Codegolf flexcercise:
  3.   Create a field with randomly selected tiles, using unicode characters.
  4.  
  5.   fun tilesets (copy paste in console, preload t with the string):
  6.     ["\u2550","\u2551","\u2557","\u255A","\u255D","\u2560","\u2563","\u2566","\u2569","\u256C"," "]
  7.     ["\u2571","\u2572"," "]
  8.     ["\u2500", "\u2502","\u250C", "\u2510", "\u2514", "\u2518","\u251C","\u2524", "\u252C", "\u2534", "\u253C"]
  9.  
  10.   q -   The string we're building
  11.   s -   string length
  12.   f -   total field length (number of lines)
  13.   t -   tileset
  14.   c -   line counter
  15.   n -   character counter
  16.  
  17.   2019-01-04: 130 bytes (108chr.)
  18. */
  19.  
  20. 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"}
Advertisement
Add Comment
Please, Sign In to add comment