Slightly generalized implementation of tic tac toe in Swift