Added back-end code for surrendering

This completes the back-end changes required for surrendering, issue #174.

This may also address #350 and #249.

I'm passing this over to @cgolubi1 to add the surrender button to the front-end.