コード例 #1
0
        public Game CreateGame(Container container, BoardView boardView, NetworkServiceHost networkServiceHost, Color color)
        {
            Engine.Engine engine = new RealEngine(container);
            Game          game;

            // Si le joueur local est blanc
            if (color == Color.White)
            {
                PlayerControler whitePlayerControler = new BoardViewPlayerController(boardView);
                PlayerControler blackPlayerControler = new NetworkPlayerController(networkServiceHost);

                Player whitePlayer = new Player(Color.White, whitePlayerControler);
                Player blackPlayer = new Player(Color.Black, blackPlayerControler);

                game = new Game(engine, whitePlayer, blackPlayer, container);

                whitePlayer.Game = game;
                blackPlayer.Game = game;

                whitePlayerControler.Player = whitePlayer;
                blackPlayerControler.Player = blackPlayer;

                boardView.BoardViewPlayerControllers.Add((BoardViewPlayerController)whitePlayerControler);
            }
            else
            {
                PlayerControler whitePlayerControler = new NetworkPlayerController(networkServiceHost);
                PlayerControler blackPlayerControler = new BoardViewPlayerController(boardView);

                Player whitePlayer = new Player(Color.White, whitePlayerControler);
                Player blackPlayer = new Player(Color.Black, blackPlayerControler);

                game = new Game(engine, whitePlayer, blackPlayer, container);

                whitePlayer.Game = game;
                blackPlayer.Game = game;

                whitePlayerControler.Player = whitePlayer;
                blackPlayerControler.Player = blackPlayer;

                boardView.BoardViewPlayerControllers.Add((BoardViewPlayerController)blackPlayerControler);
            }

            SMTPLogger smtpLogger = new SMTPLogger(game);

            return(game);
        }
コード例 #2
0
        public override Core.Game CreateGame(Container container, BoardView boardView, Color color, GameCreatorParameters parameters)
        {
            IEngine engine = new RealEngine(container);

            Core.Game game;
            // Si le joueur local est blanc
            if (color == Color.White)
            {
                PlayerControler whitePlayerControler = new BoardViewPlayerController(boardView);
                PlayerControler blackPlayerControler = new NetworkPlayerController(NetworkServiceHost.GetNetworkServiceHost());

                Player whitePlayer = new Player(Color.White, whitePlayerControler);
                Player blackPlayer = new Player(Color.Black, blackPlayerControler);

                game = new Core.Game(engine, whitePlayer, blackPlayer, container, false);

                whitePlayer.Game = game;
                blackPlayer.Game = game;

                whitePlayerControler.Player = whitePlayer;
                blackPlayerControler.Player = blackPlayer;

                boardView.BoardViewPlayerControllers.Add((BoardViewPlayerController)whitePlayerControler);
            }
            else
            {
                PlayerControler whitePlayerControler = new NetworkPlayerController(NetworkServiceHost.GetNetworkServiceHost());
                PlayerControler blackPlayerControler = new BoardViewPlayerController(boardView);

                Player whitePlayer = new Player(Color.White, whitePlayerControler);
                Player blackPlayer = new Player(Color.Black, blackPlayerControler);

                game = new Core.Game(engine, whitePlayer, blackPlayer, container, false);

                whitePlayer.Game = game;
                blackPlayer.Game = game;

                whitePlayerControler.Player = whitePlayer;
                blackPlayerControler.Player = blackPlayer;

                boardView.BoardViewPlayerControllers.Add((BoardViewPlayerController)blackPlayerControler);
            }

            //SMTPLogger smtpLogger = new SMTPLogger(game);
            return(game);
        }
コード例 #3
0
        public override Backend.Core.Game CreateGame(Container container, BoardView boardView, Color color, GameCreatorParameters parameters)
        {
            IEngine         engine = new RealEngine(container);
            PlayerControler whitePlayerControler = new BoardViewPlayerController(boardView);
            PlayerControler lolengineController  = new LolengineController(container);
            var             whitePlayer          = new Player(Color.White, whitePlayerControler);
            var             blackLolengine       = new Player(Color.Black, lolengineController);

            var game = new Backend.Core.Game(engine, whitePlayer, blackLolengine, container, true);

            whitePlayer.Game    = game;
            blackLolengine.Game = game;

            whitePlayerControler.Player = whitePlayer;
            lolengineController.Player  = blackLolengine;

            boardView.BoardViewPlayerControllers.Add((BoardViewPlayerController)whitePlayerControler);

            return(game);
        }
