internal static int CalculateMove(IPlayer MyEngine, IPlayer MyPlayer) { if (GetAllRiskyCombinationsOfTwo(MyEngine.Moves, MyPlayer.Moves).Count > 0 && GetAllRiskyCombinationsOfTwo(MyEngine.Moves, MyPlayer.Moves).Count < 1) { return(BlockingStrategy.WithAllCombinationsCalculateBlock(MyEngine.Moves, MyPlayer.Moves)); } return(WiningStrategy.CalculateWiningMove(MyEngine.Moves, MyPlayer.Moves)); }
private string Play() { switch (MyGame.MyPlayer.Moves.Count) { case 1: MyGame.MyEngine.Moves.Add(BlockingStrategy.FirstMove(MyGame.MyPlayer)); return($" Computer First move is: {MyGame.MyEngine.Moves[0]} "); case 2: if (EngineManager.GetAllRiskyCombinationsOfTwo(MyGame.MyEngine.Moves, MyGame.MyPlayer.Moves).Count > 0) { MyGame.MyEngine.Moves.Add(BlockingStrategy.WithAllCombinationsCalculateBlock(MyGame.MyEngine.Moves, MyGame.MyPlayer.Moves)); return($" Computer Second move is: {MyGame.MyEngine.Moves[1]} "); } MyGame.MyEngine.Moves.Add(WiningStrategy.CalculateWiningMove(MyGame.MyEngine.Moves, MyGame.MyPlayer.Moves)); return($" Computer Second move is: {MyGame.MyEngine.Moves[1]} "); case 3: if (WinnerStateChecker.CheckState(MyGame.MyPlayer)) { return("YOU WIN!"); } if (EngineManager.GetAllRiskyCombinationsOfTwo(MyGame.MyEngine.Moves, MyGame.MyPlayer.Moves).Count > 0 && EngineManager.GetAllRiskyCombinationsOfTwo(MyGame.MyPlayer.Moves, MyGame.MyEngine.Moves).Count < 1) { MyGame.MyEngine.Moves.Add(BlockingStrategy.WithAllCombinationsCalculateBlock(MyGame.MyEngine.Moves, MyGame.MyPlayer.Moves)); if (WinnerStateChecker.CheckState(MyGame.MyEngine)) { return($" Computer Third move is: {MyGame.MyEngine.Moves[2]}, Haha, You loose"); } return($" Computer Third move is: {MyGame.MyEngine.Moves[2]} "); } MyGame.MyEngine.Moves.Add(WiningStrategy.CalculateWiningMove(MyGame.MyEngine.Moves, MyGame.MyPlayer.Moves)); if (WinnerStateChecker.CheckState(MyGame.MyEngine)) { return($" Computer Third move is: {MyGame.MyEngine.Moves[2]}, oh Haha, You loose"); } return($" Computer Third move is: {MyGame.MyEngine.Moves[2]} "); case 4: if (WinnerStateChecker.CheckState(MyGame.MyPlayer)) { return("YOU WIN!"); } if (EngineManager.GetAllRiskyCombinationsOfTwo(MyGame.MyEngine.Moves, MyGame.MyPlayer.Moves).Count > 0 && EngineManager.GetAllRiskyCombinationsOfTwo(MyGame.MyPlayer.Moves, MyGame.MyEngine.Moves).Count < 1) { MyGame.MyEngine.Moves.Add(BlockingStrategy.WithAllCombinationsCalculateBlock(MyGame.MyEngine.Moves, MyGame.MyPlayer.Moves)); if (WinnerStateChecker.CheckState(MyGame.MyEngine)) { return($" Computer Fourth move is: {MyGame.MyEngine.Moves[3]}, Haha, You loose"); } return($" Computer Fourth move is: {MyGame.MyEngine.Moves[3]} "); } MyGame.MyEngine.Moves.Add(WiningStrategy.CalculateWiningMove(MyGame.MyEngine.Moves, MyGame.MyPlayer.Moves)); if (WinnerStateChecker.CheckState(MyGame.MyEngine)) { return($" Computer Fourth move is: {MyGame.MyEngine.Moves[3]}, Haha, You loose"); } return($" Computer Fourth move is: {MyGame.MyEngine.Moves[3]} "); case 5: if (WinnerStateChecker.CheckState(MyGame.MyPlayer)) { return("YOU WIN!"); } if (EngineManager.GetAllRiskyCombinationsOfTwo(MyGame.MyEngine.Moves, MyGame.MyPlayer.Moves).Count > 0 && EngineManager.GetAllRiskyCombinationsOfTwo(MyGame.MyPlayer.Moves, MyGame.MyEngine.Moves).Count < 1) { MyGame.MyEngine.Moves.Add(BlockingStrategy.WithAllCombinationsCalculateBlock(MyGame.MyEngine.Moves, MyGame.MyPlayer.Moves)); if (WinnerStateChecker.CheckState(MyGame.MyEngine)) { return($" Computer Fifth move is: {MyGame.MyEngine.Moves[4]}, Haha, You loose"); } return($" Computer Fifth move is: {MyGame.MyEngine.Moves[4]} "); } MyGame.MyEngine.Moves.Add(WiningStrategy.CalculateWiningMove(MyGame.MyEngine.Moves, MyGame.MyPlayer.Moves)); if (WinnerStateChecker.CheckState(MyGame.MyEngine)) { return($" Computer Fifth move is: {MyGame.MyEngine.Moves[4]}, Haha, You loose"); } return($" Computer Fifth move is: {MyGame.MyEngine.Moves[4]} "); default: return("Inesperated Error"); } }