1 ! Copyright (C) 2006, 2007, 2008 Alex Chapman
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: kernel arrays namespaces sequences math math.order
5 math.vectors colors random ;
9 TUPLE: tetromino states colour ;
11 C: <tetromino> tetromino
18 { 0 0 } { 1 0 } { 2 0 } { 3 0 }
29 { 0 1 } { 1 1 } { 2 1 }
35 { 0 0 } { 1 0 } { 2 0 }
49 { { 0 0 } { 1 0 } { 2 0 }
57 { 0 1 } { 1 1 } { 2 1 }
66 { { 0 0 } { 1 0 } { 2 0 }
74 { 0 1 } { 1 1 } { 2 1 }
103 } [ first2 <tetromino> ] map tetrominoes set-global
105 : random-tetromino ( -- tetromino )
106 tetrominoes get random ;
108 : blocks-max ( blocks quot -- max )
109 map supremum 1 + ; inline
111 : blocks-width ( blocks -- width )
112 [ first ] blocks-max ;
114 : blocks-height ( blocks -- height )
115 [ second ] blocks-max ;