private void UpdateOpponentState(GomokuPlayer player, GameData data) { if (player == PlayerBlue) { PlayerRed.UpdateState(data); } if (player == PlayerRed) { PlayerBlue.UpdateState(data); } }
public async Task RunAuto() { var data = Game.StartGame(Team.Blue); OnGameStarted?.Invoke(data); Console.WriteLine("Runner started an auto game!"); while (Game.State != GameState.GameEnded) { Point move; if (Game.PlayerTurn == Team.Blue) { move = PlayerBlue.ProposeMove(data); PlayerRed.UpdateState(data); } else { move = PlayerRed.ProposeMove(data); PlayerBlue.UpdateState(data); } data = Game.TryMakeMove(Game.PlayerTurn, move); if (data.Code == ResponseCode.OK) { await OnMoveCompleted?.Invoke(data); } if (Game.State == GameState.GameEnded) { await OnMoveCompleted?.Invoke(data); await OnGameEnded?.Invoke(data); return; } await Task.Delay(500); } //if (data.Code == ResponseCode.Draw) // Console.WriteLine("Draw!"); //else // Console.WriteLine("{0} Lost! (Point {1})", data.NextPlayer, data.Updated); }