Recreate the classic snake Game
Ruby 1.9 + SDL (341 324 316)

Here's a first attempt at a Ruby version using the SDL library.  I can save 6 characters if I'm allowed to load the SDL library using -rsdl on the command line instead of the require statement.

require'sdl'
f=o=d=3
s=SDL::Screen.open l=32,l,0,0
r=*0..l*l
loop{f==o ?f=(r-$*).sample: $*.shift
/yU/=~"#{e=SDL::Event.poll}"&amp;&amp;(v=e.sym%4)&amp;&amp;d+v!=3&amp;&amp;d=v
$&gt;&lt;&lt;"Score #{$*.size}"&amp;&amp;exit if$*.index(n=o+[-1,-l,l,1][d])||n&lt;0||n&gt;=l*l||d%3&lt;1&amp;&amp;n/l!=o/l
$*&lt;&lt;o=n
r.map{|i|s[i%l,i/l]=[[f,*$*].index(i)?0:255]*3}
s.flip
sleep 0.1}


The snake segments and food pieces are represented using black pixels, the grid size is currently 32*32.  You can control with the arrow keys (or any keys really, the keycode mod 4 indexes the direction array [LEFT, UP, DOWN, RIGHT]).  I think there's definitely room for improvement here, especially in the death-checking IF statement.

I've vastly improved this over the previous version, hopefully it more closely matches the spirit of the question now.  There's one thing I need to fix to comply with the spec, which is that food can currently spawn inside the tail. Fixed!

Prints the score to stdout after the game is completed.