1 ! Copyright (C) 2006, 2007, 2008 Alex Chapman
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel arrays namespaces sequences math math.vectors
7 TUPLE: tetromino states colour ;
9 C: <tetromino> tetromino
16 { 0 0 } { 1 0 } { 2 0 } { 3 0 }
27 { 0 1 } { 1 1 } { 2 1 }
33 { 0 0 } { 1 0 } { 2 0 }
47 { { 0 0 } { 1 0 } { 2 0 }
55 { 0 1 } { 1 1 } { 2 1 }
64 { { 0 0 } { 1 0 } { 2 0 }
72 { 0 1 } { 1 1 } { 2 1 }
101 } [ call <tetromino> ] map tetrominoes set-global
103 : random-tetromino ( -- tetromino )
104 tetrominoes get random ;
106 : blocks-max ( blocks quot -- max )
107 map [ 1+ ] map supremum ; inline
109 : blocks-width ( blocks -- width )
110 [ first ] blocks-max ;
112 : blocks-height ( blocks -- height )
113 [ second ] blocks-max ;