public Common.MoveResult Move(Common.Move move) { var response = new Common.MoveResult(); response.PlayerMoveResult = gameLogic.Move(move); if (response.PlayerMoveResult == Common.MoveResponse.Sucess) { response.OpponentMove = ((AI)player2).MakeMove(gameLogic); } if (gameLogic.IsGameOver()) { response.PlayerMoveResult = Common.MoveResponse.GameOver; return(response); } return(response); }
public Common.MoveResult Move(Common.Move move) { var response = new Common.MoveResult(); response.OpponentMove = new Move(); response.PlayerMoveResult = gameLogic.Move(move); if (response.PlayerMoveResult == Common.MoveResponse.Sucess) { gameLogic.gameBoard.UpdateBoard(move, gameLogic.IsPlayer1sTurn()); gameLogic.SwitchTurns(); if (isAIInitialized) { ((AI)player2).UpdateBoard(move.x, move.y, 1); int[] xy = AIMove();//((AI)player2).Move(2, 1); response.OpponentMove.x = xy[0]; response.OpponentMove.y = xy[1]; gameLogic.gameBoard.UpdateBoard(response.OpponentMove, false); } else { ((AI)player2).UpdateBoard(move.x, move.y, 1); int[] xy = ((AI)(player2)).Initialize(2, (int)DateTime.Now.Ticks);//send time as seed response.OpponentMove.x = xy[0]; response.OpponentMove.y = xy[1]; gameLogic.gameBoard.UpdateBoard(response.OpponentMove, false); isAIInitialized = true; } gameLogic.SwitchTurns(); } if (gameLogic.GameWon()) { response.PlayerMoveResult = Common.MoveResponse.GameOver; return(response); } return(response); }