コード例 #4
0
        public override Backend.Core.Game CreateGame(Container container, BoardView boardView, Color color, GameCreatorParameters parameters)
        {
            IEngine         engine = new RealEngine(container);
            PlayerControler whitePlayerControler = new BoardViewPlayerController(boardView);
            PlayerControler blackPlayerControler = new UciProcessController(container, parameters.AiSearchType, parameters.AiSkillLevel, parameters.AiSearchValue);
            var             whitePlayer          = new Player(Color.White, whitePlayerControler);
            var             blackPlayer          = new Player(Color.Black, blackPlayerControler);

            var game = new Backend.Core.Game(engine, whitePlayer, blackPlayer, container, true);

            whitePlayer.Game = game;
            blackPlayer.Game = game;

            whitePlayerControler.Player = whitePlayer;
            blackPlayerControler.Player = blackPlayer;

            boardView.BoardViewPlayerControllers.Add((BoardViewPlayerController)whitePlayerControler);

            return(game);
        }
コード例 #5
0
        public static List <Coordinate> GetBestMoves(Container container)
        {
            var pieces = new List <Piece>();

            for (var i = 0; i < container.Board.Squares.GetLength(0); i++)
            {
                for (var index2 = 0; index2 < container.Board.Squares.GetLength(0); index2++)
                {
                    if (container.Board.Squares[i, index2].Piece != null)
                    {
                        if (container.Board.Squares[i, index2].Piece.Color == Color.Black)
                        {
                            pieces.Add(container.Board.Squares[i, index2].Piece);
                        }
                    }
                }
            }

            var realEngine = new RealEngine(container);
            var moves      = new List <Moves>();

            foreach (var piece in pieces)
            {
                var possibleMoves = realEngine.PossibleMoves(piece);
                if (possibleMoves.Any())
                {
                    moves.Add(new Moves(piece, possibleMoves));
                }
            }

            var random      = new Random();
            var moveToDo    = moves[random.Next(moves.Count)];
            var coordinates = new List <Coordinate>
            {
                moveToDo.Piece.Square.Coordinate,
                moveToDo.PossibleMoves.First().Coordinate
            };

            return(coordinates);
        }
コード例 #6
0
        public override Core.Game CreateGame(Container container, BoardView boardView, Color color, GameCreatorParameters parameters)
        {
            IEngine         engine = new RealEngine(container);
            PlayerControler whitePlayerControler = new BoardViewPlayerController(boardView);
            PlayerControler blackPlayerControler = new BoardViewPlayerController(boardView);
            Player          whitePlayer          = new Player(Color.White, whitePlayerControler);
            Player          blackPlayer          = new Player(Color.Black, blackPlayerControler);

            Core.Game game = new Core.Game(engine, whitePlayer, blackPlayer, container, true);

            whitePlayer.Game = game;
            blackPlayer.Game = game;

            whitePlayerControler.Player = whitePlayer;
            blackPlayerControler.Player = blackPlayer;

            boardView.BoardViewPlayerControllers.Add((BoardViewPlayerController)whitePlayerControler);
            boardView.BoardViewPlayerControllers.Add((BoardViewPlayerController)blackPlayerControler);

            //TODO Remvoe the logger
            //SMTPLogger smtpLogger = new SMTPLogger(game);
            return(game);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: mikezhuyuan/Test-Git
        static void Main(string[] args)
        {
            var sinas = new List<Sina>{
                new RealSina("*****@*****.**", "1234qwer", "2448595899"),
                new RealSina("*****@*****.**", "1234qwer", "2546876916"),
                new RealSina("*****@*****.**", "1234qwer", "51923812"),
                new RealSina("*****@*****.**", "1234qwer", "2343725106"),
            };

            Engine engine = new RealEngine(sinas);
            engine.Process();
        }