Rewrote bth_is_valid_move; removed bug-prone unsigned ints

At Cătălin's suggestion, I rewrote the mess that was bth_is_valid_move() into
something much more manageable and maintainable.

I've also removed pretty much every instance of unsigned ints in the code
because if you're not careful with them, infinite loops often ensure. For
example, it's downright impossible to use and unsigned int to count down to 0
in a for loop, because of unsigned integer underflow.