I am working on a generic game engine for simple board games and such. I am defining interfaces that I will require each game to implement I have classes like IGame, IGameState, IBoardEvaluator, and IMove.
I have methods like IGame.PerformMove(IMove move), that I would like to restrict. If I am playing tic-tac-toe I would like to enforce that I can only use the concrete classes TTTGame, TTTState, TTTMove, etc...
I can think of several ways to do this, but none of them sound fun. Maybe all classes could have a single generic parameter, and I could make sure it matches.
so IGame<T> has method PerformMove(IMove<T> move)
If that works out, I wouldn't know what class to use for T. Maybe it doesn't matter.
My other idea is put a bunch of generic parameters on IGame and give it all of the classes I need. So I would create class TTTGame<TTTMove,TTTState,TTTMove....>
That isn't pretty either. Is there a common pattern to do this?