Add functions for alternate group-based approach.

By storing information about the game state as a list of groups (of
adjacent pieces, as per the go game rules), we make it possible to
express most of the game rules as set operations. This makes for much
cleaner code, so it's worth the effort of migrating the existing code
over to the new model.