public void TestDoGameNotFinished()
        {
            var checker = new GameResultChecker();

            var field = new sbyte[, ]
            {
                { 1, 0, 1 },
                { 0, 0, -1 },
                { 1, 0, -1 }
            };

            var result = checker.DoesGameFinished(field);

            Assert.IsFalse(result);
        }
        public void TestDoGameFinishedVerticalFinished()
        {
            var checker = new GameResultChecker();

            var field = new sbyte[, ]
            {
                { 1, -1, 1 },
                { 1, -1, -1 },
                { 1, -1, -1 }
            };

            var result = checker.DoesGameFinished(field);

            Assert.IsTrue(result);
        }
        public Board GetBoardWithDecisonExecuted(Board state)
        {
            GameTree gameTree = new GameTree(state, Me, 2, 0);

            gameTree.Expand();
            Board statusQuo = gameTree.Children.ElementAt(0).BoardState; //it may not be true status quo, but only when I can't win
            Board boardOnWhichIOccupyMiddlePoint = null;

            foreach (GameTree child in gameTree.Children)
            {
                if (IfIWin(GameResultChecker.CheckGameResult(child.BoardState)))
                {
                    return(child.BoardState);
                }
                foreach (GameTree child2 in child.Children)
                {
                    if (IfILoose(GameResultChecker.CheckGameResult(child2.BoardState)))
                    {
                        goto GoFurther;
                    }
                }
                if (child.BoardState.PositionAt(1, 1).Status == Me)
                {
                    boardOnWhichIOccupyMiddlePoint = child.BoardState;
                }
                statusQuo = child.BoardState;
GoFurther:
                continue;
            }
            if (boardOnWhichIOccupyMiddlePoint == null)
            {
                return(statusQuo);
            }
            else
            {
                return(boardOnWhichIOccupyMiddlePoint);
            }
        }
示例#4
0
        public async Task <IActionResult> Move([FromBody] List <Position> board, CancellationToken token)
        {
            foreach (var pos in board)
            {
                pos.TranslateFromInnerSystem();
            }

            var query = new Requests.AiMove.Query()
            {
                Board = board
            };
            var result = await Mediator.Send(query, token);

            var gameResult = GameResultChecker.CheckGameResult(new Board(result));

            foreach (var pos in result)
            {
                pos.TranslateToInnerSystem();
            }
            return(new JsonResult(new {
                Game = result,
                GameResult = gameResult
            }));
        }
    private void StartCheckResult()
    {
        GameObject resultChecker = (GameObject)Instantiate(Resources.Load("GameScene/GameResultChecker"));

        this.GameResultChecker = resultChecker.GetComponent <GameResultChecker>();
    }
示例#6
0
 public GameService(IUnitOfWork uow)
 {
     _database          = uow;
     _gameResultChecker = new GameResultChecker();
 }