moving code to a library

this is a work in progress, I do not actually want the game rules to be in the library, but untangling this stuff is *hard*