Exemplo n.º 1
0
        public void PlayIA(Game game)
        {
            Position position = null;

            position = CheckJumpAndSquare(game);
            if (position != null)
            {
                game.Jump(position, _positionToJump);
                _positionToJump = null;
                return;
            }

            position = CheckSquare(game);
            if (position != null)
            {
                game.PlaceBall(position);
                _board.PlaceBall(new BallData(position.I, position.J, position.Stage));
                var           list      = game.BallFree();
                System.Random aleatoire = new System.Random();
                int           i         = aleatoire.Next(list.Count);
                game.RemoveSquare(list[i]);

                list = game.BallFree();
                if (!list.Any())
                {
                    return;
                }
                i = aleatoire.Next(list.Count);
                game.RemoveSquare(list[i]);
                return;
            }

            position = CheckSquareOpponent(game);
            if (position != null)
            {
                game.PlaceBall(position);
                _board.PlaceBall(new BallData(position.I, position.J, position.Stage));
                return;
            }
            position = CheckJump(game);
            if (position != null)
            {
                game.Jump(position, _positionToJump);
                _positionToJump = null;
                return;
            }
            game.PlaceBall(ChooseEmplacement(game));
            // _board.PlaceBall(new BallData(position.I, position.J, position.Stage));
        }