Exemplo n.º 1
0
        internal LocalGamePvB(IQuoridorBot unInitializedBot, string botName, GameConstraints gameConstraints, string initialProgress)
        {
            quoridorBot = unInitializedBot;
            quoridorBot.DebugMessageAvailable += OnDebugMessageAvailable;

            humenMoves        = new TimeoutBlockingQueue <Move>(200);
            gameLoopThreadPvB = new GameLoopThreadPvB(quoridorBot, botName, humenMoves, gameConstraints, initialProgress);

            gameLoopThreadPvB.NewBoardStateAvailable += OnNewBoardStateAvailable;
            gameLoopThreadPvB.WinnerAvailable        += OnWinnerAvailable;

            new Thread(gameLoopThreadPvB.Run).Start();
        }
Exemplo n.º 2
0
        public void CreateGame(IQuoridorBot uninitializedBot, string botName, GameConstraints gameConstraints, string initialProgress)
        {
            if (currentIpvBGame != null)
            {
                StopGame();
            }

            currentIpvBGame = disableBotTimeout
                                                                        ? gameFactory.CreateNewGame(uninitializedBot,
                                                                                                    botName,
                                                                                                    new GameConstraints(Timeout.InfiniteTimeSpan,
                                                                                                                        gameConstraints.MaximalMovesPerPlayer),
                                                                                                    initialProgress)
                                                                        : gameFactory.CreateNewGame(uninitializedBot,
                                                                                                    botName,
                                                                                                    gameConstraints,
                                                                                                    initialProgress);

            currentIpvBGame.DebugMessageAvailable   += OnDebugMessageAvailable;
            currentIpvBGame.NextBoardstateAvailable += OnNextBoardstateAvailable;
            currentIpvBGame.WinnerAvailable         += OnWinnerAvailable;
        }
Exemplo n.º 3
0
        public GameLoopThreadPvB(IQuoridorBot uninitializedBot,
                                 string botName,
                                 TimeoutBlockingQueue <Move> humenMoves,
                                 GameConstraints gameConstraints,
                                 string initialProgress)
        {
            bot             = uninitializedBot;
            this.botName    = botName;
            this.humenMoves = humenMoves;

            botMoves = new TimeoutBlockingQueue <Move>(200);

            bot.NextMoveAvailable += OnNextBotMoveAvailable;

            this.gameConstraints = gameConstraints;
            this.initialProgress = initialProgress;

            stopRunning = false;
            IsRunning   = false;

            botTimer = new Timer(TimerTick, null, Timeout.Infinite, Timeout.Infinite);
        }
Exemplo n.º 4
0
        public GameLoopThreadBvB(IQuoridorBot bottomPlayerBot,
                                 IQuoridorBot topPlayerBot,
                                 BoardState initialBoardState,
                                 GameConstraints gameConstraints)
        {
            this.bottomPlayerBot = bottomPlayerBot;
            this.topPlayerBot    = topPlayerBot;

            topPlayerBotMoves    = new TimeoutBlockingQueue <Move>(200);
            bottomPlayerBotMoves = new TimeoutBlockingQueue <Move>(200);

            bottomPlayerBot.NextMoveAvailable += OnNextBottomPlayerBotMoveAvailable;
            topPlayerBot.NextMoveAvailable    += OnNextTopPlayerBotMoveAvailable;

            currentBoardState    = initialBoardState;
            this.gameConstraints = gameConstraints;

            stopRunning = false;
            IsRunning   = false;

            bottomPlayerBotTimer = new Timer(TimerTickForBottomPlayerBot, null, Timeout.Infinite, Timeout.Infinite);
            topPlayerBotTimer    = new Timer(TimerTickForTopPlayerBot, null, Timeout.Infinite, Timeout.Infinite);
        }
Exemplo n.º 5
0
        internal LocalGameBvB(IQuoridorBot uninitializedTopPlayerBot,
                              IQuoridorBot uninitializedBottomPlayerBot,
                              GameConstraints gameConstraints)
        {
            var topPlayer    = new Player(PlayerType.TopPlayer);
            var bottomPlayer = new Player(PlayerType.BottomPlayer);

            topPlayerBot = uninitializedTopPlayerBot;
            topPlayerBot.Init(topPlayer.PlayerType, gameConstraints);
            topPlayerBot.DebugMessageAvailable += OnTopPlayerBotDebugMessageAvailable;

            bottomPlayerBot = uninitializedBottomPlayerBot;
            bottomPlayerBot.Init(bottomPlayer.PlayerType, gameConstraints);
            bottomPlayerBot.DebugMessageAvailable += OnBottomPlayerBotDebugMessageAvailable;

            var initialBoadState = BoardStateTransition.CreateInitialBoadState(topPlayer, bottomPlayer);

            gameLoopThreadBvB = new GameLoopThreadBvB(bottomPlayerBot, topPlayerBot, initialBoadState, gameConstraints);

            gameLoopThreadBvB.NewBoardStateAvailable += OnNewBoardStateAvailable;
            gameLoopThreadBvB.WinnerAvailable        += OnWinnerAvailable;

            new Thread(gameLoopThreadBvB.Run).Start();
        }
Exemplo n.º 6
0
 public IBvBGame CreateNewGame(IQuoridorBot uninitializedBottomPlayerBot, IQuoridorBot uninitializedTopPlayerBot, GameConstraints gameConstraints)
 {
     return(new LocalGameBvB(uninitializedTopPlayerBot, uninitializedBottomPlayerBot, gameConstraints));
 }
Exemplo n.º 7
0
 public IPvBGame CreateNewGame(IQuoridorBot uninitializedBot, string botName, GameConstraints gameConstraints, string intitialProgress)
 {
     return(new LocalGamePvB(uninitializedBot, botName, gameConstraints, intitialProgress));
 }