Rewrite difficulty system

Fixes #80
Also move the table just before the function, so that it isn't function-local, but rather file-local. As it is now, each time Lua calls the function, a new instance of the table is created.