public void RunGame(IGameHost gameHost) { gameHost.NewGame(); while (gameHost.Winner == 0) { for (int p = 0; p < gameHost.Player.Length; p++) { var baseState = gameHost.TransformStateForPlayer(gameHost.GetCurrentState(), p); // player never gets access to original state var playerBaseState = new byte[baseState.Length]; Array.Copy(baseState, playerBaseState, baseState.Length); var newState = gameHost.Player[p].GetMove(playerBaseState, gameHost.MoveCount); if (!gameHost.ValidatePlayerMove(baseState, newState)) { throw new Exception("Player made illegal move."); } gameHost.SetCurrentState(gameHost.UntransformStateForPlayer(newState, p)); gameHost.PrintState(); Console.ReadKey(); } } }
public void NewGame() { host.NewGame(); }