SHARE
TWEET

Untitled

a guest Oct 17th, 2017 119 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sed -nf
  2. # sedtris.sed - sed tetris
  3. # 26th of May, 2008
  4. # Julia Jomantaite <julia.jomantaite@gmail.com>
  5. 1{
  6. s/.*/ 2a2a2a2a|3a3a3a3a3a3a3a3a3a3a|2a2a2a2a~/
  7. s/[^~]*~$/&&&/
  8. s/.*/& 2a2a2a2a|0a0a0a0a0a0a0a0a0a0a|2a2a2a2a~/
  9. s/[^~]*~$/&&&&&&&&&&&&&&&&&&&&/
  10. s// 2a2a2a2a|4a4a4a4a4a4a4a4a4a4a|2a2a2a2a~/
  11. s/[^~]*~$/&&&/
  12. s/.*/~&/
  13. s/$/#....,,,~/
  14. s/$/#AAAA AAAA APPA APPA~/
  15. s/$/#AAAA ANAA LPOA AHAA~/
  16. s/$/#AAAA BKIA FPFA CKEA~/
  17. s/$/#AAAA EDCA GPJA IMBA~/
  18. s/$/#ACIA EGME BDJB ACIA~/
  19. s/$/#AAAA IKEA FPFA BKCA~/
  20. s/$/#AAAA CGBA MPDA EJIA~/
  21. s/$/#NEXTAAAA ANAA LPOA AHAA 5~/
  22. s/$/#SCORE0~/
  23. h
  24. b display
  25. }
  26.  
  27. /1/{s/1//;x;s/#\.\.*/&./;s/#\.\{8\}/#./;x;}
  28.  
  29. /^w/b rotate
  30. /^a/b left
  31. /^d/b right
  32. /^s/b nothing
  33. /^\[A/b rotate
  34. /^\[D/b left
  35. /^\[C/b right
  36. /^\[B/b nothing
  37. /^$/b nothing
  38. /^[z ]/{
  39. g
  40. s/#\.*/&.../
  41. s/#\.\{8\}/#./
  42. s/$/#FALL~/
  43. h
  44. b nothing
  45. }
  46. b display
  47.  
  48. :rotate
  49. g
  50. s/#\.*/&./
  51. s/#\.\{8\}/#./
  52. /[14-9x][e-h]/! {/2[e-h]/!y/abcdefghijklmnop/acegikmobdfhjlnp/;}
  53. h
  54. b display
  55.  
  56. :left
  57. g
  58. s/#\.*/&../
  59. s/#\.\{8\}/#./
  60. /|[0-9x][i-p]/! {/[14-9x][a-p][0-9x][i-p]/! {
  61. s/\([0-9x]\)a\(|\{0,1\}\)\([0-9x]\)\([b-p]\)/\1\4\2\3a/g
  62. s/\([b-p]\)\(|\{0,1\}\)\([0-9x]\)a\(|\{0,1\}\)\([0-9x]\)\([b-p]\)/\1\2\3\6\4\5a/g
  63. s/\([b-p]\)\(|\{0,1\}\)\([0-9x]\)a\(|\{0,1\}\)\([0-9x]\)\([b-p]\)/\1\2\3\6\4\5a/g
  64. s/\([b-p]\)\(|\{0,1\}\)\([0-9x]\)a\(|\{0,1\}\)\([0-9x]\)\([b-p]\)/\1\2\3\6\4\5a/g
  65. };}
  66. h
  67. b display
  68.  
  69. :right
  70. g
  71. s/#\.*/&./
  72. s/#\.\{8\}/#./
  73. /[i-p]|/! {/[i-p][14-9x]/!{
  74. s/\([0-9x]\)\([b-p]\)\(|\{0,1\}\)\([0-9x]\)a/\1a\3\4\2/g
  75. s/\([0-9x]\)\([b-p]\)\(|\{0,1\}\)\([0-9x]\)a\(|\{0,1\}\)\([0-9x]\)\([b-p]\)/\1a\3\4\2\5\6\7/g
  76. s/\([0-9x]\)\([b-p]\)\(|\{0,1\}\)\([0-9x]\)a\(|\{0,1\}\)\([0-9x]\)\([b-p]\)/\1a\3\4\2\5\6\7/g
  77. s/\([0-9x]\)\([b-p]\)\(|\{0,1\}\)\([0-9x]\)a\(|\{0,1\}\)\([0-9x]\)\([b-p]\)/\1a\3\4\2\5\6\7/g
  78. };};
  79. h
  80. b display
  81.  
  82. :nothing
  83. g
  84.  
  85. #New brick
  86. /~ \(2a\)*|\([15-9x]a\)*|\(2a\)*~/! {
  87. /[b-p]/! {
  88. #Set % before all 4-letter "words"
  89. t e
  90. :e
  91. s/\(#NEXT\(\( \)\{0,1\}%[A-P]\)*\)\( \)\{0,1\}\([A-P]\)/\1\4%\5/
  92. t e
  93.  
  94. #Set @ before probable new letters
  95. s/^\(~[^~]*~[^~]*~.\{17\}\)\(..\)\(..\)\(..\)\(..\)/\1@\2@\3@\4@\5/
  96. s/^\(~[^~]*~[^~]*~[^~]*~.\{17\}\)\(..\)\(..\)\(..\)\(..\)/\1@\2@\3@\4@\5/
  97. t blank2
  98. :blank2
  99. /#NEXT\([^%]*%\)\{13\}[A-H]%[A-H]%[A-H]%[A-H]/{
  100. s/^\(~[^~]*~[^~]*~[^~]*~[^~]*~.\{17\}\)\(..\)\(..\)\(..\)\(..\)/\1@\2@\3@\4@\5/
  101. /#NEXT\([^%]*%\)\{9\}[A-H]%[A-H]%[A-H]%[A-H]/{
  102. s/^\(~[^~]*~[^~]*~[^~]*~[^~]*~[^~]*~.\{17\}\)\(..\)\(..\)\(..\)\(..\)/\1@\2@\3@\4@\5/
  103. b v2
  104. }
  105. b v1
  106. }
  107. s/^\(~.\{17\}\)\(..\)\(..\)\(..\)\(..\)/\1@\2@\3@\4@\5/
  108. :v1
  109. s/^\(~[^~]*~.\{17\}\)\(..\)\(..\)\(..\)\(..\)/\1@\2@\3@\4@\5/
  110. :v2
  111.  
  112. #Add real new letters (capital)
  113. t f
  114. :f
  115. /^\([^@]*\)[15-9x]@.\([^%]*\)%[I-P]/s/$/#OVER~/
  116. s/^\([^@]*\)@.\([^%]*\)%\([A-P]\)/\1\3\2\3/
  117. t f
  118.  
  119. #Decapitalization
  120. h
  121. s/^\(~[^~]*\)\{6\}~//
  122. x
  123. s/^\(\(~[^~]*\)\{6\}\)\(.*\)$/\1/
  124. y/ABCDEFGHIJKLMNOP/abcdefghijklmnop/
  125. x
  126. H
  127. #Add "Current"
  128. g
  129. s/\n/~/
  130. s/#CURRENT.~//g
  131. s/\(#NEXT[^~]*\)\([0-9x]\)\(.*\)$/\1\2\3#CURRENT\2~/
  132.  
  133. #Add NEXT
  134. :g
  135. /\./{
  136. s/#/$/
  137. s/\./@/
  138. b g
  139. }
  140. s/@/./g
  141. s/^\([^#]*\)#\([^~]*\)\(.*\)\(#NEXT[^~]*\)/\1#\2\3#NEXT\2/
  142.  
  143. s/\([^.]\)\(\.\)\([^.]*\)\(#NEXT[^~]*\)/\1\2\3\4 1/
  144. s/\([^.]\)\(\.\{2\}\)\([^.]*\)\(#NEXT[^~]*\)/\1\2\3\4 5/
  145. s/\([^.]\)\(\.\{3\}\)\([^.]*\)\(#NEXT[^~]*\)/\1\2\3\4 6/
  146. s/\([^.]\)\(\.\{4\}\)\([^.]*\)\(#NEXT[^~]*\)/\1\2\3\4 7/
  147. s/\([^.]\)\(\.\{5\}\)\([^.]*\)\(#NEXT[^~]*\)/\1\2\3\4 8/
  148. s/\([^.]\)\(\.\{6\}\)\([^.]*\)\(#NEXT[^~]*\)/\1\2\3\4 9/
  149. s/\([^.]\)\(\.\{7\}\)\([^.]*\)\(#NEXT[^~]*\)/\1\2\3\4 x/
  150. s/\$/#/g
  151.  
  152. h
  153. s/\(,*\)\([^,]*#NEXT[^~]*\)/\1\2\1/
  154. s/.*#NEXT\([^~]*\)~.*/\1/
  155.  
  156. :g2
  157. /,/{
  158. s/\,/@/
  159. y/ABCDEFGHIJKLMNOP/ACEGIKMOBDFHJLNP/
  160. b g2
  161. }
  162. s/@//g
  163. H
  164. g
  165. s/\n/~/
  166. s/\(#NEXT\)[^~]*\(~.*\)~\([^~]*\)$/\1\3\2/
  167. h
  168. b display
  169. };};
  170.  
  171. #Eat that line
  172. t d
  173. :d
  174. /~ \(2a\)*|\([15-9x]a\)*|\(2a\)*~/ {
  175. s/~ \(2a\)*|\([15-9x]a\)*|\(2a\)*//
  176. s/^~\([^~]*~\)\{3\}/& 2a2a2a2a|0a0a0a0a0a0a0a0a0a0a|2a2a2a2a~/
  177. s/#SCORE[^~]*/&A/
  178. b d
  179. }
  180. #Scoring
  181. /#SCORE[^~]*A/{
  182. s/\(#SCORE[^~]*\)AAAA/\1+1200z/
  183. s/\(#SCORE[^~]*\)AAA/\1+300z/
  184. s/\(#SCORE[^~]*\)AA/\1+100z/
  185. s/\(#SCORE[^~]*\)A/\1+40z/
  186.  
  187. /#SCORE[0-9]*+[0-9]*z/{
  188. s/+/@+/
  189. :finnul
  190. /0z/{
  191. /#SCORE@/b endsum
  192. s/\(.\)@/@\1/
  193. s/0z/z/
  194. /+z/b endsum
  195. b finnul
  196. }
  197. t incr
  198. :incr
  199. s/9\(%*\)@/%\1@/
  200. t incr
  201. s/#SCORE\(%*\)@/#SCORE0\1@/
  202. s/8\(%*\)@/9\1@/
  203. s/7\(%*\)@/8\1@/
  204. s/6\(%*\)@/7\1@/
  205. s/5\(%*\)@/6\1@/
  206. s/4\(%*\)@/5\1@/
  207. s/3\(%*\)@/4\1@/
  208. s/2\(%*\)@/3\1@/
  209. s/1\(%*\)@/2\1@/
  210. s/0\(%*\)@/1\1@/
  211. s/%/0/g
  212. t blank
  213. :blank
  214. s/9z/8z/
  215. t incr
  216. s/8z/7z/
  217. t incr
  218. s/7z/6z/
  219. t incr
  220. s/6z/5z/
  221. t incr
  222. s/5z/4z/
  223. t incr
  224. s/4z/3z/
  225. t incr
  226. s/3z/2z/
  227. t incr
  228. s/2z/1z/
  229. t incr
  230. s/1z/0z/
  231. t finnul
  232. :endsum
  233. s/@//
  234. s/#SCORE\([0-9]*\)+\([0-9]*\)z/#SCORE\2\1/
  235. }
  236. h
  237. b display
  238. }
  239.  
  240. #Falling down
  241. :fall
  242. /~[^~]*[03][i-p].\{38\}[14-9x]/! {
  243. :c
  244. #Find the lowest line with the...
  245. s/\(~[^~]*[b-p][^~]*\)~\([^b-p~]*~\)/\1z\2/
  246. s/~\([^~b-p]*\)\([b-p]\)\([^~]\{39\}\)[a-p]/~\1a\3\2/
  247. s/~\([^~b-p]*\)\([b-p]\)\([^~]\{39\}\)[a-p]/~\1a\3\2/
  248. s/~\([^~b-p]*\)\([b-p]\)\([^~]\{39\}\)[a-p]/~\1a\3\2/
  249. s/~\([^~b-p]*\)\([b-p]\)\([^~]\{39\}\)[a-p]/~\1a\3\2/
  250. s/z/~/
  251. /[^~]*[b-p][^~]*~[^~b-p]*~[^~]*[b-p][^~]*/b c
  252. /#FALL~$/b fall
  253. h
  254. b display
  255. }
  256. s/#FALL~//g
  257.  
  258. #Freezing
  259. s/0[b-h]/0a/g
  260. t i
  261. :i
  262. s/\(0[i-p]\)\(.*#CURRENT\)\(.\)/\3a\2\3/
  263. t i
  264.  
  265. s/\([15-9x]\)[b-p]/\1a/g
  266. s/2[b-p]/2a/g
  267. s/3[b-h]/3a/g
  268. s/4[b-p]/4a/g
  269.  
  270. #if it's over
  271. /3[i-p]/ s/$/#OVER~/
  272. /[15-9x][i-p]/{
  273. s/\([15-9x]\)\([i-p]\)/\1a/g
  274. s/$/#OVER~/
  275. }
  276. h
  277.  
  278. #Display
  279. :display
  280. g
  281. s/#\.*/&./
  282. s/#\.\{8\}/#./
  283. s/,\{1,\}/&,/
  284. s/,\{5\}/,/
  285. s/#FALL~//g
  286. h
  287.  
  288. s/^~/~ +----------+~/
  289. s/~[^~]*~$/& +----------+/
  290. s/~[^~]*|[^~]*3[^~]*//g
  291. s/~[^~]*|[^~]*4[^~]*//g
  292. s/2[a-h]//g
  293. s/\([15-9x]\)[i-p]/\1a/g
  294.  
  295. /#OVER/s/^\(\(~[^~]*\)\{6\}~\)\([^~]*~\)/\1 |GAME OVER!|~/
  296.  
  297. /#CURRENT1/s/0[i-p]/O/g
  298. /#CURRENT5/s/0[i-p]/O/g
  299. /#CURRENT6/s/0[i-p]/O/g
  300. /#CURRENT7/s/0[i-p]/O/g
  301. /#CURRENT8/s/0[i-p]/O/g
  302. /#CURRENT9/s/0[i-p]/O/g
  303. /#CURRENTx/s/0[i-p]/O/g
  304. s/0[a-h]/ /g
  305. #s/[+|\-]/&/g
  306. s/1[a-h]/X/g
  307. s/5[a-h]/X/g
  308. s/6[a-h]/X/g
  309. s/7[a-h]/X/g
  310. s/8[a-h]/X/g
  311. s/9[a-h]/X/g
  312. s/x[a-h]/X/g
  313.  
  314. :decap
  315. /#NEXT[^~]*[A-P]/{
  316. s/\(#NEXT[^~]*\)[A-H]/\1 /
  317. s/\(#NEXT[^~]*\)[I-P]/\1X/
  318. b decap
  319. }
  320. s/\(#NEXT[^~]*\)     /\1/
  321.  
  322. s/^\(\(~[^~]*\)\{2\}\)/&   Next:/
  323. s/^\(\(~[^~]*\)\{3\}\)\(.*\)\(#NEXT\([^~]\{4\}\)\)/\1    \5\3\4/
  324. s/^\(\(~[^~]*\)\{4\}\)\(.*\)\(#NEXT[^~]\{4\} \([^~]\{4\}\)\)/\1    \5\3\4/
  325. s/^\(\(~[^~]*\)\{5\}\)\(.*\)\(#NEXT\([^~]\{4\} \)\{2\}\([^~]\{4\}\)\)/\1    \6\3\4/
  326. s/^\(\(~[^~]*\)\{6\}\)\(.*\)\(#NEXT\([^~]\{4\} \)\{3\}\([^~]\{4\}\)\)/\1    \6\3\4/
  327. s/^\(\(~[^~]*\)\{7\}\)\(.*\)\(#SCORE\([^~]*\)\)/\1   Score:\5 \3\4/
  328. s/ \(X\{1,4\}\)/ \1 /g
  329. s/^\(\(~[^~]*\)\{9\}\)/&  "w" or up - rotate/
  330. s/^\(\(~[^~]*\)\{10\}\)/&  "a" or left - left/
  331. s/^\(\(~[^~]*\)\{11\}\)/&  "d" or right - right/
  332. s/^\(\(~[^~]*\)\{12\}\)/&  "s" or down - one step down/
  333. s/^\(\(~[^~]*\)\{13\}\)/&  "z" or space - drop down/
  334.  
  335. #uncomment the line below to switch colours off
  336. #s/\[\([0-9]*;\)*[0-9]*m//g
  337. s/#[^~]*~//g
  338. s/^~//
  339. s/~/\
  340. /g
  341. i\
  342. 
  343. p
  344. /GAME OVER!/q
RAW Paste Data
Top