I defined the following interface:
public interface IStateSpace<State, Action>
where State : IState
where Action : IAction<State, Action>
{
void SetValueAt(State state, Action action);
Action GetValueAt(State state);
}
Basically, the interface IStateSpaceshould be something like a chessboard, and in each position of the chessboard you have a set of possible movements. These movements are called IActions here . I defined this interface so that I could adapt to various implementations: I can then define specific classes that implement the 2D matrix, 3D matrix, graphics, etc.
public interface IAction<State, Action> {
IStateSpace<State, Action> StateSpace { get; }
}
An IAction, will move up (this if in (2, 2)go on (2, 1)), go down, etc. Now I want every action to have access to StateSpace so that it can execute some validation logic. Is this implementation correct? Or is this a bad case of circular addiction? If so, how do you do the same thing differently?
thank
source
share